Package Exports
- @urbica/react-map-gl
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@urbica/react-map-gl) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Urbica React Mapbox GL JS
React Component for Mapbox GL JS.
Mapbox GL JS is a JavaScript library that renders interactive maps from vector tiles and Mapbox styles using WebGL.
To use any of Mapbox’s tools, APIs, or SDKs, you’ll need a Mapbox access token. Mapbox uses access tokens to associate requests to API resources with your account. You can find all your access tokens, create new ones, or delete existing ones on your API access tokens page.
This package is heavily inspired by uber/react-map-gl.
Installation
npm install --save mapbox-gl immutable@4.0.0-rc.2 @urbica/react-map-gl
Example
import MapGL from '@urbica/react-map-gl';
const accessToken = <TOKEN> // Mapbox access token
<MapGL
style={{ width: '400px', height: '400px' }}
accessToken={accessToken}
mapStyle="mapbox://styles/mapbox/streets-v9"
latitude={37.7577}
longitude={-122.4376}
zoom={8}
onViewportChange={viewport => {
// Call `setState` and use the state to update the map.
}}
/>
See API for more info.
Development
Install project dependencies and check that the tests run
npm install
npm test
Then start the storybook by running the shortcut
MAPBOX_ACCESS_TOKEN=<TOKEN> npm run styleguide
where <TOKEN>
is a valid Mapbox access token.