iphone — convert MKMapPoint distances to meters

2 Solutions Collect From Internet About “iphone — convert MKMapPoint distances to meters”

The MapKit function MKMetersBetweenMapPoints makes this easier.

For example, if you wanted to get the area of the currently displayed region:

MKMapPoint mpTopLeft = mapView.visibleMapRect.origin;

MKMapPoint mpTopRight = MKMapPointMake(
    mapView.visibleMapRect.origin.x + mapView.visibleMapRect.size.width, 
    mapView.visibleMapRect.origin.y);

MKMapPoint mpBottomRight = MKMapPointMake(
    mapView.visibleMapRect.origin.x + mapView.visibleMapRect.size.width, 
    mapView.visibleMapRect.origin.y + mapView.visibleMapRect.size.height);

CLLocationDistance hDist = MKMetersBetweenMapPoints(mpTopLeft, mpTopRight);
CLLocationDistance vDist = MKMetersBetweenMapPoints(mpTopRight, mpBottomRight);

double vmrArea = hDist * vDist;

The documentation states that the function takes “into account the curvature of the Earth.”

You can use the Haversine formula to calculate it, assuming that the earth is a perfect sphere.

To understand how lat/lon vs meters works in the context of the earth, you may find it interesting to read about Nautical miles.

You can find some more resources and some sample code by googling objective-c Haversine formula.

Enjoy!