Skip to content

Commit 8d106d2

Browse files
fix(example): ensure zoom buttons zoom by a full zoom level only (#1861)
1 parent c2806fd commit 8d106d2

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

example/lib/plugins/zoombuttons_plugin.dart

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class FlutterMapZoomButtons extends StatelessWidget {
1616
final IconData zoomInIcon;
1717
final IconData zoomOutIcon;
1818

19-
static const _fitBoundsPadding = EdgeInsets.all(12);
20-
2119
const FlutterMapZoomButtons({
2220
super.key,
2321
this.minZoom = 1,
@@ -52,12 +50,8 @@ class FlutterMapZoomButtons extends StatelessWidget {
5250
mini: mini,
5351
backgroundColor: zoomInColor ?? theme.primaryColor,
5452
onPressed: () {
55-
final paddedMapCamera = CameraFit.bounds(
56-
bounds: camera.visibleBounds,
57-
padding: _fitBoundsPadding,
58-
).fit(camera);
59-
final zoom = min(paddedMapCamera.zoom + 1, maxZoom);
60-
controller.move(paddedMapCamera.center, zoom);
53+
final zoom = min(camera.zoom + 1, maxZoom);
54+
controller.move(camera.center, zoom);
6155
},
6256
child: Icon(zoomInIcon,
6357
color: zoomInColorIcon ?? theme.iconTheme.color),
@@ -70,15 +64,8 @@ class FlutterMapZoomButtons extends StatelessWidget {
7064
mini: mini,
7165
backgroundColor: zoomOutColor ?? theme.primaryColor,
7266
onPressed: () {
73-
final paddedMapCamera = CameraFit.bounds(
74-
bounds: camera.visibleBounds,
75-
padding: _fitBoundsPadding,
76-
).fit(camera);
77-
var zoom = paddedMapCamera.zoom - 1;
78-
if (zoom < minZoom) {
79-
zoom = minZoom;
80-
}
81-
controller.move(paddedMapCamera.center, zoom);
67+
final zoom = max(camera.zoom - 1, minZoom);
68+
controller.move(camera.center, zoom);
8269
},
8370
child: Icon(zoomOutIcon,
8471
color: zoomOutColorIcon ?? theme.iconTheme.color),

0 commit comments

Comments
 (0)