I want to be able to update the region displayed on a MKMapView by allowing the user to type in an address or location in a UIAlertView. I currently have:
You could just set it equal to latitudeDelta
and the map view will adjust as needed.
But you don't need to calculate the span yourself in the first place. You can use:
region = MKCoordinateRegionMakeWithDistance(
placemark.region.center,
placemark.region.radius,
placemark.region.radius);
Not sure about the second part of your question.
region
returned by the CLPlacemark
is actually a CLCircularRegion
(see Deprecated CLRegion methods - how to get radius?).
Although the original code will still work as-is, you may get a compiler warning that radius
and center
are deprecated.
To avoid the warning, cast the region
as a CLCircularRegion
:
CLCircularRegion *pmCircularRegion = (CLCircularRegion *)placemark.region;
region = MKCoordinateRegionMakeWithDistance(
pmCircularRegion.center,
pmCircularRegion.radius,
pmCircularRegion.radius);