toCoordinateRegion()
Returns the region that corresponds to a map rectangle.
Declaration
toCoordinateRegion(): CoordinateRegion;Return Value
A CoordinateRegion object that corresponds to a map rectangle.
Discussion
It’s often easier to work with a map rectangle than a CoordinateRegion.
The following example demonstrates how to convert a MapRect instance to a CoordinateRegion and back again:
const mapRect = new mapkit.MapRect(0.1, 0.2, 0.3, 0.4);
// Return a coordinate region with center (33.841220320476786, -90) and span (106.57400641480324, 108).
const coordinateRegion = mapRect.toCoordinateRegion();
// Return the same map rectangle as mapRect, plus or minus any floating point inaccuracies.
const newMapRect = coordinateRegion.toMapRect();