toBounds static method

GoogleMapsUtilsLatLngBounds toBounds(
  1. double x,
  2. double y,
  3. double radiusInMeters
)

Creates a bounding box centered at (x, y) with a given radiusInMeters.

See: https://stackoverflow.com/a/31029389/3182210

Implementation

static GoogleMapsUtilsLatLngBounds toBounds(
    double x, double y, double radiusInMeters) {
  final center = Point<double>(x, y);
  final distanceFromCenterToCorner = radiusInMeters * sqrt(2.0);
  final southwestCorner =
      SphericalUtils.computeOffset(center, distanceFromCenterToCorner, 225.0);
  final northeastCorner =
      SphericalUtils.computeOffset(center, distanceFromCenterToCorner, 45.0);
  return GoogleMapsUtilsLatLngBounds(
    northEast: northeastCorner,
    southWest: southwestCorner,
  );
}