1

I m trying to execute url query but have no results about duration in traffic.

https://maps.googleapis.com/maps/api/distancematrix/json?origins=garching&destinations=hamburg&departure_time=now&api_key=my_api_key

The results of query listed below:

{
   "destination_addresses" : [ "Гамбург, Германия" ],  
   "origin_addresses" : [ "85748 Гархинг, Германия" ],  
   "rows" : [  
      {  
         "elements" : [  
            {  
               "distance" : {  
                  "text" : "761 км",  
                  "value" : 761011  
               },  
               "duration" : {  
                  "text" : "7 ч. 17 мин.",  
                  "value" : 26216  
               },  
               "status" : "OK"  
            }  
         ]  
      }
   ],  
   "status" : "OK"  
}

The result does not contain duration_in_traffic. Why?

Himanshu Mishra
  • 8,510
  • 12
  • 37
  • 74

1 Answers1

1

The duration_in_traffic result is only returned where traffic data is available, when a departure_time is specified.

https://developers.google.com/maps/documentation/javascript/distancematrix

It seems no traffic data is available for that destination/origin.

Seth
  • 96
  • 4
  • Seth, thanks for your answer. It seems to be true. But i saw in some googledocumentation pages, that its enough to get api key to use duration-IN-traffic (without premium plan). Apparently it was archaic pages. – Егор Колобов Dec 03 '17 at 07:21
  • Mind sharing those outdated pages? – Seth Dec 04 '17 at 19:04
  • ...The duration in traffic is returned only if all of the following are true: 1. The request includes a departure_time parameter. 2. The request includes a valid API key, **OR** a valid Google Maps APIs Premium Plan client ID and signature. 3. Traffic conditions are available for the requested route. 4. The mode parameter is set to driving. – Егор Колобов Dec 07 '17 at 09:11