Reputation: 611
I have an app that uses Google Maps and I want to get the travel time between my current location and another location. How will I do that? Thanks in advance.
Upvotes: 2
Views: 4813
Reputation: 1066
You can use CLLocation to calculate the distance between two locations. Something like,
CLLocationDistance meters = [newLocation distanceFromLocation:oldLocation];
Once you calculated the distance, then you can easily calculate the travel time by using the speed distance time formula
i.e., speed = distance / time
since you know the distance and if you assume the speed, you can calculate time taken for the travel as
time = distance / speed
Checkout this link to use Google Maps API to calculate the time travel.
Upvotes: 3