durationInTraffic property

DirectionsDuration? durationInTraffic
final

Indicates the total duration of this leg. This value is an estimate of the time in traffic based on current and historical traffic conditions. See the trafficModel request parameter for the options you can use to request that the returned value is optimistic, pessimistic, or a best-guess estimate. 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
  • Platform Premium Plan client ID and signature.
  • The request does not include stopover waypoints. If the request includes waypoints, they must be prefixed with via: to avoid stopovers.
  • The request is specifically for driving directions—the mode parameter is set to driving.
  • The request includes a departureTime parameter.
  • Traffic conditions are available for the requested route.

The durationInTraffic contains the following fields:

  • value indicates the duration in seconds.
  • text contains a human-readable representation of the duration.

Implementation

final DirectionsDuration? durationInTraffic;