# iphone — convert MKMapPoint distances to meters

Say I have a square which consists of four CLLocationCoordinate2D points, which are in lat, lon, and I want to find the area of the square in meters. I convert the CLLocationCoordinate2D points into MKMapPoints, and I find the area in X-Y space. However, the area I find is in the units of MKMapPoint, which don’t directly translate to meters. How can I translate this area in MKMapPoint-space back into meters?

• Accelerometer Low Pass Filtering
• UICollectionView align logic missing in horizontal paging scrollview
• Save UIImage, Load it in Wrong Orientation
• Getting detected data from the UITextView
• File transfer from Browser to locally connected iPhone
• Xcode Dynamically loaded GUI for all views
• ### 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!