How to calculate the distance between two location points?

Asked

Viewed 914 times

2

I need to calculate the shortest distance between two locations obtained automatically through the CoreLocation.

To be more specific, the idea is to mark a starting point and after the user "walk" a little, I need to calculate the distance traveled when arriving in another place

1 answer

2


From two objects on Cllocation you get the distance, in meters, through the method distanceFromLocation. Example:

CLLocationDistance distance = [location1 distanceFromLocation:location2];
  • Interesting. I’ll test this at night. Just a question, this distance is calculated based on what? Straight line? Routes?

  • In most cases it is practically a straight line. The method considers only the curvature of the earth. For nearby points this will not make a difference. The documentation reads: "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."

  • worked. Thank you so much for your help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.