toBoundsFromPoints static method
Computes the smallest bounding box that contains all points.
Throws if points is empty.
See: https://github.com/flutter/flutter/issues/36653#issuecomment-525288053
Implementation
static GoogleMapsUtilsLatLngBounds toBoundsFromPoints(
List<Point<double>> points) {
if (points.isEmpty) throw ArgumentError('Points cannot be empty');
double x0 = points.first.x;
double x1 = points.first.x;
double y0 = points.first.y;
double y1 = points.first.y;
for (final point in points) {
if (point.x > x1) x1 = point.x;
if (point.x < x0) x0 = point.x;
if (point.y > y1) y1 = point.y;
if (point.y < y0) y0 = point.y;
}
return GoogleMapsUtilsLatLngBounds(
northEast: Point<double>(x1, y1),
southWest: Point<double>(x0, y0),
);
}