A custom mode for MapboxGL Draw to draw rectangles
npm install mapbox-gl-draw-rectangle-modeThis is a custom mode for Mapbox GL Draw that adds the functionality to draw rectangles
yarn add mapbox-gl-draw-rectangle-mode
https://bl.ocks.org/andrewharvey/31b8180e3f5f1e12849a352796e0daf4
``js
import DrawRectangle from 'mapbox-gl-draw-rectangle-mode';
const modes = MapboxDraw.modes;
modes.draw_rectangle = DrawRectangle;
const draw = new MapboxDraw({
modes: modes
});
draw.changeMode('draw_rectangle');
`
Once a rectangle is created, 1 events is fired:
- draw.create with the created rectangle
yarn build` will do it.
MIT