trafficModel property

TrafficModel? trafficModel
final

Specifies the assumptions to use when calculating time in traffic. This setting affects the value returned in the durationInTraffic field in the response, which contains the predicted time in traffic based on historical averages. The trafficModel parameter may only be specified for driving directions where the request includes a departureTime.

Defaults to bestGuess.

The available values for this parameter are:

  • bestGuess (default) indicates that the returned durationInTraffic should be the best estimate of travel time given what is known about both historical traffic conditions and live traffic. Live traffic becomes more important the closer the departureTime is to now.
  • pessimistic indicates that the returned durationInTraffic should be longer than the actual travel time on most days, though occasional days with particularly bad traffic conditions may exceedthis value.
  • optimistic indicates that the returned durationInTraffic should be shorter than the actual travel time on most days, though occasional days with particularly good traffic conditions may be faster than this value.

The default value of bestGuess will give the most useful predictions for the vast majority of use cases. It is possible the bestGuess travel time prediction may be shorter than optimistic, or alternatively, longer than pessimistic, due to the way the bestGuess prediction model integrates live traffic information.

Implementation

final TrafficModel? trafficModel;