Configure the Quality vs Latency Trade-off

The Routes Preferred API provides three routing preferences for calculating routes. They differ in the extent that they factor traffic conditions into the route calculation. Each routing preference produces results that differ to a degree in regard to route quality, estimated ETA, and response latency.

About traffic conditions

Traffic conditions characterize the rate of traffic flow. For example:

  • When there is no congestion, traffic conditions are considered normal, and traffic flows at the regular unimpeded speed.

  • Approaching rush-hour, traffic density increases, which causes traffic to slow down, producing light to moderate traffic conditions.

  • In bumper-to-bumper traffic, the flow-rate grinds to a halt, producing heavy traffic conditions.

Traffic unaware

When you set the TRAFFIC_UNAWARE routing preference, routes are calculated without accounting for traffic conditions. This routing preference provides the lowest response latency (responses are returned the quickest).

Use this routing preference when you want responses returned the quickest, and approximate routing details are good enough.

Traffic aware

When you set the TRAFFIC_AWARE routing preference, routes are calculated accounting for traffic conditions. As a result, the route and route details more accurately reflect real-world conditions. Since this increase in data quality comes at the expense of response latency, performance optimizations are applied to reduce much of the latency.

Use this routing preference when you want more accurate routing details, and yet you don't mind if responses are returned with a moderate increase in latency.

Traffic aware optimal

When you set the TRAFFIC_AWARE_OPTIMAL routing preference, routes are calculated accounting for traffic conditions, but no performance optimizations are applied. In this mode, the server performs a more exhaustive search of the road network to find the optimal route.

This routing preference provides the highest response latency (i.e., responses return with the longest delay). Use this routing preference when you want results of the highest quality, without regard to how long responses take.

Example

The following JSON code demonstrates how to set the routing preference in a request message entity body.

{
  "origin":{
    "location":{
      "latLng":{
        "latitude":37.419734,
        "longitude":-122.0827784
      }
    }
  },
  "destination":{
    "location":{
      "latLng":{
        "latitude":37.417670,
        "longitude":-122.079595
      }
    }
  },
  "travelMode":"DRIVE",
  "routingPreference":"TRAFFIC_AWARE_OPTIMAL"
}