setFromCenterAndRadii method

void setFromCenterAndRadii({
  1. required Coordinates coords,
  2. required double horizRadius,
  3. required double vertRadius,
})

Sets rectangle coordinates using a center point and horizontal/vertical radii.

Configures this rectangle by specifying a center coordinate and distances in meters extending horizontally and vertically from that center. The method calculates the appropriate corner coordinates to create a rectangle with the specified dimensions.

Parameters

  • coords: The center Coordinates of the desired rectangle.
  • horizRadius: Horizontal radius in meters (east-west extent from center).
  • vertRadius: Vertical radius in meters (north-south extent from center).

Implementation

void setFromCenterAndRadii({
  required Coordinates coords,
  required double horizRadius,
  required double vertRadius,
}) {
  topLeft = coords.copyWithMetersOffset(
    metersLatitude: vertRadius.toInt(),
    metersLongitude: -horizRadius.toInt(),
  );
  bottomRight = coords.copyWithMetersOffset(
    metersLatitude: -vertRadius.toInt(),
    metersLongitude: horizRadius.toInt(),
  );
}