running this code:
NSLog(@"%f", MKMetersBetweenMapPoints(MKMapPointMake(33.6523, -118.507), MKMapPointMake(34.516, -117.628)));
returns this:
0.015819
When the expected output should be ~136900. What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like you’re giving a regular latitude and longitude to
MKMapPointMake(). AnMKMapPointcontains andxandyvalue, not latitude and longitude.Use
MKMapPointForCoordinate(myLocation)to convert your locations to map points, then give those to yourMKMetersBetweenMapPoints()function.Or easier still, use
-distanceFromLocation:with twoCLLocationobjects. It gives you back a distance in meters, taking into account the curvature of the earth.