LatLngBounds.fromPoints constructor

LatLngBounds.fromPoints(
  1. List<LatLng> points
)

Implementation

LatLngBounds.fromPoints(List<LatLng> points) {
  if (points.isNotEmpty) {
    num? minX;
    num? maxX;
    num? minY;
    num? maxY;

    for (var point in points) {
      num x = point.longitudeInRad;
      num y = point.latitudeInRad;

      if (minX == null || minX > x) {
        minX = x;
      }

      if (minY == null || minY > y) {
        minY = y;
      }

      if (maxX == null || maxX < x) {
        maxX = x;
      }

      if (maxY == null || maxY < y) {
        maxY = y;
      }
    }

    _sw = LatLng(radianToDeg(minY as double), radianToDeg(minX as double));
    _ne = LatLng(radianToDeg(maxY as double), radianToDeg(maxX as double));
  }
}