From a54ab728da497663101a79cca79b82ac2a9a73ff Mon Sep 17 00:00:00 2001 From: Alfanhui Date: Thu, 7 Jun 2018 17:09:14 +0100 Subject: [PATCH] Applied constraints to zoom on gesture update if min or max options set --- flutter_map/lib/src/gestures/gestures.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flutter_map/lib/src/gestures/gestures.dart b/flutter_map/lib/src/gestures/gestures.dart index e83444308..c4873aa71 100644 --- a/flutter_map/lib/src/gestures/gestures.dart +++ b/flutter_map/lib/src/gestures/gestures.dart @@ -70,7 +70,13 @@ abstract class MapGestureMixin extends State var offsetPt = newCenter - map.project(_mapCenterStart); _animationOffset = _pointToOffset(offsetPt); + //Abide to min/max zoom var newZoom = _mapZoomStart * dScale; + if (options.maxZoom != null) + newZoom = (newZoom > options.maxZoom) ? options.maxZoom : newZoom; + if (options.minZoom != null) + newZoom = (newZoom < options.minZoom) ? options.minZoom : newZoom; + map.move(map.unproject(newCenter), newZoom); }); }