<iframe src="https://developers.devsite.google/frame/maps/documentation/javascript/reference/route_6950a1ed8465fddba17fddf962c35fb4b09a88c8fc62056bb883f9b5f0d19700.frame" class="framebox inherit-locale redirect-iframe" allow="clipboard-write https://developers.devsite.google" allowfullscreen is-upgraded></iframe>

## [Route](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route)
class


class
`google.maps.routes.Route`

library `"routes"`

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

```javascript
const {Route} = await google.maps.importLibrary("routes");
```

| ### Static Methods ||
|---|---|
| `computeRoutes` | `computeRoutes(request)` **Parameters:** - `request: ComputeRoutesRequest` **Return Value:** `Promise<{ routes:Array<Route> optional, fallbackInfo:FallbackInfo optional, geocodingResults:GeocodingResults optional }>` Returns the primary route along with optional alternate routes, given a set of terminal and intermediate waypoints. Note: This method requires that you specify a response field mask in the request by setting the `ComputeRoutesRequest.fields` property. The value is a list of field paths. For example: - Field mask of all available fields: `fields: ['*']` - Field mask of Route-level duration, distance, and path: `fields: ['durationMillis', 'distanceMeters', 'path']` <br /> Use of the wildcard response field mask `fields: ['*']` is discouraged because: - Selecting only the fields that you need helps our server save computation cycles, allowing us to return the result to you with a lower latency. - Selecting only the fields that you need in your production job ensures stable latency performance. We might add more response fields in the future, and those new fields might require extra computation time. If you select all fields, or if you select all fields at the top level, then you might experience performance degradation because any new field we add will be automatically included in the response. - Selecting only the fields that you need results in a smaller response size, and thus a faster load over the network. |

| ### Properties ||
|---|---|
| `description` readonly | **Type:** `string optional` A description of the route. |
| `distanceMeters` readonly | **Type:** `number optional` The travel distance of the route, in meters. |
| `durationMillis` readonly | **Type:** `number optional` The length of time needed to navigate the route in milliseconds. If you set `ComputeRoutesRequest.routingPreference` to `TRAFFIC_UNAWARE`, then this value is the same as `Route.staticDurationMillis`. If you set `ComputeRoutesRequest.routingPreference` to either `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL`, then this value is calculated taking traffic conditions into account. Note: If the duration exceeds 2\^53 milliseconds, then this value is `Number.POSITIVE_INFINITY`. |
| `legs` readonly | **Type:** `Array<RouteLeg> optional` 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`. |
| `localizedValues` readonly | **Type:** `RouteLocalizedValues optional` Text representations of properties of the `Route`. |
| `optimizedIntermediateWaypointIndices` readonly | **Type:** `Array<number> optional` If you set `ComputeRoutesRequest.optimizeWaypointOrder` to `true`, this field contains the optimized ordering of intermediate waypoints. Otherwise, this field is empty. The index starts with 0 for the first intermediate waypoint provided in the input. For example, if you give an input of: - Origin: LA - Intermediate waypoints: Dallas, Bangor, Phoenix - Destination: New York and the optimized intermediate waypoint order is Phoenix, Dallas, Bangor, then this field will be `[2, 0, 1]`. |
| `path` readonly | **Type:** `Array<LatLngAltitude> optional` The list of `LatLngAltitude`s of the route, which can be used to draw a route polyline. Granularity of the path can be controlled by setting `ComputeRoutesRequest.polylineQuality`. |
| `polylineDetails` readonly | **Type:** `PolylineDetails optional` Contains information about details along the path. |
| `routeLabels` readonly | **Type:** `Array<RouteLabel> optional` Labels for the route that are useful to identify specific properties of to compare against others. |
| `routeToken` readonly | **Type:** `string optional` An opaque token that can be passed to Navigation SDK to reconstruct the route during navigation, and, in the event of rerouting, honor the original intention when the route was created. Treat this token as an opaque blob. Don't compare its value across requests as its value may change even if the service returns the exact same route. Note: `routeToken` is only available for requests that have set `ComputeRoutesRequest.routingPreference` to `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL`. It is not supported for requests that have `via` waypoints. |
| `speedPaths` readonly | **Type:** `Array<SpeedPath> optional` Groupings of sections of the route path with their corresponding speed reading. For this field to be populated, `ComputeRoutesRequest.routingPreference` must be set to `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL` and `ComputeRoutesRequest.extraComputations` must include `TRAFFIC_ON_POLYLINE`. |
| `staticDurationMillis` readonly | **Type:** `number optional` The duration of traveling through the route without taking traffic conditions into consideration. Note: If the duration exceeds 2\^53 milliseconds, then this value is `Number.POSITIVE_INFINITY`. |
| `travelAdvisory` readonly | **Type:** `RouteTravelAdvisory optional` Additional information about the route. |
| `viewport` readonly | **Type:** `LatLngBounds optional` The viewport bounding box of the route. |
| `warnings` readonly | **Type:** `Array<string> optional` An array of warnings to show when displaying the route. |

| ### Methods ||
|---|---|
| `![Alpha](data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24' viewBox='0 0 24 24' fill='%2301579b'%3E%3Cpath d='M5 21q-1.275 0-1.812-1.137-.538-1.138.262-2.113L9 11V5H8q-.425 0-.713-.288Q7 4.425 7 4t.287-.713Q7.575 3 8 3h8q.425 0 .712.287Q17 3.575 17 4t-.288.712Q16.425 5 16 5h-1v6l5.55 6.75q.8.975.262 2.113Q20.275 21 19 21Zm2-3h10l-3.4-4h-3.2Zm-2 1h14l-6-7.3V5h-2v6.7Zm7-7Z'/%3E%3C/svg%3E "Alpha")create3DPolylines` | **Notice:** Available only in the [v=alpha channel](https://developers.google.com/maps/documentation/javascript/versions.md.txt#choosing-the-alpha-channel). `create3DPolylines([options])` **Parameters:** - `options: RoutePolyline3DOptions optional` **Return Value:** `Promise<Array<Polyline3DElement>>` Creates 3D polylines for the route based on the data available for the route. |
| `createPolylines` | `createPolylines([options])` **Parameters:** - `options: RoutePolylineOptions optional` **Return Value:** `Array<Polyline>` Creates polylines for the route based on the data available. Multi-modal polylines: - Requirements: - The `"path"` and `"legs"` fields must be requested in `ComputeRoutesRequest.fields` - `ComputeRoutesRequest.travelMode` must be set to `TRANSIT`. - Creates a polyline for each multi-modal route segment. Polylines are styled according to the segment travel mode and transit line data when available. Options can be passed in to alter the polyline style based on travel mode and transit line. <br /> Traffic polylines: - Requirements: - The `"path"` and `"travelAdvisory"` fields (or just `"speedPaths"` as a shorthand) must be requested in `ComputeRoutesRequest.fields`. - `ComputeRoutesRequest.routingPreference` must be set to `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL`. - `ComputeRoutesRequest.extraComputations` must include `TRAFFIC_ON_POLYLINE`. - Creates a polyline for each route interval when the speed reading differs from the preceding interval. Polylines have default speed-based styling applied. Options can be passed in to alter the polyline style based on speed. <br /> Overall polyline: - Requirements: - The `"path"` or `"legs"` field must be requested in `ComputeRoutesRequest.fields`. - Creates a single polyline for the entire route with default styling applied. Options can be passed in to alter the polyline style based on the route travel mode. For further customization, create polylines directly using `Route.path` or `RouteLeg.path`. |
| `![Alpha](data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24' viewBox='0 0 24 24' fill='%2301579b'%3E%3Cpath d='M5 21q-1.275 0-1.812-1.137-.538-1.138.262-2.113L9 11V5H8q-.425 0-.713-.288Q7 4.425 7 4t.287-.713Q7.575 3 8 3h8q.425 0 .712.287Q17 3.575 17 4t-.288.712Q16.425 5 16 5h-1v6l5.55 6.75q.8.975.262 2.113Q20.275 21 19 21Zm2-3h10l-3.4-4h-3.2Zm-2 1h14l-6-7.3V5h-2v6.7Zm7-7Z'/%3E%3C/svg%3E "Alpha")createPopover` | **Notice:** Available only in the [v=alpha channel](https://developers.google.com/maps/documentation/javascript/versions.md.txt#choosing-the-alpha-channel). `createPopover()` **Parameters:** None **Return Value:** `Promise<PopoverElement>` Creates a popover for the route based on the data available for the route, configured in a way suitable for annotating a route on a map. Currently uses `Route.localizedValues`, `Route.path`, and `Route.legs`, if available. |
| `createWaypointAdvancedMarkers` | `createWaypointAdvancedMarkers([options])` **Parameters:** - `options: AdvancedMarkerElementOptions|(function(AdvancedMarkerElementOptions, WaypointMarkerDetails): AdvancedMarkerElementOptions) optional` **Return Value:** `Promise<Array<AdvancedMarkerElement>>` Creates markers for the route labeled 'A', 'B', 'C', etc. for each waypoint. Markers have default styling applied. Options can be passed in to alter the marker style based on the marker index or properties of the corresponding `RouteLeg`. The `WaypointMarkerDetails.leg` parameter will be undefined if the route has no legs. The `"legs"` field must be requested in `ComputeRoutesRequest.fields` in order for intermediate waypoints to be included. |
| `![Alpha](data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24' viewBox='0 0 24 24' fill='%2301579b'%3E%3Cpath d='M5 21q-1.275 0-1.812-1.137-.538-1.138.262-2.113L9 11V5H8q-.425 0-.713-.288Q7 4.425 7 4t.287-.713Q7.575 3 8 3h8q.425 0 .712.287Q17 3.575 17 4t-.288.712Q16.425 5 16 5h-1v6l5.55 6.75q.8.975.262 2.113Q20.275 21 19 21Zm2-3h10l-3.4-4h-3.2Zm-2 1h14l-6-7.3V5h-2v6.7Zm7-7Z'/%3E%3C/svg%3E "Alpha")createWaypointMarkers` | **Notice:** Available only in the [v=alpha channel](https://developers.google.com/maps/documentation/javascript/versions.md.txt#choosing-the-alpha-channel). `createWaypointMarkers<T extends MarkerElement|Marker3DElement|MarkerInteractiveElement|Marker3DInteractiveElement>([options])` **Parameters:** - `options: CreateWaypointMarkersOptions<T> optional` **Return Value:** `Promise<Array<T>>` Creates markers for the route's origin and destination. Markers have default styling applied unless a customOverride function is specified. Intermediate waypoints are not currently supported. Created markers have their `CollisionBehavior` set to `CollisionBehavior.REQUIRED_AND_HIDES_OPTIONAL` by default. Created markers have a localized `title` ("Origin" or "Destination") by default, which can be overridden in `forEach`. For `Marker3DElement` and `Marker3DInteractiveElement` markers, `sizePreserved` is set to `true` by default, which can also be overridden in `forEach`. |

## [ComputeRoutesRequest](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#ComputeRoutesRequest)
interface


interface
`google.maps.routes.ComputeRoutesRequest`

Request for routes.

| ### Properties ||
|---|---|
| `destination` | **Type:** `string|LatLng|LatLngLiteral|LatLngAltitudeLiteral|DirectionalLocationLiteral|Place|Waypoint` The destination of the route. A value passed as a string may be an address, [plus code](https://plus.codes), or a Place resource name. Altitude values are not taken into consideration for computing routes. |
| `fields` | **Type:** `Iterable<string>` Collection of fields to be fetched. Specify `["*"]` for all fields. |
| `origin` | **Type:** `string|LatLng|LatLngLiteral|LatLngAltitudeLiteral|DirectionalLocationLiteral|Place|Waypoint` The origin of the route. A value passed as a string may be an address, [plus code](https://plus.codes), or a Place resource name. Altitude values are not taken into consideration for computing routes. |
| `arrivalTime` optional | **Type:** `Date optional` The arrival time. Note: Can only be set when `ComputeRoutesRequest.travelMode` is set to `TRANSIT`. You can specify either `ComputeRoutesRequest.departureTime` or `ComputeRoutesRequest.arrivalTime`, but not both. Transit trips are available for up to 7 days in the past or 100 days in the future. |
| `computeAlternativeRoutes` optional | **Type:** `boolean optional` Specifies whether to calculate alternate routes in addition to the route. No alternative routes are returned for requests that have intermediate waypoints. |
| `departureTime` optional | **Type:** `Date optional` The departure time. If you don't set this value, then this value defaults to the time that you made the request. Note: You can only specify a time in the past when `ComputeRoutesRequest.travelMode` is set to `TRANSIT`. Transit trips are available for up to 7 days in the past or 100 days in the future. |
| `extraComputations` optional | **Type:** `Iterable<ComputeRoutesExtraComputation> optional` A list of extra computations which may be used to complete the request. Note: These extra computations may return extra fields on the response. These extra fields must also be specified in `ComputeRoutesRequest.fields` to be returned in the response. |
| `intermediates` optional | **Type:** `Iterable<Waypoint> optional` A set of waypoints along the route (excluding terminal points), for either stopping at or passing by. Up to 25 intermediate waypoints are supported. |
| `internalUsageAttributionIds` optional | **Type:** `Iterable<string> optional` Identifiers used to attribute calls to specific packages or OSS libraries. |
| `language` optional | **Type:** `string optional` The BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see [Unicode Locale Identifier](http://www.unicode.org/reports/tr35/#Unicode_locale_identifier). See [Language Support](https://developers.google.com/maps/faq.md.txt#languagesupport) for the list of supported languages. When you don't provide this value, the language is inferred from your Google Maps JavaScript API [localization settings](https://developers.google.com/maps/documentation/javascript/localization.md.txt#Language). Otherwise, the language is inferred from the location of the origin. |
| `optimizeWaypointOrder` optional | **Type:** `boolean optional` If set to true, the service attempts to minimize the overall cost of the route by re-ordering the specified intermediate waypoints. The request fails if any of the intermediate waypoints is a via waypoint. Use `Route.optimizedIntermediateWaypointIndices` in the response to find the new ordering. If `"optimizedIntermediateWaypointIndices"` is not requested in `ComputeRoutesRequest.fields`, the request fails. If set to false, `Route.optimizedIntermediateWaypointIndices` in the response will be empty. |
| `polylineQuality` optional | **Type:** `PolylineQuality optional` Specifies the preference for the quality of the polyline. |
| `region` optional | **Type:** `string optional` The region code, specified as a ccTLD ("top-level domain") two-character value. For more information see [Country code top-level domains](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains). When you don't provide this value, the region is inferred from your Google Maps JavaScript API [localization settings](https://developers.google.com/maps/documentation/javascript/localization.md.txt#Language). Otherwise, the region is inferred from the location of the origin. |
| `requestedReferenceRoutes` optional | **Type:** `Iterable<ReferenceRoute> optional` Specifies what reference routes to calculate as part of the request in addition to the default route. A reference route is a route with a different route calculation objective than the default route. For example a `FUEL_EFFICIENT` reference route calculation takes into account various parameters that would generate an optimal fuel efficient route. When using this feature, look for `Route.routeLabels` on the resulting routes. |
| `routeModifiers` optional | **Type:** `RouteModifiers optional` A set of conditions to satisfy that affect the way routes are calculated. For example you can specify features to avoid such as toll roads or highways. |
| `routingPreference` optional | **Type:** `RoutingPreference optional` Specifies how to compute the route. The server attempts to use the selected routing preference to compute the route. If the routing preference results in an error or an extra long latency, an error is returned. You can specify this option only when `ComputeRoutesRequest.travelMode` is `DRIVING` or `TWO_WHEELER`, otherwise the request fails. |
| `trafficModel` optional | **Type:** `TrafficModel optional` Specifies the assumptions to use when calculating time in traffic. This setting affects the value of `Route.durationMillis` and `RouteLeg.durationMillis` which contain the predicted time in traffic based on historical averages. `ComputeRoutesRequest.trafficModel` is only available for requests that have set `ComputeRoutesRequest.routingPreference` to `TRAFFIC_AWARE_OPTIMAL` and `ComputeRoutesRequest.travelMode` to `DRIVING`. Defaults to `BEST_GUESS`. |
| `transitPreference` optional | **Type:** `TransitPreference optional` Specifies preferences that influence the route returned for `TRANSIT` routes. Note: Can only be specified when `ComputeRoutesRequest.travelMode` is set to `TRANSIT`. |
| `travelMode` optional | **Type:** `TravelMode optional` Specifies the mode of transportation. |
| `units` optional | **Type:** `UnitSystem optional` Specifies the units of measure for the display fields, such as navigation instructions. The units of measure used for the route, leg, step distance, and duration are not affected by this value. If you don't provide this value, then the display units are inferred from the location of the origin. |

## [ComputeRoutesExtraComputation](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#ComputeRoutesExtraComputation)
constants


constants
`google.maps.routes.ComputeRoutesExtraComputation`

library `"routes"`

Extra computations to perform while completing the request. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#extracomputation) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `ComputeRoutesExtraComputationString` type.

```javascript
const {ComputeRoutesExtraComputation} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `FLYOVER_INFO_ON_POLYLINE` | Flyover information for the route(s). See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#extracomputation) for more information. |
| `FUEL_CONSUMPTION` | Estimated fuel consumption for the route(s). See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#extracomputation) for more information. |
| `HTML_FORMATTED_NAVIGATION_INSTRUCTIONS` | See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#extracomputation) for more information. |
| `NARROW_ROAD_INFO_ON_POLYLINE` | Narrow road information for the route(s). See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#extracomputation) for more information. |
| `TOLLS` | Toll information for the route(s). See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#extracomputation) for more information. |
| `TRAFFIC_ON_POLYLINE` | Traffic aware polylines for the route(s). See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#extracomputation) for more information. |

## [CreateWaypointMarkersOptions](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#CreateWaypointMarkersOptions)
interface


interface
`google.maps.routes.CreateWaypointMarkersOptions<T = MarkerElement|Marker3DElement|MarkerInteractiveElement|Marker3DInteractiveElement>`
**Notice:** Available only in the [v=alpha channel](https://developers.google.com/maps/documentation/javascript/versions.md.txt#choosing-the-alpha-channel).

Options for creating waypoint markers.

| ### Properties ||
|---|---|
| `forEach` optional | **Type:** `function(T): void optional` A custom function to mutate the created elements. The default forEach function appends pins with A-Z glyphs to each marker. For different behavior, override this function. |
| `markerClass` optional | **Type:** `new () => T optional` The constructor of the element to create. Supported types include: - `Marker3DElement` - `Marker3DInteractiveElement` - `MarkerElement` - `MarkerInteractiveElement` |

## [DirectionalLocationLiteral](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#DirectionalLocationLiteral)
interface


interface
`google.maps.routes.DirectionalLocationLiteral`
extends `LatLngAltitudeLiteral, LatLngLiteral`

implemented by `DirectionalLocation`

Object literals are accepted in place of `DirectionalLocation` instances as a convenience. These are converted to `DirectionalLocation` when the Maps JS API encounters them.

| ### Properties ||
|---|---|
| `heading` optional | **Type:** `number optional` The compass heading associated with the direction of the flow of traffic. Heading values can be numbers from 0 to 360, where 0 specifies a heading of due North, 90 specifies a heading of due East, and so on. You can use this field only for `DRIVING` and `TWO_WHEELER` `ComputeRoutesRequest.travelMode`. |

## [DirectionalLocation](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#DirectionalLocation)
class


class
`google.maps.routes.DirectionalLocation`
extends `LatLngAltitude`
implements `DirectionalLocationLiteral, LatLngAltitudeLiteral, LatLngLiteral`

library `"routes"`

Encapsulates a geographic point and an optional heading.

```javascript
const {DirectionalLocation} = await google.maps.importLibrary("routes");
```

| ### Constructor ||
|---|---|

| ### Properties ||
|---|---|
| `heading` readonly | **Type:** `number optional` The compass heading associated with the direction of the flow of traffic. Heading values can be numbers from 0 to 360, where 0 specifies a heading of due North, 90 specifies a heading of due East, and so on. You can use this field only for `DRIVING` and `TWO_WHEELER` `ComputeRoutesRequest.travelMode`. |

| ### Methods ||
|---|---|
| `toJSON` | `toJSON([key])` **Parameters:** - `key: string optional` **Return Value:** `DirectionalLocationLiteral` Converts to a plain object. |

## [FallbackInfo](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#FallbackInfo)
class


class
`google.maps.routes.FallbackInfo`

library `"routes"`

Information related to how and why a fallback result was used in a `Route.computeRoutes` response. If this field is set, then it means the server used a different routing mode from your preferred mode as fallback.

```javascript
const {FallbackInfo} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `reason` readonly | **Type:** `FallbackReason optional` The reason why fallback response was used instead of the original response. This field is only populated when the fallback mode is triggered and the fallback response is returned. |
| `routingMode` readonly | **Type:** `FallbackRoutingMode optional` Routing mode used for the response. If fallback was triggered, the mode may be different from routing preference set in the original client request. |

| ### Methods ||
|---|---|

## [FallbackReason](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#FallbackReason)
constants


constants
`google.maps.routes.FallbackReason`

library `"routes"`

Reasons for using fallback response. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#fallbackreason) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `FallbackReasonString` type.

```javascript
const {FallbackReason} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `LATENCY_EXCEEDED` | We were not able to finish the calculation with your preferred routing mode on time, but we were able to return a result calculated by an alternative mode. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#fallbackreason) for more information. |
| `SERVER_ERROR` | A server error happened while calculating routes with your preferred routing mode, but we were able to return a result calculated by an alternative mode. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#fallbackreason) for more information. |

## [FallbackRoutingMode](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#FallbackRoutingMode)
constants


constants
`google.maps.routes.FallbackRoutingMode`

library `"routes"`

Actual routing mode used for returned fallback response. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#fallbackroutingmode) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `FallbackRoutingModeString` type.

```javascript
const {FallbackRoutingMode} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `TRAFFIC_AWARE` | See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#fallbackroutingmode) for more information. |
| `TRAFFIC_UNAWARE` | See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#fallbackroutingmode) for more information. |

## [GeocodedWaypoint](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#GeocodedWaypoint)
class


class
`google.maps.routes.GeocodedWaypoint`

library `"routes"`

Geocoding about the locations used as waypoints. Only populated for address waypoints. Includes details about the geocoding results for the purposes of determining what the address was geocoded to.

```javascript
const {GeocodedWaypoint} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `geocoderStatus` readonly | **Type:** `RPCStatus optional` Indicates the status code resulting from the geocoding operation. |
| `intermediateWaypointRequestIndex` readonly | **Type:** `number optional` The index of the corresponding intermediate waypoint in the request. Only populated if the corresponding waypoint is an intermediate waypoint. |
| `partialMatch` readonly | **Type:** `boolean` Indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address. You may wish to examine the original request for misspellings and/or an incomplete address. |
| `placeId` readonly | **Type:** `string` The place ID for this result. |
| `types` readonly | **Type:** `Array<string>` The type(s) of the result, in the form of zero or more type tags. See <https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types> for supported types. |

| ### Methods ||
|---|---|

## [GeocodingResults](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#GeocodingResults)
class


class
`google.maps.routes.GeocodingResults`

library `"routes"`

Contains `GeocodedWaypoint`s for origin, destination, and intermediate waypoints. Only populated for address waypoints.

```javascript
const {GeocodingResults} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `destination` readonly | **Type:** `GeocodedWaypoint optional` The geocoded waypoint for the destination. |
| `intermediates` readonly | **Type:** `Array<GeocodedWaypoint> optional` A list of intermediate geocoded waypoints each containing an index field that corresponds to the zero-based position of the waypoint in the order they were specified in the request. |
| `origin` readonly | **Type:** `GeocodedWaypoint optional` The geocoded waypoint for the origin. |

| ### Methods ||
|---|---|

## [MultiModalSegment](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#MultiModalSegment)
class


class
`google.maps.routes.MultiModalSegment`

library `"routes"`

Provides summarized information about a multi-modal segment of the `RouteLeg.steps` of a route. A multi-modal segment is defined as one or more contiguous `RouteLegStep`'s that have the same `TravelMode`.

```javascript
const {MultiModalSegment} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `instructions` readonly | **Type:** `string optional` Instructions for navigating this multi-modal segment. |
| `maneuver` readonly | **Type:** `string optional` The navigation maneuver to perform at this step. See [Maneuver](https://developers.google.com/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes.md.txt#maneuver) for a list of possible values. |
| `stepEndIndex` readonly | **Type:** `number` The corresponding `RouteLegStep` index that is the end of a multi-modal segment. |
| `stepStartIndex` readonly | **Type:** `number` The corresponding `RouteLegStep` index that is the start of a multi-modal segment. |
| `travelMode` readonly | **Type:** `TravelMode optional` The travel mode used for this multi-modal segment. |

| ### Methods ||
|---|---|

## [PolylineDetailInfo](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#PolylineDetailInfo)
class


class
`google.maps.routes.PolylineDetailInfo`

library `"routes"`

Encapsulates information about a road feature along a stretch of polyline.

```javascript
const {PolylineDetailInfo} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `endIndex` readonly | **Type:** `number optional` The end index of this road feature in the polyline. |
| `presence` readonly | **Type:** `RoadFeatureState optional` Denotes whether the road feature exists along the polyline. |
| `startIndex` readonly | **Type:** `number optional` The start index of this road feature in the polyline. |

| ### Methods ||
|---|---|

## [PolylineDetails](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#PolylineDetails)
class


class
`google.maps.routes.PolylineDetails`

library `"routes"`

Details corresponding to a given index or contiguous segment of a polyline. Given a polyline with points P_0, P_1, ... , P_N (zero-based index), the `PolylineDetails` describes a road feature for a given interval.

```javascript
const {PolylineDetails} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `flyoverInfo` readonly | **Type:** `Array<PolylineDetailInfo>` Flyover details along the polyline. |
| `narrowRoadInfo` readonly | **Type:** `Array<PolylineDetailInfo>` Narrow road details along the polyline. |

| ### Methods ||
|---|---|

## [PolylineQuality](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#PolylineQuality)
constants


constants
`google.maps.routes.PolylineQuality`

library `"routes"`

A set of values that specify the quality of the polyline. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#polylinequality) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `PolylineQualityString` type.

```javascript
const {PolylineQuality} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `HIGH_QUALITY` | Specifies a high-quality polyline - which is composed using more points than `OVERVIEW`, at the cost of increased response size. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#polylinequality) for more information. |
| `OVERVIEW` | Specifies an overview polyline - which is composed using a small number of points. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#polylinequality) for more information. |

## [ReferenceRoute](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#ReferenceRoute)
constants


constants
`google.maps.routes.ReferenceRoute`

library `"routes"`

A supported reference route on the ComputeRoutesRequest. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#referenceroute) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `ReferenceRouteString` type.

```javascript
const {ReferenceRoute} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `FUEL_EFFICIENT` | Fuel efficient route. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#referenceroute) for more information. |
| `SHORTER_DISTANCE` | Route with shorter travel distance. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#referenceroute) for more information. |

## [RoadFeatureState](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RoadFeatureState)
constants


constants
`google.maps.routes.RoadFeatureState`

library `"routes"`

Encapsulates the states of road features along a stretch of polyline. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#roadfeaturestate) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `RoadFeatureStateString` type.

```javascript
const {RoadFeatureState} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `DOES_NOT_EXIST` | The road feature does not exist. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#roadfeaturestate) for more information. |
| `EXISTS` | The road feature exists. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#roadfeaturestate) for more information. |

## [RouteLabel](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteLabel)
constants


constants
`google.maps.routes.RouteLabel`

library `"routes"`

See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routelabel) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `RouteLabelString` type.

```javascript
const {RouteLabel} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `DEFAULT_ROUTE` | The default "best" route returned for the route computation. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routelabel) for more information. |
| `DEFAULT_ROUTE_ALTERNATE` | An alternative to the default "best" route. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routelabel) for more information. |
| `FUEL_EFFICIENT` | Fuel efficient route. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routelabel) for more information. |
| `SHORTER_DISTANCE` | Shorter travel distance route. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routelabel) for more information. |

## [RouteLeg](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteLeg)
class


class
`google.maps.routes.RouteLeg`

library `"routes"`

Contains a segment between non-`via` waypoints.

```javascript
const {RouteLeg} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `distanceMeters` readonly | **Type:** `number` The travel distance of the route leg, in meters. |
| `durationMillis` readonly | **Type:** `number optional` The length of time needed to navigate the route leg in milliseconds. If you set `ComputeRoutesRequest.routingPreference` to `TRAFFIC_UNAWARE`, then this value is the same as `staticDurationMillis`. If you set `ComputeRoutesRequest.routingPreference` to either `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL`, then this value is calculated taking traffic conditions into account. Note: If the duration exceeds 2\^53 milliseconds, then this value is `Number.POSITIVE_INFINITY`. |
| `endLocation` readonly | **Type:** `DirectionalLocation optional` The end location of this leg. This location might be different from `ComputeRoutesRequest.destination`. For example, when `ComputeRoutesRequest.destination` is not near a road, this is a point on the road. |
| `localizedValues` readonly | **Type:** `RouteLegLocalizedValues optional` Text representations of properties of the `RouteLeg`. |
| `path` readonly | **Type:** `Array<LatLngAltitude>` The list of `LatLngAltitude`s of the route leg, which can be used to draw a route leg polyline. Granularity of the path can be controlled by setting `ComputeRoutesRequest.polylineQuality`. |
| `speedPaths` readonly | **Type:** `Array<SpeedPath>` Groupings of sections of the route leg path with their corresponding speed reading. For this field to be populated, `ComputeRoutesRequest.routingPreference` must be set to `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL` and `ComputeRoutesRequest.extraComputations` must include `TRAFFIC_ON_POLYLINE`. |
| `startLocation` readonly | **Type:** `DirectionalLocation optional` The start location of this leg. This location might be different from `ComputeRoutesRequest.origin`. For example, when `ComputeRoutesRequest.origin` is not near a road, this is a point on the road. |
| `staticDurationMillis` readonly | **Type:** `number optional` The duration of traveling through the leg without taking traffic conditions into consideration. Note: If the duration exceeds 2\^53 milliseconds, then this value is `Number.POSITIVE_INFINITY`. |
| `steps` readonly | **Type:** `Array<RouteLegStep>` An array of steps denoting segments within this leg. Each step represents one navigation instruction. |
| `stepsOverview` readonly | **Type:** `StepsOverview optional` Overview information about the steps in this `RouteLeg`. This field is only populated for `TRANSIT` routes. |
| `travelAdvisory` readonly | **Type:** `RouteLegTravelAdvisory optional` Contains the additional information that the user should be informed about, such as possible traffic zone restrictions, on a route leg. |

| ### Methods ||
|---|---|

## [RouteLegLocalizedValues](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteLegLocalizedValues)
class


class
`google.maps.routes.RouteLegLocalizedValues`

library `"routes"`

Text representations of the `RouteLeg`.

```javascript
const {RouteLegLocalizedValues} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `distance` readonly | **Type:** `string optional` Travel distance of the route leg in text form. |
| `distanceLanguage` readonly | **Type:** `string optional` The distance text's BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>. |
| `duration` readonly | **Type:** `string optional` Duration, represented in text form and localized to the region of the query. Takes traffic conditions into consideration. |
| `durationLanguage` readonly | **Type:** `string optional` The duration text's BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>. |
| `staticDuration` readonly | **Type:** `string optional` Duration without taking traffic conditions into consideration, represented in text form. |
| `staticDurationLanguage` readonly | **Type:** `string optional` The static duration text's BCP-47 language code, such as "en-US" or "sr-Latn". |

| ### Methods ||
|---|---|

## [RouteLegStep](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteLegStep)
class


class
`google.maps.routes.RouteLegStep`

library `"routes"`

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

```javascript
const {RouteLegStep} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `distanceMeters` readonly | **Type:** `number` The travel distance of this step, in meters. |
| `endLocation` readonly | **Type:** `DirectionalLocation optional` The end location of this step. |
| `instructions` readonly | **Type:** `string optional` Instructions for navigating this step. |
| `localizedValues` readonly | **Type:** `RouteLegStepLocalizedValues optional` Text representations of properties of the `RouteLegStep`. |
| `maneuver` readonly | **Type:** `string optional` The navigation maneuver to perform at this step. See [Maneuver](https://developers.google.com/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes.md.txt#maneuver) for a list of possible values. |
| `path` readonly | **Type:** `Array<LatLngAltitude>` The list of `LatLngAltitude`s of the route leg step, which can be used to draw a route leg step polyline. Granularity of the path can be controlled by setting `ComputeRoutesRequest.polylineQuality`. The `"path"` field must be requested in `ComputeRoutesRequest.fields` in order for this field to be populated. |
| `startLocation` readonly | **Type:** `DirectionalLocation optional` The start location of this step. |
| `staticDurationMillis` readonly | **Type:** `number optional` The duration of traveling through this step without taking traffic conditions into consideration. Note: If the duration exceeds 2\^53 milliseconds, then this value is `Number.POSITIVE_INFINITY`. |
| `transitDetails` readonly | **Type:** `TransitDetails optional` Details pertaining to this step if the travel mode is `TRANSIT`. |
| `travelMode` readonly | **Type:** `TravelMode optional` The travel mode used for this step. |

| ### Methods ||
|---|---|

## [RouteLegStepLocalizedValues](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteLegStepLocalizedValues)
class


class
`google.maps.routes.RouteLegStepLocalizedValues`

library `"routes"`

Text representations of properties of the `RouteLegStep`.

```javascript
const {RouteLegStepLocalizedValues} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `distance` readonly | **Type:** `string optional` Travel distance of the route leg step in text form. |
| `distanceLanguage` readonly | **Type:** `string optional` The distance text's BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>. |
| `staticDuration` readonly | **Type:** `string optional` Duration without taking traffic conditions into consideration, represented in text form. |
| `staticDurationLanguage` readonly | **Type:** `string optional` The static duration text's BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>. |

| ### Methods ||
|---|---|

## [RouteLegTravelAdvisory](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteLegTravelAdvisory)
class


class
`google.maps.routes.RouteLegTravelAdvisory`

library `"routes"`

Contains additional information that the user should be informed about on a `RouteLeg`.

```javascript
const {RouteLegTravelAdvisory} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `speedReadingIntervals` readonly | **Type:** `Array<SpeedReadingInterval> optional` Speed reading intervals detailing traffic density. Applicable in case of `TRAFFIC_AWARE` and `TRAFFIC_AWARE_OPTIMAL` `ComputeRoutesRequest.routingPreference`. 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) |
| `tollInfo` readonly | **Type:** `TollInfo optional` Contains information about tolls on the specific `RouteLeg`. This field is only populated if tolls are expected on the `RouteLeg`. If this field is set but `TollInfo.estimatedPrices` is not populated, then the route leg contains tolls but the estimated price is unknown. If this field is empty, then there are no tolls on the `RouteLeg`. |

| ### Methods ||
|---|---|

## [RouteLocalizedValues](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteLocalizedValues)
class


class
`google.maps.routes.RouteLocalizedValues`

library `"routes"`

Text representations of properties of the `Route`.

```javascript
const {RouteLocalizedValues} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `distance` readonly | **Type:** `string optional` Travel distance of the route represented in text form. |
| `distanceLanguage` readonly | **Type:** `string optional` The distance text's BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>. |
| `duration` readonly | **Type:** `string optional` Duration, represented in text form and localized to the region of the query. Takes traffic conditions into consideration. Note: If you did not request traffic information, this value is the same value as `staticDuration`. |
| `durationLanguage` readonly | **Type:** `string optional` The duration text's BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>. |
| `staticDuration` readonly | **Type:** `string optional` Duration without taking traffic conditions into consideration, represented in text form. |
| `staticDurationLanguage` readonly | **Type:** `string optional` The static duration text's BCP-47 language code, such as "en-US" or "sr-Latn". |
| `transitFare` readonly | **Type:** `string optional` Transit fare represented in text form. |
| `transitFareLanguage` readonly | **Type:** `string optional` The transit fare text's BCP-47 language code, such as "en-US" or "sr-Latn". |

| ### Methods ||
|---|---|

## [RouteModifiers](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteModifiers)
interface


interface
`google.maps.routes.RouteModifiers`

Encapsulates a set of optional conditions to satisfy when calculating routes.

| ### Properties ||
|---|---|
| `avoidFerries` optional | **Type:** `boolean optional` When set to `true`, avoids ferries where reasonable, giving preference to routes not containing ferries. Applies only to `DRIVING` or `TWO_WHEELER` `TravelMode`. |
| `avoidHighways` optional | **Type:** `boolean optional` When set to `true`, avoids highways where reasonable, giving preference to routes not containing highways. Applies only to `DRIVING` or `TWO_WHEELER` `TravelMode`. |
| `avoidIndoor` optional | **Type:** `boolean optional` When set to `true`, avoids navigating indoors where reasonable, giving preference to routes not containing indoor navigation. Applies only to `WALKING` `TravelMode`. |
| `avoidTolls` optional | **Type:** `boolean optional` When set to `true`, avoids toll roads where reasonable, giving preference to routes not containing toll roads. Applies only to `DRIVING` or `TWO_WHEELER` `TravelMode`. |
| `tollPasses` optional | **Type:** `Iterable<string> optional` Encapsulates information about toll passes. If toll passes are provided, the API tries to return the pass price. If toll passes are not provided, the API treats the toll pass as unknown and tries to return the cash price. Applies only to `DRIVING` or `TWO_WHEELER` `TravelMode`. See [TollPass](https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers.md.txt#tollpass) for a list of valid values. |
| `vehicleInfo` optional | **Type:** `VehicleInfo optional` Specifies the vehicle information. |

## [RoutePolyline3DOptions](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RoutePolyline3DOptions)
interface


interface
`google.maps.routes.RoutePolyline3DOptions`
**Notice:** Available only in the [v=alpha channel](https://developers.google.com/maps/documentation/javascript/versions.md.txt#choosing-the-alpha-channel).

Options for creating route 3D polylines.

| ### Properties ||
|---|---|
| `polylineOptions` optional | **Type:** `Polyline3DElementOptions|(function(Polyline3DElementOptions, RoutePolylineDetails): Polyline3DElementOptions) optional` Options for customizing the style of a 3D polyline. |
| `trafficPolylinesDisabled` optional | **Type:** `boolean optional` Whether to disable traffic-aware polylines. Traffic aware polylines are only available when routingPreference is set to TRAFFIC_AWARE or TRAFFIC_AWARE_OPTIMAL. |

## [RoutePolylineDetails](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RoutePolylineDetails)
interface


interface
`google.maps.routes.RoutePolylineDetails`

Details about a section of a route corresponding to a polyline that can be used to customize the polyline style.

| ### Properties ||
|---|---|
| `speed` optional | **Type:** `Speed optional` The speed reading of the section of the route corresponding to this polyline. Only populated for routes with traffic information. |
| `transitDetails` optional | **Type:** `TransitDetails optional` The transit details of the section of the route corresponding to this polyline. Only populated for routes with transit information. |
| `travelMode` optional | **Type:** `TravelMode optional` The travel mode of the section of the route corresponding to this polyline. Empty for traffic polylines. |

## [RoutePolylineOptions](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RoutePolylineOptions)
interface


interface
`google.maps.routes.RoutePolylineOptions`

Options for creating route polylines.

| ### Properties ||
|---|---|
| `colorScheme` optional | **Type:** `ColorScheme optional` The color scheme to use for the polyline. When specified as `FOLLOW_SYSTEM` while the map `colorScheme` is also `FOLLOW_SYSTEM`, the polylines will be drawn in the same dark/light mode as the map. When not specified, `Route.createPolylines` attempts to use the `colorScheme` of the map or falls back to the system default. |
| `polylineOptions` optional | **Type:** `PolylineOptions|(function(PolylineOptions, RoutePolylineDetails): PolylineOptions) optional` Options for customizing the style of a polyline. Can either be a `PolylineOptions` object that is applied to all polylines for the route or a function that takes default `PolylineOptions` and `RoutePolylineDetails` and returns the `PolylineOptions` to be applied to that polyline. |

## [RouteTravelAdvisory](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RouteTravelAdvisory)
class


class
`google.maps.routes.RouteTravelAdvisory`

library `"routes"`

Contains additional information that the user should be informed about on a `Route`.

```javascript
const {RouteTravelAdvisory} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `fuelConsumptionMicroliters` readonly | **Type:** `number optional` The predicted fuel consumption in microliters. Note: If the fuel consumption exceeds 2\^53 microliters, then this value is `Number.POSITIVE_INFINITY`. |
| `routeRestrictionsPartiallyIgnored` readonly | **Type:** `boolean optional` The `Route` may have restrictions that are not suitable for the requested travel mode or route modifiers. |
| `speedReadingIntervals` readonly | **Type:** `Array<SpeedReadingInterval> optional` Speed reading intervals detailing traffic density. Applicable in case of `TRAFFIC_AWARE` and `TRAFFIC_AWARE_OPTIMAL` `ComputeRoutesRequest.routingPreference`. The intervals cover the entire polyline of the `Route` 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) |
| `tollInfo` readonly | **Type:** `TollInfo optional` Contains information about tolls on the `Route`. This field is only populated if tolls are expected on the `Route`. If this field is set but `TollInfo.estimatedPrices` is not populated, then the route contains tolls but the estimated price is unknown. If this field is empty, then there are no tolls on the `Route`. |
| `transitFare` readonly | **Type:** `Money optional` If present, contains the total fare or ticket costs of this `Route`. This property is only returned for `TRANSIT` `ComputeRoutesRequest.travelMode` and only for routes where fare information is available for all transit steps. |

| ### Methods ||
|---|---|

## [RoutingPreference](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#RoutingPreference)
constants


constants
`google.maps.routes.RoutingPreference`

library `"routes"`

A set of values that specify factors to take into consideration when calculating the route. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routingpreference) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `RoutingPreferenceString` type.

```javascript
const {RoutingPreference} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `TRAFFIC_AWARE` | Calculates routes taking live traffic conditions into consideration. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routingpreference) for more information. |
| `TRAFFIC_AWARE_OPTIMAL` | Calculates the routes taking live traffic conditions into consideration, without applying most performance optimizations. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routingpreference) for more information. |
| `TRAFFIC_UNAWARE` | Computes routes without taking live traffic conditions into consideration. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#routingpreference) for more information. |

## [Speed](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Speed)
constants


constants
`google.maps.routes.Speed`

library `"routes"`

The classification of polyline speed based on traffic data. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#speed) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `SpeedString` type.

```javascript
const {Speed} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `NORMAL` | Normal speed, no traffic delays. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#speed) for more information. |
| `SLOW` | Slowdown detected, medium amount of traffic. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#speed) for more information. |
| `TRAFFIC_JAM` | Traffic delays. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#speed) for more information. |

## [SpeedPath](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#SpeedPath)
interface


interface
`google.maps.routes.SpeedPath`

Groups together the `LatLngAltitude`s of a route interval with the speed reading for the interval.

| ### Properties ||
|---|---|
| `path` | **Type:** `Array<LatLngAltitude>` The path covered by this speed path. |
| `speed` optional | **Type:** `Speed optional` The speed reading of the path. |

## [SpeedReadingInterval](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#SpeedReadingInterval)
class


class
`google.maps.routes.SpeedReadingInterval`

library `"routes"`

Traffic density indicator on a contiguous segment of a polyline or path. Given a path with points P_0, P_1, ... , P_N (zero-based index), the `SpeedReadingInterval` describes the traffic density of an interval.

```javascript
const {SpeedReadingInterval} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `endPolylinePointIndex` readonly | **Type:** `number optional` The ending index of this interval in the polyline. |
| `speed` readonly | **Type:** `Speed optional` Traffic speed in this interval. |
| `startPolylinePointIndex` readonly | **Type:** `number optional` The starting index of this interval in the polyline. |

## [StepsOverview](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#StepsOverview)
class


class
`google.maps.routes.StepsOverview`

library `"routes"`

Provides overview information about a list of `RouteLeg.steps`.

```javascript
const {StepsOverview} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `multiModalSegments` readonly | **Type:** `Array<MultiModalSegment>` Summarized information about different multi-modal segments of the `RouteLeg.steps`. |

| ### Methods ||
|---|---|

## [TollInfo](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#TollInfo)
class


class
`google.maps.routes.TollInfo`

library `"routes"`

Encapsulates toll information on a `Route` or `RouteLeg`.

```javascript
const {TollInfo} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `estimatedPrices` readonly | **Type:** `Array<Money> optional` The monetary amount of tolls for the corresponding `Route` or `RouteLeg`. This list contains an amount for each currency that is expected to be charged by toll stations. Typically this list will contain only one item for routes with tolls in one currency. For international trips, this list may contain multiple items to reflect tolls in different currencies. This field may be an empty array if tolls are expected but the estimated price is unknown. |

| ### Methods ||
|---|---|

## [TransitAgency](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#TransitAgency)
class


class
`google.maps.routes.TransitAgency`

library `"routes"`

Information about a transit agency.

```javascript
const {TransitAgency} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `name` readonly | **Type:** `string optional` The name of this transit agency. |
| `phoneNumber` readonly | **Type:** `string optional` The transit agency's locale-specific formatted phone number. |
| `url` readonly | **Type:** `URL optional` The transit agency's URL. |

| ### Methods ||
|---|---|

## [TransitDetails](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#TransitDetails)
class


class
`google.maps.routes.TransitDetails`

library `"routes"`

Additional information about a transit step in a route.

```javascript
const {TransitDetails} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `arrivalStop` readonly | **Type:** `TransitStop optional` Information about the arrival stop for the step. |
| `arrivalTime` readonly | **Type:** `Date optional` The estimated time of arrival for the step. |
| `departureStop` readonly | **Type:** `TransitStop optional` Information about the departure stop for the step. |
| `departureTime` readonly | **Type:** `Date optional` The estimated time of departure for the step. |
| `headsign` readonly | **Type:** `string optional` Specifies the direction in which to travel on this line as marked on the vehicle or at the departure stop. The direction is often the terminus station. |
| `headwayMillis` readonly | **Type:** `number optional` Specifies the expected time in milliseconds between departures from the same stop at this time. For example, with a headway value of 600,000, you would expect a ten minute wait if you should miss your bus. Note: If the headway exceeds 2\^53 milliseconds, then this value is `Number.POSITIVE_INFINITY`. |
| `stopCount` readonly | **Type:** `number` The number of stops from the departure to the arrival stop. This count includes the arrival stop, but excludes the departure stop. For example, if your route leaves from Stop A, passes through stops B and C, and arrives at stop D, `stopCount` will be 3. |
| `transitLine` readonly | **Type:** `TransitLine optional` Information about the transit line used in the step. |
| `tripShortText` readonly | **Type:** `string optional` The text that appears in schedules and sign boards to identify a transit trip to passengers. The text uniquely identifies a trip within a service day. For example, "538" is the `tripShortText` of the Amtrak train that leaves San Jose, CA at 15:10 on weekdays to Sacramento, CA. |

| ### Methods ||
|---|---|

## [TransitLine](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#TransitLine)
class


class
`google.maps.routes.TransitLine`

library `"routes"`

Information about a transit line.

```javascript
const {TransitLine} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `agencies` readonly | **Type:** `Array<TransitAgency>` The transit agency (or agencies) that operates this transit line. |
| `color` readonly | **Type:** `string optional` The color commonly used in signage for this line. Represented in hexadecimal. |
| `iconURL` readonly | **Type:** `URL optional` The URL for the icon associated with this line. |
| `name` readonly | **Type:** `string optional` The full name of this transit line, For example, "8 Avenue Local". |
| `shortName` readonly | **Type:** `string optional` The short name of this transit line. This name will normally be a line number, such as "M7" or "355". |
| `textColor` readonly | **Type:** `string optional` The color commonly used in text on signage for this line. Represented in hexadecimal. |
| `url` readonly | **Type:** `URL optional` The URL for this transit line as provided by the transit agency. |
| `vehicle` readonly | **Type:** `TransitVehicle optional` The type of vehicle that operates on this transit line. |

| ### Methods ||
|---|---|

## [TransitPreference](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#TransitPreference)
interface


interface
`google.maps.routes.TransitPreference`

Preferences for `TRANSIT` based routes that influence the route that is returned.

| ### Properties ||
|---|---|
| `allowedTransitModes` optional | **Type:** `Iterable<TransitMode> optional` A set of travel modes to use when getting a `TRANSIT` route. Defaults to all supported modes of travel. |
| `routingPreference` optional | **Type:** `TransitRoutePreference optional` A routing preference that, when specified, influences the `TRANSIT` route returned. |

## [TransitStop](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#TransitStop)
class


class
`google.maps.routes.TransitStop`

library `"routes"`

Information about a transit stop.

```javascript
const {TransitStop} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `location` readonly | **Type:** `DirectionalLocation optional` The location of the stop expressed in latitude/longitude coordinates and an optional heading. |
| `name` readonly | **Type:** `string optional` The name of the transit stop. |

| ### Methods ||
|---|---|

## [TransitVehicle](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#TransitVehicle)
class


class
`google.maps.routes.TransitVehicle`

library `"routes"`

Information about a vehicle used in transit routes.

```javascript
const {TransitVehicle} = await google.maps.importLibrary("routes");
```

| ### Properties ||
|---|---|
| `iconURL` readonly | **Type:** `URL optional` The URL for an icon associated with this vehicle type. |
| `localIconURL` readonly | **Type:** `URL optional` The URL for the icon associated with this vehicle type, based on the local transport signage. |
| `name` readonly | **Type:** `string optional` The name of this vehicle, capitalized. |
| `nameLanguage` readonly | **Type:** `string optional` The vehicle name text's BCP-47 language code, such as "en-US" or "sr-Latn". For more information see: <https://www.unicode.org/reports/tr35/#Unicode_locale_identifier>. |
| `vehicleType` readonly | **Type:** `string optional` The type of vehicle used. See <https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2#transitvehicletype> for a list of possible values. |

| ### Methods ||
|---|---|

## [VehicleEmissionType](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#VehicleEmissionType)
constants


constants
`google.maps.routes.VehicleEmissionType`

library `"routes"`

A set of values describing the vehicle's emission type. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#vehicleemissiontype) for more information.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `VehicleEmissionTypeString` type.

```javascript
const {VehicleEmissionType} = await google.maps.importLibrary("routes");
```

| ### Constants ||
|---|---|
| `DIESEL` | Diesel fueled vehicle. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#vehicleemissiontype) for more information. |
| `ELECTRIC` | Electricity powered vehicle. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#vehicleemissiontype) for more information. |
| `GASOLINE` | Gasoline/petrol fueled vehicle. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#vehicleemissiontype) for more information. |
| `HYBRID` | Hybrid fuel (such as gasoline + electric) vehicle. See the [web service documentation](https://developers.google.com/maps/documentation/routes/reference/rpc/google.maps.routing.v2.md.txt#vehicleemissiontype) for more information. |

## [VehicleInfo](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#VehicleInfo)
interface


interface
`google.maps.routes.VehicleInfo`

Contains the vehicle information, such as the vehicle emission type.

| ### Properties ||
|---|---|
| `emissionType` optional | **Type:** `VehicleEmissionType optional` Describes the vehicle's emission type. Applies only to the `DRIVING` travel mode. |

## [Waypoint](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Waypoint)
interface


interface
`google.maps.routes.Waypoint`

Represents a waypoint in a route.

| ### Properties ||
|---|---|
| `location` | **Type:** `string|LatLng|LatLngLiteral|LatLngAltitudeLiteral|DirectionalLocationLiteral|Place` The location of the waypoint. A string may be an address, a [plus code](https://plus.codes), or a Place resource name. |
| `sideOfRoad` optional | **Type:** `boolean optional` Indicates that the location of this waypoint is meant to have a preference for the vehicle to stop at a particular side of road. When you set this value, the route will pass through the location so that the vehicle can stop at the side of road that the location is biased towards from the center of the road. This option works only for `DRIVING` and `TWO_WHEELER` `ComputeRoutesRequest.travelMode` |
| `vehicleStopover` optional | **Type:** `boolean optional` Indicates that the waypoint is meant for vehicles to stop at, where the intention is to either pickup or drop-off. When you set this value, the calculated route won't include non-`via` waypoints on roads that are unsuitable for pickup and drop-off. This option works only for `DRIVING` and `TWO_WHEELER` `ComputeRoutesRequest.travelMode` and when the `Waypoint.location` is not a `string` or a `Place`. |
| `via` optional | **Type:** `boolean optional` Marks this waypoint as a milestone rather a stopping point. For each non-`via` waypoint in the `ComputeRoutesRequest`, `Route.computeRoutes` appends an entry to the `Route.legs` array to provide the details for stopovers on that leg of the trip. Set this value to `true` when you want the route to pass through this waypoint without stopping over. Via waypoints don't cause an entry to be added to the `Route.legs` array, but they do route the journey through the waypoint. Notes: - You can only set this value on waypoints that are intermediates. The request fails if you set this field on terminal waypoints. - If `ComputeRoutesRequest.optimizeWaypointOrder` is set to `true`, this field cannot be set to true; otherwise, the request fails. |

## [WaypointMarkerDetails](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#WaypointMarkerDetails)
interface


interface
`google.maps.routes.WaypointMarkerDetails`

Details about a waypoint that can be used to customize marker style.

| ### Properties ||
|---|---|
| `index` | **Type:** `number` The index of the marker. |
| `totalMarkers` | **Type:** `number` The total number of markers in the route. |
| `leg` optional | **Type:** `RouteLeg optional` The leg that the marker belongs to. Empty if the route has no legs. |