Nate
Nate

Reputation: 7856

Google Maps API duration for specific route

I'm writing an iOS application and need to get the duration time for a specific route (latitude, longitude points), how can I do that?

Thanks

Upvotes: 1

Views: 2082

Answers (2)

Nate
Nate

Reputation: 7856

I finally found this: http://code.google.com/apis/maps/documentation/distancematrix/

Thanks to Jiri for his help!

Upvotes: 0

Jiri Kriz
Jiri Kriz

Reputation: 9292

There are various methods to calculate the distance between two points given by lat/lng. The simplest is to use the functions provided by the spherical namespace of Google Maps API v3:

computeDistanceBetween(from:LatLng, to:LatLng)

There is even a method to compute the length of a path:

computeLength(path:Array.<LatLng>|MVCArray.<LatLng>)

To use these methods you would need to initialize Maps as follows:

<script type="text/javascript"
        src="http://maps.googleapis.com/maps/api/jslibraries=geometry&sensor=false"> 
</script>

And if you know the distance and the velocity, you can compute the time.

Upvotes: 2

Related Questions