MapRectangle.from constructor

MapRectangle.from(
  1. List<Mappoint> mp1
)

Creates a new MapRectangle that encloses all the given points.

Implementation

factory MapRectangle.from(List<Mappoint> mp1) {
  assert(mp1.isNotEmpty);
  double bottom = -1;
  double left = double.maxFinite;
  double right = -1;
  double top = double.maxFinite;
  for (var element in mp1) {
    if (left > element.x) left = element.x;
    if (top > element.y) top = element.y;
    if (right < element.x) right = element.x;
    if (bottom < element.y) bottom = element.y;
  }
  return MapRectangle(left, top, right, bottom);
}