This is a custom mode for Mapbox GL Draw 1.x that adds the LineString cutting/splitting functionality
yarn add mapbox-gl-draw-cut-line-mode
import CutLineMode from 'mapbox-gl-draw-cut-line-mode';
const modes = MapboxDraw.modes;
modes.cut_line = CutLineMode;
const draw = new MapboxDraw({
modes: modes
});
draw.changeMode('cut_line');
Once a feature is splitted, 2 events are fired:
draw.delete
with the id of the deleted featuredraw.create
with the new (children) features
See a full example in the example folder.
yarn build
will do it.
MIT