React-mapbox-gl | Documentation | Demos

A React binding of mapbox-gl-js
Under MIT License
By alex3165

react map mapbox-gl-js react-mapbox-gl mapbox-gl

React-mapbox-gl | Documentation | Demos

React wrapper for mapbox-gl-js.

Proxy components (proxy between React and Mapbox API)

DOM components (normal React components)

Getting Started

npm install react-mapbox-gl mapbox-gl --save


Adding the css in your index.html:


// ES6
import ReactMapboxGl, { Layer, Feature } from 'react-mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';

// ES5
var ReactMapboxGl = require('react-mapbox-gl');
var Layer = ReactMapboxGl.Layer;
var Feature = ReactMapboxGl.Feature;

const Map = ReactMapboxGl({

// in render()


Why are zoom, bearing and pitch Arrays ?

If those properties changed at the mapbox-gl-js level and you don't update the value kept in your state, it will be unsynced with the current viewport. At some point you might want to update the viewport value (zoom, pitch or bearing) with the ones in your state but using value equality is not enough. Taking zoom as example, you will still have the unsynced zoom value therefore we can't tell if you want to update the prop or not. In order to explicitly update the current viewport values you can instead break the references of those props and reliably update the current viewport with the one you have in your state to be synced again.

Current version documentation
Version 3.0 documentation
Version 2.0 documentation

Please try to reproduce your problem with the boilerplate before posting an issue.

mapbox-gl-draw compatibility

Try react-mapbox-gl-draw

Looking for an Angular alternative?

Try ngx-mapbox-gl