Reputation: 79
One question for google api route
I wanted to know if it is possible to make a request to the google just getting the timing and duration of the full path without receiving each of the intermediate steps
thanks
http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 45.51014580,
"lng" : -73.55252489999999
},
"southwest" : {
"lat" : 43.65331030,
"lng" : -79.38373319999999
}
},
"copyrights" : "Datos de mapa ©2013 Google",
"legs" : [
{
"distance" : {
"text" : "542 km",
"value" : 542385
},
"duration" : {
"text" : "5h 14 min",
"value" : 18834
},
"end_address" : "Montreal, Quebec, Canadá",
"end_location" : {
"lat" : 45.50857120,
"lng" : -73.55376740
},
"start_address" : "Toronto, Ontario, Canadá",
"start_location" : {
"lat" : 43.65331030,
"lng" : -79.38276750
},
Upvotes: 1
Views: 771
Reputation: 18058
(Note the parameters: origins and destinations (plural form, unlike the directions api)
{
"destination_addresses" : [ "Montreal, QC, Canada" ],
"origin_addresses" : [ "Toronto, ON, Canada" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "542 km",
"value" : 542384
},
"duration" : {
"text" : "5 hours 14 mins",
"value" : 18835
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
Upvotes: 0
Reputation: 161404
Use the DistanceMatrix API
The Google Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. The information returned is based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing duration and distance values for each pair.
Upvotes: 1