This is the documentation of version 1.0.0-rc.2. Go to the latest version, 1.0.0-rc.5.

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 to Use Guide
A click, right click, hover or long hover on a place, route, traffic incident or your own data module.events.on('click', …) User interaction events
A click or hover on the rest of the map BaseMapModule events Handling events on the rest of the map
Selecting or highlighting a feature from your own UI setEventState, getEventStates Event states
A module's configuration changing, to keep your UI in sync module.events.on('config-change', …) Module lifecycle events
New data drawn by a module's show module.events.on('shown-features', …) Module lifecycle events
A map style switch, to keep your own layers or a dark-mode class map.addStyleChangeHandler(…) Listening to style changes
Map lifecycle such as load, moveend or zoom map.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.