fromGeoPoints static method

BoundingBox fromGeoPoints(
  1. List<GeoPoint> geoPoints
)

Implementation

static BoundingBox fromGeoPoints(List<GeoPoint> geoPoints) {
  if (geoPoints.isEmpty) {
    throw Exception("list of geopint shouldn't be empty");
  }
  double maxLat = -86.0;
  double maxLon = -180.0;
  double minLat = 86.0;
  double minLon = 180.0;
  for (final gp in geoPoints) {
    final lat = gp.latitude;
    final lng = gp.longitude;
    maxLat = max(maxLat, lat);
    maxLon = max(maxLon, lng);
    minLat = min(minLat, lat);
    minLon = min(minLon, lng);
  }
  return BoundingBox(
    north: maxLat,
    east: maxLon,
    south: minLat,
    west: minLon,
  );
}