useOlDrawEventListener
useOlDrawEventListener(
draw,type,listener):void
Defined in: src/use-ol-draw-event-listener.ts:33
Hook to attach an event listener to an OpenLayers Draw interaction. Automatically handles cleanup when the component unmounts or dependencies change.
Parameters
Section titled “Parameters”The OpenLayers Draw interaction instance (null-safe)
Draw | null
The type of draw event to listen for (e.g., ‘drawstart’, ‘drawend’, ‘drawabort’)
listener
Section titled “listener”The callback function to execute when the event fires
Returns
Section titled “Returns”void
Example
Section titled “Example”const draw = useOlDraw()useOlDrawEventListener(draw, 'drawend', (evt) => { console.log('Feature drawn', evt.feature)})