zoom method
void
zoom(
- List<LatLng> points, {
- bool? hasCurrentLocation,
})
override
Implementation
@override
void zoom(List<LatLng> points, {bool? hasCurrentLocation}) {
LatLngBounds? bound = MapsUtils.calculateBounds(points);
if (bound != null) {
CameraUpdate cameraUpdate;
// if we only have 1 marker (also apply to just the current location),
// simply move the camera with a reasonable zoom, as the LatLngBound
// otherwise may zoom in all the way.
if (points.length == 1) {
cameraUpdate = CameraUpdate.newCameraPosition(CameraPosition(
target: LatLng(points[0].latitude, points[0].longitude),
zoom: widget.controller.initialCameraZoom?.toDouble() ??
widget.controller.defaultCameraZoom));
}
// otherwise bound the markers and add some reasonable padding
else {
cameraUpdate = CameraUpdate.newLatLngBounds(
bound, widget.controller.autoZoomPadding?.toDouble() ?? 50);
}
_controller.future
.then((controller) => controller.animateCamera(cameraUpdate));
}
}