geoPointAsRect function

List<GeoPoint> geoPointAsRect({
  1. required GeoPoint center,
  2. required double lengthInMeters,
  3. required double widthInMeters,
})

geoPointAsRect

this method will calculate the bounds from center using lengthInMeters and widthInMeters this method usefull to get Rect or bounds

return List of GeoPoint

Implementation

List<GeoPoint> geoPointAsRect({
  required GeoPoint center,
  required double lengthInMeters,
  required double widthInMeters,
}) {
  final List<GeoPoint> bounds = <GeoPoint>[];
  GeoPoint east = center.destinationPoint(
    distanceInMeters: lengthInMeters * 0.5,
    bearingInDegrees: 90,
  );
  GeoPoint south = center.destinationPoint(
    distanceInMeters: widthInMeters * 0.5,
    bearingInDegrees: 180,
  );
  double westLon = center.longitude * 2 - east.longitude;
  double northLat = center.latitude * 2 - south.latitude;
  bounds.add(GeoPoint(latitude: south.latitude, longitude: east.longitude));
  bounds.add(GeoPoint(latitude: south.latitude, longitude: westLon));
  bounds.add(GeoPoint(latitude: northLat, longitude: westLon));
  bounds.add(GeoPoint(latitude: northLat, longitude: east.longitude));
  return bounds;
}