Route

Encapsulates a route, which consists of a series of connected road segments that join beginning, ending, and intermediate waypoints.

JSON representation
{
  "legs": [
    {
      object (RouteLeg)
    }
  ],
  "distanceMeters": integer,
  "duration": string,
  "staticDuration": string,
  "polyline": {
    object (Polyline)
  },
  "description": string,
  "warnings": [
    string
  ],
  "viewport": {
    object (Viewport)
  },
  "travelAdvisory": {
    object (RouteTravelAdvisory)
  },
  "optimizedIntermediateWaypointIndex": [
    integer
  ]
}
Fields
legs[]

object (RouteLeg)

A collection of legs (path segments between waypoints) that make-up the route. Each leg corresponds to the trip between two non-via Waypoints. For example, a route with no intermediate waypoints has only one leg. A route that includes one non-via intermediate waypoint has two legs. A route that includes one via intermediate waypoint has one leg. The order of the legs matches the order of Waypoints from origin to intermediates to destination.

distanceMeters

integer

The travel distance of the route, in meters.

duration

string (Duration format)

The length of time needed to navigate the route. If you set the routingPreference to TRAFFIC_UNAWARE, then this value is the same as staticDuration. If you set the routingPreference to either TRAFFIC_AWARE or TRAFFIC_AWARE_OPTIMAL, then this value is calculated taking traffic conditions into account.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

staticDuration

string (Duration format)

The duration of traveling through the route without taking traffic conditions into consideration.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

polyline

object (Polyline)

The overall route polyline. This polyline will be the combined polyline of all legs.

description

string

A description of the route.

warnings[]

string

An array of warnings to show when displaying the route.

viewport

object (Viewport)

The viewport bounding box of the polyline.

travelAdvisory

object (RouteTravelAdvisory)

Additional information about the route.

optimizedIntermediateWaypointIndex[]

integer

If ComputeRoutesRequest.optimize_waypoint_order is set to true, this field contains the optimized ordering of intermediates waypoints. otherwise, this field is empty. For example, suppose the input is Origin: LA; Intermediates: Dallas, Bangor, Phoenix; Destination: New York; and the optimized intermediate waypoint order is: Phoenix, Dallas, Bangor. Then this field contains the values [2, 0, 1]. The index starts with 0 for the first intermediate waypoint.

RouteLeg

Encapsulates a segment between non-via waypoints.

JSON representation
{
  "distanceMeters": integer,
  "duration": string,
  "staticDuration": string,
  "polyline": {
    object (Polyline)
  },
  "startLocation": {
    object (Location)
  },
  "endLocation": {
    object (Location)
  },
  "steps": [
    {
      object (RouteLegStep)
    }
  ],
  "travelAdvisory": {
    object (RouteLegTravelAdvisory)
  }
}
Fields
distanceMeters

integer

The travel distance of the route leg, in meters.

duration

string (Duration format)

The length of time needed to navigate the leg. If the route_preference is set to TRAFFIC_UNAWARE, then this value is the same as staticDuration. If the route_preference is either TRAFFIC_AWARE or TRAFFIC_AWARE_OPTIMAL, then this value is calculated taking traffic conditions into account.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

staticDuration

string (Duration format)

The duration of traveling through the leg, calculated without taking traffic conditions into consideration.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

polyline

object (Polyline)

The overall polyline for this leg. This includes that each step's polyline.

startLocation

object (Location)

The start location of this leg. This might be different from the provided origin. For example, when the provided origin is not near a road, this is a point on the road.

endLocation

object (Location)

The end location of this leg. This might be different from the provided destination. For example, when the provided destination is not near a road, this is a point on the road.

steps[]

object (RouteLegStep)

An array of steps denoting segments within this leg. Each step represents one navigation instruction.

travelAdvisory

object (RouteLegTravelAdvisory)

Encapsulates the additional information that the user should be informed about, such as possible traffic zone restriction etc. on a route leg.

Polyline

Encapsulates an encoded polyline.

JSON representation
{

  // Union field polyline_type can be only one of the following:
  "encodedPolyline": string,
  "geoJsonLinestring": {
    object
  }
  // End of list of possible types for union field polyline_type.
}
Fields
Union field polyline_type. Encapsulates the type of polyline. Defaults to encoded_polyline. polyline_type can be only one of the following:
encodedPolyline

string

The string encoding of the polyline using the polyline encoding algorithm

geoJsonLinestring

object (Struct format)

Specifies a polyline using the GeoJSON LineString format

RouteLegStep

Encapsulates a segment of a RouteLeg. A step corresponds to a single navigation instruction. Route legs are made up of steps.

JSON representation
{
  "distanceMeters": integer,
  "staticDuration": string,
  "polyline": {
    object (Polyline)
  },
  "startLocation": {
    object (Location)
  },
  "endLocation": {
    object (Location)
  },
  "navigationInstruction": {
    object (NavigationInstruction)
  },
  "travelAdvisory": {
    object (RouteLegStepTravelAdvisory)
  }
}
Fields
distanceMeters

integer

The travel distance of this step, in meters. In some circumstances, this field might not have a value.

staticDuration

string (Duration format)

The duration of travel through this step without taking traffic conditions into consideration. In some circumstances, this field might not have a value.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

polyline

object (Polyline)

The polyline associated with this step.

startLocation

object (Location)

The start location of this step.

endLocation

object (Location)

The end location of this step.

navigationInstruction

object (NavigationInstruction)

Navigation instructions.

travelAdvisory

object (RouteLegStepTravelAdvisory)

Encapsulates the additional information that the user should be informed about, such as possible traffic zone restriction on a leg step.

RouteLegStepTravelAdvisory

Encapsulates the additional information that the user should be informed about, such as possible traffic zone restriction on a leg step.

JSON representation
{
  "speedReadingIntervals": [
    {
      object (SpeedReadingInterval)
    }
  ]
}
Fields
speedReadingIntervals[]

object (SpeedReadingInterval)

Speed reading intervals detailing traffic density. Applicable in case of TRAFFIC_AWARE and TRAFFIC_AWARE_OPTIMAL routing preferences. The intervals cover the entire polyline of the RouteLegStep without overlap. The start point of a specified interval is the same as the end point of the preceding interval.

Example:

polyline: A ---- B ---- C ---- D ---- E ---- F ---- G
speedReadingIntervals: [A,C), [C,D), [D,G).

RouteLegTravelAdvisory

Encapsulates the additional information that the user should be informed about, such as possible traffic zone restriction etc. on a route leg.

JSON representation
{
  "tollInfo": {
    object (TollInfo)
  },
  "speedReadingIntervals": [
    {
      object (SpeedReadingInterval)
    }
  ]
}
Fields
tollInfo

object (TollInfo)

Encapsulates information about tolls on the specific RouteLeg. This field is only populated if we expect there are tolls on the RouteLeg. If this field is set but the estimatedPrice subfield is not populated, we expect that road contains tolls but we do not know an estimated price. If this field does not exist, then there is no toll on the RouteLeg.

speedReadingIntervals[]

object (SpeedReadingInterval)

Speed reading intervals detailing traffic density. Applicable in case of TRAFFIC_AWARE and TRAFFIC_AWARE_OPTIMAL routing preferences. The intervals cover the entire polyline of the RouteLg without overlap. The start point of a specified interval is the same as the end point of the preceding interval.

Example:

polyline: A ---- B ---- C ---- D ---- E ---- F ---- G
speedReadingIntervals: [A,C), [C,D), [D,G).