iOS how to calculate size width to meters in every region(any location and any zoom)

ios, mkmapview

Solution

You can find an elaborate explanation of the formula here: transform longitude latitude into meters.

Sample code:

CLLocationDegrees deltaLatitude = self.mapView.region.span.latitudeDelta;
CLLocationDegrees deltaLongitude = self.mapView.region.span.longitudeDelta;
CGFloat latitudeCircumference = 40075160 * cos(self.mapView.region.center.latitude * M_PI / 180);
NSLog(@"x: %f; y: %f", deltaLongitude * latitudeCircumference / 360, deltaLatitude * 40008000 / 360);

Credits to Mark Ransom

Problem

like the title, does any one know how to calculate size width to meters in every region, means in every where and any zoom. I found how to get the zoomScale. ``` CLLocationDegrees longitudeDelta = myMapView.region.span.longitudeDelta; CGFloat mapWidthInPixels = myMapView.bounds.size.width; double zoomScale = longitudeDelta * MERCATOR_RADIUS * M_PI / (180.0 * mapWidthInPixels); ``` But I don't know what does result mean, if I want to get the meters for size width or maybe a line 20f, I change the mapWidthInPixels to 20 does it right?

Original source

Related problems