Skip to main content
Version: 0.1.x

Events

The event system is the used if you want to listen to any user interactions or state changes on the map.

Basic Usage

To listen to map events, implement a callback function for the onEvent parameter.

  
Widget build(BuildContext context) {
return MapLibreMap(
options: MapOptions(center: Position(9.17, 47.68)),
onEvent: _onEvent,
);
}

void _onEvent(event) {
print(event.runtimeType);

// check for the event type
if (event is MapEventClicked) {
print('The map has been clicked at ${event.point.lng}, ${event.point.lat}');
}

// or use a switch statement to listen to all the events you are interested in
switch (event) {
case MapEventMapCreated():
print('map created');
case MapEventStyleLoaded():
print('style loaded');
default:
// ignore all other events
}
}

Available Events

FlutterWebAndroidiOSWindowsMacOSLinux
MapEventMapCreated
MapEventStyleLoadedload(OnDidFinishLoadingStyleListener)
MapEventClickedclickOnMapClickListener
MapEventDoubleClickeddblclick
MapEventSecondaryClickedcontextmenu
MapEventLongClickedOnMapLongClickListener
MapEventIdleidleOnDidBecomeIdleListener
mousedown
MapEventStartMoveCameraOnCameraMoveStartedListener
MapEventMoveCameramoveOnCameraMoveListener
MapEventCameraIdlemoveendOnCameraMoveCanceledListener