GeoPolygon.rectangle constructor

GeoPolygon.rectangle({
  1. required double north,
  2. required double south,
  3. required double east,
  4. required double west,
})

Creates a rectangular polygon from bounding coordinates.

north - Northern latitude boundary south - Southern latitude boundary east - Eastern longitude boundary west - Western longitude boundary

Example:

final rect = GeoPolygon.rectangle(
  north: 37.78,
  south: 37.76,
  east: -122.40,
  west: -122.42,
);

Implementation

factory GeoPolygon.rectangle({
  required double north,
  required double south,
  required double east,
  required double west,
}) {
  return GeoPolygon(
    points: [
      GeoPoint(latitude: north, longitude: west),
      GeoPoint(latitude: north, longitude: east),
      GeoPoint(latitude: south, longitude: east),
      GeoPoint(latitude: south, longitude: west),
    ],
  );
}