npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jailbreak-paris/svelte-mapbox-gl

v0.1.9

Published

Mapbox GL components for Svelte

Downloads

26

Readme

svelte-mapbox-gl

Svelte 3 components for Mapbox GL.

Mapbox GL JS is a JavaScript library that uses WebGL to render interactive maps from vector tiles and Mapbox styles.

Svelte is a JavaScript compiler used to build user interfaces similar to React or Vue, but lighter because components are compiled.

The provided components follow Svelte idioms as much as possible (declarative props, etc.), while keeping the same namings used by Mapbox GL JS (for objects, options and events).

Usage

See Storybook: https://jailbreak.gitlab.io/svelte-mapbox-gl

Basic usage:

<script>
  import {
    Map,
    Marker,
    NavigationControl,
    Popup
  } from "@jailbreak-paris/svelte-mapbox-gl";
  const coordinates = { lat: 48, lng: 3 };
</script>

<Map
  accessToken="xxx"
  style="mapbox://styles/mapbox/streets-v11"
  center={coordinates}
  zoom={10}>
  <NavigationControl />
  <Marker {coordinates}>
    <Popup>I'm a popup attached to a marker!</Popup>
  </Marker>
</Map>

Mapbox GL Javascript and CSS

This package defines mapbox-gl as a peer dependency. It needs it, but it's the responsibility of the application using it to provide the mapbox-gl module.

About JavaScript two scenarios are possible:

  • source Mapbox GL script in the DOM via a <script src=""> tag targeting the CDN URL, and configure your module bundler (e.g. Rollup, Webpack, etc.) to consider the mapbox-gl module as external (see below).
  • install the mapbox-gl from npm in your application

About CSS two scenarios are possible:

  • source Mapbox GL stylesheet in the DOM via a <link> tag targeting the CDN URL
  • import mapbox-gl/dist/mapbox-gl.css from your JavaScript code and setup your module bundler to manage CSS

See also: https://docs.mapbox.com/mapbox-gl-js/overview/

If you choose to include the script via a <script> DOM element, you must configure your module bundler to let it "redirect" the mapbox-gl module to the global variable window.mapboxgl which is provided by the sourced <script>. For example, see Webpack externals or Rollup globals + externals.

Access token

To avoid hard-coding your accessToken, you may load it from your environment (e.g. with dotenv). The Storybook uses the access token of all Mapbox GL JS demos (e.g. Display a map).

Documentation

TODO

Meanwhile, read the source code and look at the Storybook to know about components, their properies and events.

Similar projects

  • https://github.com/beyonk-adventures/svelte-mapbox
  • https://soal.github.io/vue-mapbox/
  • http://alex3165.github.io/react-mapbox-gl/
  • https://uber.github.io/react-map-gl/