zoomToFit method

void zoomToFit()

zoom to fit all markers. If location is enabled and includeLocationInAutoZoom is true, then also fit the location in the bound.

Implementation

void zoomToFit() {
  List<LatLng> points = [];

  // add user location
  LocationData? currentLocation = getCurrentLocation();
  if (currentLocation != null &&
      widget.controller.includeCurrentLocationInAutoZoom) {
    points.add(LatLng(currentLocation.latitude, currentLocation.longitude));
  }

  for (var payload in getMarkerPayloads()) {
    points.add(payload.latLng);
  }

  zoom(points, hasCurrentLocation: currentLocation != null);
}