createBounds static method

LatLngBounds createBounds(
  1. LatLng southwest,
  2. LatLng northeast
)

Implementation

static LatLngBounds createBounds(LatLng southwest, LatLng northeast) {
  final points = [southwest, northeast];

  final highestLat = points.map((e) => e.latitude).reduce(max);
  final highestLong = points.map((e) => e.longitude).reduce(max);
  final lowestLat = points.map((e) => e.latitude).reduce(min);
  final lowestLong = points.map((e) => e.longitude).reduce(min);

  final lowestLatLowestLong = LatLng(lowestLat, lowestLong);
  final highestLatHighestLong = LatLng(highestLat, highestLong);

  return LatLngBounds(
      southwest: lowestLatLowestLong, northeast: highestLatHighestLong);
}