diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index d66870cf0..fd68063a6 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -37,7 +37,8 @@ abstract class MapGestureMixin extends State : max(mapState.options.minZoom ?? 0, mapState.zoom + delta); final newZoom = mapState.fitZoomToBounds(zoom); // Move the map to the new zoom level - mapState.move(mapState.center, newZoom, source: MapEventSource.custom); + mapState.move(mapState.center, newZoom, + source: MapEventSource.scrollWheel); } } } diff --git a/lib/src/gestures/map_events.dart b/lib/src/gestures/map_events.dart index 2180d40a9..e6825d194 100644 --- a/lib/src/gestures/map_events.dart +++ b/lib/src/gestures/map_events.dart @@ -19,7 +19,8 @@ enum MapEventSource { interactiveFlagsChanged, fitBounds, initialization, - custom + custom, + scrollWheel, } /// Base event class which is emitted by MapController instance, the event @@ -183,6 +184,23 @@ class MapEventDoubleTapZoom extends MapEventWithMove { ); } +/// Event which is fired when scroll wheel is used to zoom +class MapEventScrollWheelZoom extends MapEventWithMove { + MapEventScrollWheelZoom({ + required LatLng targetCenter, + required double targetZoom, + required MapEventSource source, + required LatLng center, + required double zoom, + }) : super( + targetCenter: targetCenter, + targetZoom: targetZoom, + source: source, + center: center, + zoom: zoom, + ); +} + /// Event which is fired when animation for double tap gesture is started class MapEventDoubleTapZoomStart extends MapEvent { MapEventDoubleTapZoomStart( diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index cc352326f..3c56ac171 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -200,6 +200,16 @@ class MapState { source: source, ), ); + } else if (source == MapEventSource.scrollWheel) { + emitMapEvent( + MapEventScrollWheelZoom( + center: _lastCenter!, + zoom: _zoom, + targetCenter: targetCenter, + targetZoom: targetZoom, + source: source, + ), + ); } else if (source == MapEventSource.onDrag || source == MapEventSource.onMultiFinger) { emitMapEvent(