1

Depending on the congestion severity, Google Maps color codes the travel time/duration with Red, Amber or Green as seen below.

Google Maps congestion color coding

How do I get these colors when I query Google Maps API?

In the sample responses presented below, I don't see any congestion/color information.
https://developers.google.com/maps/documentation/directions/

Any advice?

stackoverflow
  • 399
  • 2
  • 14
  • 1
    This is not available through the API. The best you could do, I suppose, is to compare the values of `duration` with `duration_in_traffic`, but this is only available under certain conditions, and if you have a Premium API plan. [Read more here](https://developers.google.com/maps/documentation/javascript/directions#Legs). – MrUpsidown Mar 03 '18 at 10:02
  • 1
    @MrUpsidown the Premium plan is not mandatory to get duration_in_traffic value. [Documentation](https://developers.google.com/maps/documentation/directions/intro#DirectionsResponses) says `The duration in traffic is returned only if all of the following are true: - The request includes a valid API key, or a valid Google Maps APIs Premium Plan client ID and signature`... So, if you apply a valid API key for Standard plan and all other conditions are true, you will get duration in traffic as well. – xomena Mar 03 '18 at 13:19
  • @stackoverflow Have a look at this feature request https://issuetracker.google.com/issues/36537583. It seems to be relevant for your task. – xomena Mar 03 '18 at 13:21
  • @xomena True. I read this too quick. – MrUpsidown Mar 03 '18 at 13:57

0 Answers0