Skip to content

Commit

Permalink
Fix example ZoomButtonsPluginOption (#1120)
Browse files Browse the repository at this point in the history
* Fix ZoomButtonsPluginOption to check min and max properly (x2)
  • Loading branch information
chriscant authored Jan 29, 2022
1 parent 95c05b5 commit bb0b9c5
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions example/lib/pages/zoombuttons_plugin_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';

class ZoomButtonsPluginOption extends LayerOptions {
final int minZoom;
final int maxZoom;
final double minZoom;
final double maxZoom;
final bool mini;
final double padding;
final Alignment alignment;
Expand Down Expand Up @@ -78,12 +78,11 @@ class ZoomButtons extends StatelessWidget {
var bounds = map.getBounds();
var centerZoom = map.getBoundsCenterZoom(bounds, options);
var zoom = centerZoom.zoom + 1;
if (zoom < zoomButtonsOpts.minZoom) {
zoom = zoomButtonsOpts.minZoom as double;
} else {
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
if (zoom > zoomButtonsOpts.maxZoom) {
zoom = zoomButtonsOpts.maxZoom;
}
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
},
child: Icon(zoomButtonsOpts.zoomInIcon,
color: zoomButtonsOpts.zoomInColorIcon ??
Expand All @@ -101,12 +100,11 @@ class ZoomButtons extends StatelessWidget {
var bounds = map.getBounds();
var centerZoom = map.getBoundsCenterZoom(bounds, options);
var zoom = centerZoom.zoom - 1;
if (zoom > zoomButtonsOpts.maxZoom) {
zoom = zoomButtonsOpts.maxZoom as double;
} else {
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
if (zoom < zoomButtonsOpts.minZoom) {
zoom = zoomButtonsOpts.minZoom;
}
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
},
child: Icon(zoomButtonsOpts.zoomOutIcon,
color: zoomButtonsOpts.zoomOutColorIcon ??
Expand Down

0 comments on commit bb0b9c5

Please sign in to comment.