I know its a very common issue but I am not getting the exact answer for this thing.
How to make MKMapView defaults to a zoom of a 5 mile radius of current location.
Thanks in advance.
I know its a very common issue but I am not getting the exact answer for this thing.
How to make MKMapView defaults to a zoom of a 5 mile radius of current location.
Thanks in advance.
The parameters to
MKCoordinateSpanMake
are in degrees, and 1 degree is approx 69 miles at the equator. Thus MAP_SPAN would be 5.0/69.0Use the
MKCoordinateRegionMakeWithDistance
function from MapKit.Use a conversion function to convert miles to meters since MapKit uses meters.
Then in your code set the map region as (thanks to @DylanBettermann for pointing out that to get a radius of 5 miles, the distance needs to be doubled)
swift 4 version :
Use the following code when ever you want to zoom to 5 miles radius: