Reputation: 3622
I am fetching distance between 2 locations:
CLLocation
: Distance = 0.83 KM (Approx) (Not Correct)Location coordinates are:
Current Location: 19.0174941,72.8557548 Destination Location: 19.0205907,72.8540556
Below is the code which I am using to calculate the distance:
CLLocation *destination = [[CLLocation alloc] initWithLatitude:[latitude doubleValue] longitude:[longitude doubleValue]];
CLLocationDistance distance = [destination distanceFromLocation:currentLocation]/1000.0;
I am not able to understand why there is such a difference in both approaches. Can anyone guide me how can I get same distance from both ways.
Upvotes: 0
Views: 157
Reputation: 16318
Google map with Google SDK gives you actual road distance, while CLLocation gives you distance between 2 co-ordinates considering it a straight line. So there this this difference.
Please check apple docs here.
This method measures the distance between the two locations by tracing a line between them that follows the curvature of the Earth. The resulting arc is a smooth curve and does not take into account specific altitude changes between the two locations.
Upvotes: 0