Unlike the JavaScript Google Maps api, the MKMapView doesn't have a readily available "zoom level" property (it isn't really necessary for your purpose).
Work with the center and span values in the region property.
This question gives an example of how to save/load the region to NSUserDefaults.
(Revised Answer based on comment:)
If you mean you want the coordinates of the bounding rectangle for that circle overlay, use the overlay's boundingMapRect
property:
//"theCircle" is the MKCircle overlay object
CLLocationCoordinate2D topLeftCoord =
MKCoordinateForMapPoint(theCircle.boundingMapRect.origin);
MKMapPoint bottomRightMapPoint = MKMapPointMake (
MKMapRectGetMaxX(theCircle.boundingMapRect),
MKMapRectGetMaxY(theCircle.boundingMapRect));
CLLocationCoordinate2D bottomRightCoord =
MKCoordinateForMapPoint(bottomRightMapPoint);
(Original Answer:)
First, when you call setRegion
on the map view, the map view will almost always modify the region you requested so that it fits in the map view. This adjustment is based on the shape of the map view and whether it can show the requested span properly at one of its fixed zoom levels.
For example, if your map view is not square and you ask for a span of 10 miles in both directions, at least one of the spans is definitely going to be adjusted. Even if you ask for a span that you've set based on the proportions of the view, it could still get adjusted if the map view can't show the tiles at that zoom level (or perhaps if you've not taken the Earth's curvature into account).
Next, the latitudeDelta
and longitudeDelta
define the entire height and width of the region (not the distance from the center coordinate).
So your test in the screenshot cannot be compared with the span delta. In the screenshot, you are calculating the distance from the center coordinate to the minimum latitude and longitude (bottom-left corner) but the span deltas go all the way from right to left and bottom to top. (Because of that, you'd think that the distance from the center to a corner should be less than the delta--not more. It is shorter but the delta has also increased to more than 10 because of the reasons described above.)
Finally, to get the corner coordinates (bottom-left and top-right), this is probably a more accurate way to do it:
CLLocationCoordinate2D bottomLeftCoord =
[myMapView convertPoint:CGPointMake(0, myMapView.frame.size.height)
toCoordinateFromView:myMapView];
CLLocationCoordinate2D topRightCoord =
[myMapView convertPoint:CGPointMake(myMapView.frame.size.width, 0)
toCoordinateFromView:myMapView];
Best Answer
To add another implementation to the pile:
NB: There are many ways to convert between
MKMapRect
andMKCoordinateRegion
. This one certainly is not the exact inverse ofMKCoordinateRegionMakeWithDistance()
, but approximates it fairly well. So, be careful converting back and forth, because information can be lost.