Adds support for drawing and editing features on Mapbox GL JS maps.
git clone https://github.com/mapbox/mapbox-gl-draw.git
cd mapbox-gl-draw
npm install
Include mapbox-gl-draw.js after mapbox-gl.js
<script src="mapbox-gl.js"></script>
<script src="mapbox-gl-draw.js"></script>
Also include mapbox-gl-draw.css
<link href="mapbox-gl-draw.css" rel="stylesheet" />
mapboxgl.accessToken = 'YOUR_ACCESS_TOKEN';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8',
center: [40, -74.50],
zoom: 9
});
var Draw = mapboxgl.Draw();
map.addControl(Draw)
See API.md for complete reference.
Install dependencies, build the source files and crank up a server via:
npm start & open http://localhost:9966/debug
To run the example apps
npm run-script build-examples
npm start
open http://localhost:9966/examples/geojson-editor/ && open http://localhost:9966/examples/node/
npm run test