From ee9244644d574cfc7532af3b3f961baa821bf53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bo=CC=88ttcher?= Date: Mon, 27 Jun 2022 09:48:23 +0200 Subject: [PATCH 1/2] the zoom speed using the mouse wheel can be adjusted --- lib/flutter_map.dart | 2 ++ lib/src/gestures/gestures.dart | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 5d7b2b3b1..a8d90ba3c 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -253,6 +253,7 @@ class MapOptions { /// his mouse. This is supported on web and desktop, but might also work well /// on Android. A [Listener] is used to capture the onPointerSignal events. final bool enableScrollWheel; + final double scrollWheelVelocity; final double? minZoom; final double? maxZoom; @@ -309,6 +310,7 @@ class MapOptions { this.pinchMoveWinGestures = MultiFingerGesture.pinchZoom | MultiFingerGesture.pinchMove, this.enableScrollWheel = true, + this.scrollWheelVelocity = 0.005, this.minZoom, this.maxZoom, this.interactiveFlags = InteractiveFlag.all, diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index 00e11ae44..dfdb8fe53 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -58,7 +58,7 @@ abstract class MapGestureMixin extends State // Calculate new zoom level final minZoom = mapState.options.minZoom ?? 0.0; final maxZoom = mapState.options.maxZoom ?? double.infinity; - final newZoom = (mapState.zoom + pointerSignal.scrollDelta.dy * -0.005) + final newZoom = (mapState.zoom - pointerSignal.scrollDelta.dy * mapState.options.scrollWheelVelocity) .clamp(minZoom, maxZoom); // Calculate offset of mouse cursor from viewport center final List newCenterZoom = _getNewEventCenterZoomPosition( From d45f3daeb03356dc3ad8764698c68ca5005a7f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bo=CC=88ttcher?= Date: Tue, 28 Jun 2022 08:43:15 +0200 Subject: [PATCH 2/2] fixed formatting --- lib/src/gestures/gestures.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index dfdb8fe53..cec76503e 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -58,7 +58,9 @@ abstract class MapGestureMixin extends State // Calculate new zoom level final minZoom = mapState.options.minZoom ?? 0.0; final maxZoom = mapState.options.maxZoom ?? double.infinity; - final newZoom = (mapState.zoom - pointerSignal.scrollDelta.dy * mapState.options.scrollWheelVelocity) + final newZoom = (mapState.zoom - + pointerSignal.scrollDelta.dy * + mapState.options.scrollWheelVelocity) .clamp(minZoom, maxZoom); // Calculate offset of mouse cursor from viewport center final List newCenterZoom = _getNewEventCenterZoomPosition(