2

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.

Peppo
  • 1,107
  • 1
  • 12
  • 19
thedansaps
  • 611
  • 3
  • 10
  • 18

1 Answers1

3

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.

Community
  • 1
  • 1
PK20
  • 1,066
  • 8
  • 19
  • Is there something I can use in Google Maps API that will automatically calculate the travel time? – thedansaps Nov 25 '15 at 07:25
  • check out this [link](http://stackoverflow.com/questions/1042885/using-google-maps-api-to-get-travel-time-data) – PK20 Nov 25 '15 at 07:30