JSPM

react-map-gl

0.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 636168
  • Score
    100M100P100Q175773F
  • License MIT

A React wrapper for MapboxGL-js and overlay API.

Package Exports

  • 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 (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

react-map-gl

react-map-gl provides a React friendly API wrapper around Mapbox GL JS. A webGL based vector tile mapping library.

WARNING: This project is still very new and the API may change. There also may be Mapbox APIs that haven't yet been exposed.

Overview

react-map-gl provides an overlay API so you can add visualization overlays.

Supported Overlays:

  1. ChoroplethOverlay
  2. ScatterplotOverlay
  3. DraggablePointsOverlay
  4. SVGOverlay
  5. CanvasOverlay

Installation

npm install react-map-gl --save

Usage

<MapGL width={400} height={400} latitude={37.7577} longitude={-122.4376}
  zoom={8} onChangeViewport={function(opts) {
    // opts = {latitude, longitude, zoom, bbox}
  }}
/>

Using overlays

<MapGL {...mapProps}>
  <ScatterplotOverlay locations={locations} dotRadius={4} globalOpacity={1}
    compositeOperation="screen" />
  // Add additional overlays here...
])

ImmutableJS all the things

The mapStyle property of the MapGL as well as several of the built in overlay properties must be provided as ImmutableJS objects. This allows the library to be fast since computing changes to props only involves checking if the immutable objects are the same instance.

Development

To develop on this component, install the dependencies and then build and watch the static files.

$ npm install

To serve example app:

$ npm start &
$ open "http://localhost:9966/?access_token="`echo $MapboxAccessToken`

Where echo $MapboxAccessToken returns your Mapbox access token.

Once complete, you can view the component in your browser at localhost:9966. Any changes you make will automatically run the compiler to build the files again.

Disclaimer

This project is not affiliated with either Facebook or Mapbox.

Example Data

  1. SF GeoJSON data from: SF OpenData.