toBoundsFromPoints static method

GMULatLngBounds toBoundsFromPoints(
  1. List<Point<num>> points
)

Convert a list of latitudes and longitudes to an object of boundaries

see: https://github.com/flutter/flutter/issues/36653#issuecomment-525288053

return The boundaries from the list of points

Implementation

static GMULatLngBounds toBoundsFromPoints(List<Point> points) {
  if (points.isEmpty) throw Exception("Points cannot be empty");

  double x0, x1, y0, y1;
  x0 = x1 = points.first.x.toDouble();
  y0 = y1 = points.first.y.toDouble();
  points.forEach((point) {
    if (point.x > x1) x1 = point.x.toDouble();
    if (point.x < x0) x0 = point.x.toDouble();
    if (point.y > y1) y1 = point.y.toDouble();
    if (point.y < y0) y0 = point.y.toDouble();
  });

  Point northEast = Point(x1, y1);
  Point southWest = Point(x0, y0);

  GMULatLngBounds gmuLatLngBounds = GMULatLngBounds(northEast, southWest);

  return gmuLatLngBounds;
}