Code Monkey home page Code Monkey logo

react-map-gl's Introduction

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 new and the API may change. There also may be Mapbox APIs that haven't yet been exposed.

Overview

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

react-map-gl provides an overlay API so you can use the builtin visualization overlays, or create your own. Here's an example of using the build in ScatterplotOverlay.

var ScatterplotOverlay = require('react-map-gl/src/overlays/scatterplot.react');
// ...
<MapGL {...mapProps}>
  <ScatterplotOverlay locations={locations} dotRadius={4} globalOpacity={1}
    compositeOperation="screen" />
  // Add additional overlays here...
])

Build in overlays

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

Third party overlays

Other third party overlays can also be created. For example, the heatmap-overlay uses webgl-heatmap to create geographic heatmaps.

Example usage:

var HeatmapOverlay = require('react-map-gl-heatmap-overlay');
var cities = require('example-cities');
// ...
    render: function render() {
      return <MapGL ...viewportProps>
        <HeatmapOverlay locations={cities} />
      </MapGL>;
    }

Want to create and share your own overlay? Fork the react-map-gl-example-overlay project to get started.

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.

react-map-gl's People

Contributors

vicapow avatar philogb avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.