# Route

- [JSON representation](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#SCHEMA_REPRESENTATION)
- [RouteLeg](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLeg)
  - [JSON representation](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLeg.SCHEMA_REPRESENTATION)
- [Polyline](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#Polyline)
  - [JSON representation](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#Polyline.SCHEMA_REPRESENTATION)
- [RouteLegStep](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegStep)
  - [JSON representation](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegStep.SCHEMA_REPRESENTATION)
- [NavigationInstruction](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#NavigationInstruction)
  - [JSON representation](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#NavigationInstruction.SCHEMA_REPRESENTATION)
- [RouteLegStepTravelAdvisory](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegStepTravelAdvisory)
  - [JSON representation](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegStepTravelAdvisory.SCHEMA_REPRESENTATION)
- [RouteLegTravelAdvisory](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegTravelAdvisory)
  - [JSON representation](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegTravelAdvisory.SCHEMA_REPRESENTATION)

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

| JSON representation |
|---|
| ``` { "legs": [ { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLeg`) } ], "distanceMeters": integer, "duration": string, "staticDuration": string, "polyline": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#Polyline`) }, "description": string, "warnings": [ string ], "viewport": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Viewport`) }, "travelAdvisory": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelAdvisory`) }, "optimizedIntermediateWaypointIndex": [ integer ] } ``` |

| Fields ||
|---|---|
| `legs[]` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#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 (`https://protobuf.dev/reference/protobuf/google.protobuf#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 (`https://protobuf.dev/reference/protobuf/google.protobuf#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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#Polyline`)`` The overall route polyline. This polyline is 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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Viewport`)`` The viewport bounding box of the polyline. |
| `travelAdvisory` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#Polyline`) }, "startLocation": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Location`) }, "endLocation": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Location`) }, "steps": [ { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegStep`) } ], "travelAdvisory": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegTravelAdvisory`) } } ``` |

| Fields ||
|---|---|
| `distanceMeters` | `integer` The travel distance of the route leg, in meters. |
| `duration` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#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 (`https://protobuf.dev/reference/protobuf/google.protobuf#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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#Polyline`)`` The overall polyline for this leg. This includes that each `step`'s polyline. |
| `startLocation` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegStep`)`` An array of steps denoting segments within this leg. Each step represents one navigation instruction. |
| `travelAdvisory` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#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](https://developers.google.com/maps/documentation/utilities/polylinealgorithm). |
| `geoJsonLinestring` | ``object (`https://protobuf.dev/reference/protobuf/google.protobuf#struct` format)`` Specifies a polyline using the [GeoJSON LineString format](https://tools.ietf.org/html/rfc7946#section-3.1.4). |

## 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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#Polyline`) }, "startLocation": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Location`) }, "endLocation": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Location`) }, "navigationInstruction": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#NavigationInstruction`) }, "travelAdvisory": { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegStepTravelAdvisory`) } } ``` |

| Fields ||
|---|---|
| `distanceMeters` | `integer` The travel distance of this step, in meters. In some circumstances, this field might not have a value. |
| `staticDuration` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#Polyline`)`` The polyline associated with this step. |
| `startLocation` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Location`)`` The start location of this step. |
| `endLocation` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Location`)`` The end location of this step. |
| `navigationInstruction` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#NavigationInstruction`)`` Navigation instructions. |
| `travelAdvisory` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Route#RouteLegStepTravelAdvisory`)`` Encapsulates the additional information that the user should be informed about, such as possible traffic zone restriction on a leg step. |

## NavigationInstruction

| JSON representation |
|---|
| ``` { "maneuver": enum (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Maneuver`), "instructions": string } ``` |

| Fields ||
|---|---|
| `maneuver` | ``enum (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Maneuver`)`` Encapsulates the navigation instructions for the current step (for example, turn left, merge, or straight). This field determines which icon to display. |
| `instructions` | `string` Instructions for navigating this 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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/SpeedReadingInterval`) } ] } ``` |

| Fields ||
|---|---|
| `speedReadingIntervals[]` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/SpeedReadingInterval`)`` NOTE: This field is not currently populated. |

## 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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/TollInfo`) }, "speedReadingIntervals": [ { object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/SpeedReadingInterval`) } ] } ``` |

| Fields ||
|---|---|
| `tollInfo` | ``object (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/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 (`https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/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 `RouteLeg` 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). |