0

My requirement is to find the distance in miles between two locations without using the Google API. I added code as:

CLLocation* first = [[CLLocation alloc] initWithLatitude:35.779702 longitude:-78.641746];
CLLocation* second = [[CLLocation alloc] initWithLatitude:40.723779 longitude:-73.991289];

CLLocationDistance distance = [first distanceFromLocation:second];
NSLog(@"distance  in Miles ::%f",distance*0.00062137);

It is giving distance as 424.151386 but when I check in iPad it is giving 497 miles.

Please give me solution for this difference.

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
rani
  • 593
  • 3
  • 10
  • 28
  • How are you checking it on the iPad? – Saxon Druce Jun 22 '13 at 11:04
  • We have default Maps app on iPad,using that I checked – rani Jun 22 '13 at 12:16
  • Does the maps app allow you to type in lat/lon coordinates and measure the distance? Or are you looking up driving directions in the maps app, which follows the roads? The calculation you're doing in the above code is the distance in a straight line, not the travel distance by road. – Saxon Druce Jun 22 '13 at 12:53
  • Maybe it's missing the earth radius calculation? Some info here: http://stackoverflow.com/questions/1502590/calculate-distance-between-two-points-in-google-maps-v3 – Migore Nov 25 '15 at 12:22

0 Answers0