/mapbox-gl-draw

Draw tools for mapbox-gl-js

Primary LanguageJavaScriptBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

GL Draw

Adds support for drawing and editing features on Mapbox GL JS maps.

Circle CI

Installing

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" />

Usage

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.

Developing

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-example/ && open http://localhost:9966/examples/node-example/

Testing

npm run test