fitCameraToGeojson method
Future<void>
fitCameraToGeojson({
- required GeoJsonDTO geojson,
- required MapController mapController,
- EdgeInsets? padding,
- LazyloadMapLayer? mapLazyloader,
- dynamic onEnd()?,
Implementation
Future<void> fitCameraToGeojson({
required GeoJsonDTO geojson,
required MapController mapController,
EdgeInsets? padding,
LazyloadMapLayer? mapLazyloader,
Function()? onEnd,
}) async {
if (geojson.geom.polygons?.isEmpty == true) {
return; //does nothing if there are no polygons
}
List<LatLng> coords = [];
for (GeomPolygon g in geojson.geom.polygons!) {
coords.addAll(g.outerPoints);
}
CameraFit fit = CameraFit.coordinates(
coordinates: coords,
padding: const EdgeInsets.all(40),
);
if(mapLazyloader != null) mapLazyloader.clearLastRefreshedBounds();
mapController.fitCamera(fit);
if(onEnd != null) onEnd();
}