Using these new traffic features is super simple—just add the departure_time parameter to Directions API or Distance Matrix API queries, and the results will contain the travel time estimate given the predicted traffic conditions at that time. The route returned may also change depending on traffic conditions, which lets developers recommend the fastest route to their users. For example, the image below shows the fastest route from San Francisco International Airport to the Google campus in Mountain View late at night when there’s no traffic (blue), and during peak hour when an accident on Highway 101 has slowed traffic to a crawl (red).
Since traffic conditions far in the future could vary greatly, developers can set an optional traffic_model parameter to choose whether they’d prefer to get an optimistic, pessimistic or best_guess estimate of the travel time. For example, one of our customers, Redfin, plan to use the Google Maps APIs to predict how long it will take to drive between homes, so they will use the pessimistic traffic model to ensure there’s enough travel time taking traffic into account. On the other hand, a developer building thermostat app wants their user’s house to be warm by the time they get home from work, so they would use the optimistic travel time estimate to calculate when their user is likely to get home, and when their thermostat needs to turn on.
The default traffic model, best_guess, returns the most likely travel time given everything that’s known about the traffic conditions—both the historical model for the queried time and day of the week, and the actual live traffic conditions right now. This can be used in apps that give drivers an indication of what their travel time will most likely be.
Posted by Elena Kelareva, Product Manager, Google Maps APIs