Skip to content

useOlSelectEventListener

useOlSelectEventListener(select, type, listener): Select | null

Defined in: src/use-ol-select-event-listener.tsx:36

Hook to attach an event listener to an OpenLayers Select interaction. Automatically handles cleanup when the component unmounts or dependencies change.

The OpenLayers Select interaction instance (null-safe)

Select | null

SelectEventType

The type of select event to listen for (e.g., ‘select’)

SelectListener

The callback function to execute when the event fires

Select | null

The Select interaction instance

const select = useOlLayerSelect()
useOlSelectEventListener(select, 'select', (evt) => {
console.log('Selected features', evt.selected)
})