Git Product home page Git Product logo

react-map-gl's Introduction

version build downloads

react-map-gl | Docs

React Components Suite for Mapbox GL JS.

In addition to exposing MapboxGL functionality to React apps, react-map-gl also integrates seamlessly with deck.gl.

Installation

Using react-map-gl requires node >= v4 and react >= 15.4.

npm install --save react-map-gl

Example

import {Component} from 'react';
import ReactMapGL from 'react-map-gl';

class Map extends Component {

  state = {
    viewport: {
      width: 400,
      height: 400,
      latitude: 37.7577,
      longitude: -122.4376,
      zoom: 8
    }
  };

  render() {
    return (
      <ReactMapGL
        {...this.state.viewport}
        onViewportChange={(viewport) => this.setState({viewport})}
      />
    );
  }
}

About Mapbox Tokens

To show maps from a service such as Mapbox you will need to register on their website in order to retrieve an access token required by the map component, which will be used to identify you and start serving up map tiles. The service will be free until a certain level of traffic is exceeded.

There are several ways to provide a token to your app, as showcased in some of the example folders:

  • Modify the source directly
  • Set the MapboxAccessToken environment variable
  • Provide it in the URL, e.g ?access_token=TOKEN

But we would recommend using something like dotenv and put your key in an untracked .env file, that will then expose it as a process.env variable, with much less leaking risks.

Contribute

See developer guide.

react-map-gl's People

Contributors

pessimistress avatar vicapow avatar ibgreen avatar abmai avatar trysound avatar philogb avatar schnerd avatar jwarning avatar forrert avatar chris-catignani avatar tsemerad avatar vinkla avatar rilyu avatar mattdesl avatar willyham avatar wwwtyro avatar pranspach avatar ericsoco avatar drewbo avatar cammanderson avatar joao avatar joeduncan avatar pilotconway avatar jdeerhake avatar j0nas avatar lafin avatar lucafalasco avatar cl0ckwork avatar epicallan avatar koulmomo avatar

Watchers

James Cloos avatar Sid Ali Bentifraouine 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.