The shared draw-interaction binder. Create once per tool; call DrawController.start to begin a shape and DrawController.dispose on widget teardown.
import { DrawController, pickScenePosition } from '@bitruvius/sdk-maplibre';const draw = new DrawController({ map, pickFn: (x, y) => pickScenePosition(map, [buildings], x, y), onChange: (state) => { if (state.phase === 'done') console.log(state.vertices); },});draw.start('polyline'); // click to add vertices; dblclick or Enter finishes, Escape cancels Copy
import { DrawController, pickScenePosition } from '@bitruvius/sdk-maplibre';const draw = new DrawController({ map, pickFn: (x, y) => pickScenePosition(map, [buildings], x, y), onChange: (state) => { if (state.phase === 'done') console.log(state.vertices); },});draw.start('polyline'); // click to add vertices; dblclick or Enter finishes, Escape cancels
The current DrawState (immutable snapshot).
Abandon the current shape — back to idle, keeping the mode (a finished shape is discarded too).
Clear everything back to idle.
Apply an action (the single mutation path) and notify.
Unbind all listeners (widget teardown).
Begin drawing a new shape (clears any previous one).
The shared draw-interaction binder. Create once per tool; call DrawController.start to begin a shape and DrawController.dispose on widget teardown.
Example