From ad1456d7b77f49ca1c6c016e37c9c1af3cb94c4c Mon Sep 17 00:00:00 2001 From: mvan Date: Wed, 12 Apr 2023 10:53:25 +0200 Subject: [PATCH] Added onCameraMove event on the map controller --- lib/src/controller.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 2a4201b7..55cc0e9c 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -29,6 +29,8 @@ typedef void OnCameraIdleCallback(); typedef void OnMapIdleCallback(); +typedef void OnCameraMoveCallback(CameraPosition location); + /// Controller for a single MaplibreMap instance running on the host platform. /// /// Change listeners are notified upon changes to any of @@ -89,6 +91,9 @@ class MaplibreMapController extends ChangeNotifier { _mapboxGlPlatform.onCameraMovePlatform.add((cameraPosition) { _cameraPosition = cameraPosition; + for (final fun in List.of(onCameraMove)) { + fun(cameraPosition); + } notifyListeners(); }); @@ -184,6 +189,8 @@ class MaplibreMapController extends ChangeNotifier { final OnMapIdleCallback? onMapIdle; + final onCameraMove = []; + /// Callbacks to receive tap events for symbols placed on this map. final ArgumentCallbacks onSymbolTapped = ArgumentCallbacks();