fitCameraToGeojsonList static method
Future<void>
fitCameraToGeojsonList({
- required List<
GeoJsonDTO> geojsons, - required MapController mapController,
- EdgeInsets? padding,
- LazyloadMapLayer? mapLazyloader,
- dynamic onEnd()?,
Implementation
static Future<void> fitCameraToGeojsonList({
required List<GeoJsonDTO> geojsons,
required MapController mapController,
EdgeInsets? padding,
LazyloadMapLayer? mapLazyloader,
Function()? onEnd,
}) async {
if (geojsons.isEmpty == true) return; //secure
List<LatLng> coords = [];
for (GeoJsonDTO geojson in geojsons) {
if (geojson.geom.polygons != null) {
for(var p in geojson.geom.polygons!) {
coords.addAll(p.outerPoints);
}
}
}
if (coords.isEmpty == true) return; //secure
CameraFit fit = CameraFit.coordinates(
coordinates: coords,
padding: padding ?? EdgeInsets.all(__defaultPadding),
);
if(mapLazyloader != null) mapLazyloader.clearLastRefreshedBounds();
mapController.fitCamera(fit);
if(onEnd != null) onEnd();
}