Events

Every map module has one events object for what users do on its features and for what happens to the module itself. Map style changes and raw MapLibre events have their own hooks.

You want to react toUseGuide
A click, right click, hover or long hover on a place, route, traffic incident or your own datamodule.events.on('click', …)User interaction events
A click or hover on the rest of the mapBaseMapModule eventsHandling events on the rest of the map
The pointer leaving a feature, to un-highlight your own UIA base map hover, and MapLibre’s mouseoutEnding a hover
Selecting or highlighting a feature from your own UIsetEventState, getEventStatesEvent states
A module’s configuration changing, to keep your UI in syncmodule.events.on('config-change', …)Module lifecycle events
New data drawn by a module’s showmodule.events.on('shown-features', …)Module lifecycle events
A map style switch, to keep your own layers or a dark-mode classmap.addStyleChangeHandler(…)Listening to style changes
Map lifecycle such as load, moveend or zoommap.mapLibreMap.on(…)MapLibre Map events

For anything a module draws, use the module’s events instead of a raw MapLibre listener. Only the top-most feature receives the event, the cursor has one state, and handlers get your original typed data. About MapLibre explains when to use the raw listener.