I'm looking for a method to convert meters to a mapview region.
CLLocation
's horizontalAccuracy
is a double, representing the accuracy in meters. regionThatFits:
takes an MKCoordinateRegion
which has a span
with longitudeDelta
and latitudeDelta
. How can I convert meters to a longitude/latitude span?
Found an answer. It seems that 1 degree of latitude is equal to around 111 kilometers, or 111120 meters
- (MKCoordinateRegion)regionForAccuracyOfLocation:(CLLocation *)location
{
CLLocationDegrees spanInDegrees = (CLLocationDegrees) (location.horizontalAccuracy / 222240);
MKCoordinateSpan span = MKCoordinateSpanMake(spanInDegrees, spanInDegrees) ;
CLLocationCoordinate2D coordinate = location.coordinate;
MKCoordinateRegion region = MKCoordinateRegionMake(coordinate, span);
return region;
}