Route class
google.maps.routes
. Route
class
Contains a route, which consists of a series of connected road segments that join beginning, ending, and intermediate waypoints.
Access by calling const {Route} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Static Methods
computeRoutes(request)
-
request
:ComputeRoutesRequest
Promise
<{
routes: Array
< Route
> optional
,
fallbackInfo: FallbackInfo
optional
,
geocodingResults: GeocodingResults
optional
}>
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']
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
string optional
number optional
number optional
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
.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.
origin
to intermediates
to destination
. RouteLocalizedValues
optional
Array
<number> optional
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
[2, 0, 1]
. Array
< LatLngAltitude
> optional
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
optional
Array
< RouteLabel
> optional
string optional
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. ComputeRoutesRequest.routingPreference
must be set to TRAFFIC_AWARE
or TRAFFIC_AWARE_OPTIMAL
and ComputeRoutesRequest.extraComputations
must include TRAFFIC_ON_POLYLINE
.number optional
Note: If the duration exceeds 2^53 milliseconds, then this value is
Number.POSITIVE_INFINITY
. RouteTravelAdvisory
optional
Methods
createPolylines([options])
-
options
:RoutePolylineOptions optional
Multi-modal polylines:
- Requirements:
- The
"path"
and"legs"
fields must be requested inComputeRoutesRequest.fields
-
ComputeRoutesRequest.travelMode
must be set toTRANSIT
.
- The
- 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.
Traffic polylines:
- Requirements:
- The
"path"
and"travelAdvisory"
fields (or just"speedPaths"
as a shorthand) must be requested inComputeRoutesRequest.fields
. -
ComputeRoutesRequest.routingPreference
must be set toTRAFFIC_AWARE
orTRAFFIC_AWARE_OPTIMAL
. -
ComputeRoutesRequest.extraComputations
must includeTRAFFIC_ON_POLYLINE
.
- The
- 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.
Overall polyline:
- Requirements:
- The
"path"
field must be requested inComputeRoutesRequest.fields
.
- The
- 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
.
createWaypointAdvancedMarkers([options])
-
options
:AdvancedMarkerElementOptions |(function( AdvancedMarkerElementOptions , WaypointMarkerDetails ): AdvancedMarkerElementOptions ) optional
Promise
< Array
< AdvancedMarkerElement
>>
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.ComputeRoutesRequest interface
google.maps.routes
. ComputeRoutesRequest
interface
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 or plus code
. 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 or plus code
. 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
|
A set of waypoints along the route (excluding terminal points), for either stopping at or passing by. Up to 25 intermediate waypoints are supported.
|
language
optional
|
Type:
string optional
The BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see Unicode Locale Identifier
. See Language Support
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
. 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
. When you don't provide this value, the region is inferred from your Google Maps JavaScript API localization settings
. 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 constants
google.maps.routes
. ComputeRoutesExtraComputation
constants
Extra computations to perform for a Route.computeRoutes
request.
Access by calling const {ComputeRoutesExtraComputation} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
FLYOVER_INFO_ON_POLYLINE
|
Flyover information for the route(s). The "polylineDetails"
field must be specified in ComputeRoutesRequest.fields
to return this information. This data will only currently be populated for certain metros in India. This feature is experimental, and the SKU/charge is subject to change. |
FUEL_CONSUMPTION
|
Estimated fuel consumption for the route(s). |
HTML_FORMATTED_NAVIGATION_INSTRUCTIONS
|
Navigation instructions presented as a formatted HTML text string. This content is meant to be read as-is and is for display only. Do not programmatically parse it. |
NARROW_ROAD_INFO_ON_POLYLINE
|
Narrow road information for the route(s). The "polylineDetails"
field must be specified in ComputeRoutesRequest.fields
to return this information. This data will only currently be populated for certain metros in India. This feature is experimental, and the SKU/charge is subject to change. |
TOLLS
|
Toll information for the route(s). |
TRAFFIC_ON_POLYLINE
|
Traffic aware polylines for the route(s). |
DirectionalLocationLiteral interface
google.maps.routes
. DirectionalLocationLiteral
interface
Object literals are accepted in place of DirectionalLocation
instances as a convenience. These are converted to DirectionalLocation
when the Maps JS API encounters them.
This interface extends LatLngAltitudeLiteral
.
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
. |
Inherited:
altitude
, lat
, lng
|
DirectionalLocation class
google.maps.routes
. DirectionalLocation
class
Encapsulates a geographic point and an optional heading.
This class extends LatLngAltitude
.
This class implements DirectionalLocationLiteral
.
Access by calling const {DirectionalLocation} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constructor |
|
---|---|
Inherited:
LatLngAltitude
|
Properties |
|
---|---|
heading
|
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
. |
Inherited:
altitude
, lat
, lng
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
DirectionalLocationLiteral
Converts to an object.
|
Inherited:
equals
|
FallbackInfo class
google.maps.routes
. FallbackInfo
class
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.
Access by calling const {FallbackInfo} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
reason
|
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
|
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.
|
FallbackReason constants
google.maps.routes
. FallbackReason
constants
The reason that a fallback response was returned in a Route.computeRoutes
response.
Access by calling const {FallbackReason} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
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. |
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. |
FallbackRoutingMode constants
google.maps.routes
. FallbackRoutingMode
constants
The actual routing mode used when a fallback response is returned in a Route.computeRoutes
response.
Access by calling const {FallbackRoutingMode} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
TRAFFIC_AWARE
|
Indicates the TRAFFIC_AWARE
RoutingPreference
was used to compute the response. |
TRAFFIC_UNAWARE
|
Indicates the TRAFFIC_UNAWARE
RoutingPreference
was used to compute the response. |
GeocodedWaypoint class
google.maps.routes
. GeocodedWaypoint
class
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.
Access by calling const {GeocodedWaypoint} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
geocoderStatus
|
Type:
RPCStatus
optional
Indicates the status code resulting from the geocoding operation.
|
intermediateWaypointRequestIndex
|
Type:
number optional
The index of the corresponding intermediate waypoint in the request. Only populated if the corresponding waypoint is an intermediate waypoint.
|
partialMatch
|
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
|
Type:
string
The place ID for this result.
|
types
|
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 |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
GeocodingResults class
google.maps.routes
. GeocodingResults
class
Contains GeocodedWaypoint
s for origin, destination, and intermediate waypoints. Only populated for address waypoints.
Access by calling const {GeocodingResults} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
destination
|
Type:
GeocodedWaypoint
optional
The geocoded waypoint for the destination.
|
intermediates
|
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
|
Type:
GeocodedWaypoint
optional
The geocoded waypoint for the origin.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
MultiModalSegment class
google.maps.routes
. MultiModalSegment
class
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
.
Access by calling const {MultiModalSegment} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
instructions
|
Type:
string optional
Instructions for navigating this multi-modal segment.
|
maneuver
|
Type:
string optional
|
stepEndIndex
|
Type:
number
|
stepStartIndex
|
Type:
number
|
travelMode
|
Type:
TravelMode
optional
The travel mode used for this multi-modal segment.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
PolylineDetailInfo class
google.maps.routes
. PolylineDetailInfo
class
Encapsulates information about a road feature along a stretch of polyline.
Access by calling const {PolylineDetailInfo} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
endIndex
|
Type:
number optional
The end index of this road feature in the polyline.
|
presence
|
Type:
RoadFeatureState
optional
Denotes whether the road feature exists along the polyline.
|
startIndex
|
Type:
number optional
The start index of this road feature in the polyline.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
PolylineDetails class
google.maps.routes
. PolylineDetails
class
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.
Access by calling const {PolylineDetails} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
flyoverInfo
|
Type:
Array
< PolylineDetailInfo
>
Flyover details along the polyline.
|
narrowRoadInfo
|
Type:
Array
< PolylineDetailInfo
>
Narrow road details along the polyline.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
PolylineQuality constants
google.maps.routes
. PolylineQuality
constants
Specifies the quality of the polyline.
Access by calling const {PolylineQuality} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
HIGH_QUALITY
|
Specifies a high-quality polyline that is composed using more points than OVERVIEW
at the cost of increased response size. Use this value when you need more precision. |
OVERVIEW
|
Specifies an overview polyline that is composed using a small number of points. Using this option has a lower request latency compared to HIGH_QUALITY
. Use this value when displaying an overview of the route. |
ReferenceRoute constants
google.maps.routes
. ReferenceRoute
constants
A supported reference route on a ComputeRoutesRequest
.
Access by calling const {ReferenceRoute} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
FUEL_EFFICIENT
|
Fuel efficient route. |
SHORTER_DISTANCE
|
Route with shorter travel distance. |
RoadFeatureState constants
google.maps.routes
. RoadFeatureState
constants
Encapsulates the states of road features along a stretch of polyline.
Access by calling const {RoadFeatureState} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
DOES_NOT_EXIST
|
The road feature does not exist. |
EXISTS
|
The road feature exists. |
RouteLabel constants
google.maps.routes
. RouteLabel
constants
Labels for the route that are useful to identify specific properties to compare against others.
Access by calling const {RouteLabel} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
DEFAULT_ROUTE
|
The default "best" route returned for the route computation. |
DEFAULT_ROUTE_ALTERNATE
|
An alternative to the default "best" route. Routes like this will be returned when ComputeRoutesRequest.computeAlternativeRoutes
is specified. |
FUEL_EFFICIENT
|
Fuel efficient route. Routes labeled with this value are determined to be optimized for eco parameters such as fuel consumption. |
SHORTER_DISTANCE
|
Shorter travel distance route. This is an experimental feature. |
RouteLeg class
google.maps.routes
. RouteLeg
class
Contains a segment between non- via
waypoints.
Access by calling const {RouteLeg} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
distanceMeters
|
Type:
number
The travel distance of the route leg, in meters.
|
durationMillis
|
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
|
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
|
Type:
RouteLegLocalizedValues
optional
Text representations of properties of the
RouteLeg
. |
path
|
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
|
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
|
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
|
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
|
Type:
Array
< RouteLegStep
>
An array of steps denoting segments within this leg. Each step represents one navigation instruction.
|
stepsOverview
|
Type:
StepsOverview
optional
Overview information about the steps in this
RouteLeg
. This field is only populated for TRANSIT
routes. |
travelAdvisory
|
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 |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
RouteLegLocalizedValues class
google.maps.routes
. RouteLegLocalizedValues
class
Text representations of the RouteLeg
.
Access by calling const {RouteLegLocalizedValues} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
distance
|
Type:
string optional
Travel distance of the route leg in text form.
|
distanceLanguage
|
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
|
Type:
string optional
Duration, represented in text form and localized to the region of the query. Takes traffic conditions into consideration.
|
durationLanguage
|
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
|
Type:
string optional
Duration without taking traffic conditions into consideration, represented in text form.
|
staticDurationLanguage
|
Type:
string optional
The static duration text's BCP-47 language code, such as "en-US" or "sr-Latn".
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
RouteLegStep class
google.maps.routes
. RouteLegStep
class
Contains a segment of a RouteLeg
. A step corresponds to a single navigation instruction. Route legs are made up of steps.
Access by calling const {RouteLegStep} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
distanceMeters
|
Type:
number
The travel distance of this step, in meters.
|
endLocation
|
Type:
DirectionalLocation
optional
The end location of this step.
|
instructions
|
Type:
string optional
Instructions for navigating this step.
|
localizedValues
|
Type:
RouteLegStepLocalizedValues
optional
Text representations of properties of the
RouteLegStep
. |
maneuver
|
Type:
string optional
|
path
|
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
|
Type:
DirectionalLocation
optional
The start location of this step.
|
staticDurationMillis
|
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
|
Type:
TransitDetails
optional
Details pertaining to this step if the travel mode is
TRANSIT
. |
travelMode
|
Type:
TravelMode
optional
The travel mode used for this step.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
RouteLegStepLocalizedValues class
google.maps.routes
. RouteLegStepLocalizedValues
class
Text representations of properties of the RouteLegStep
.
Access by calling const {RouteLegStepLocalizedValues} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
distance
|
Type:
string optional
Travel distance of the route leg step in text form.
|
distanceLanguage
|
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
|
Type:
string optional
Duration without taking traffic conditions into consideration, represented in text form.
|
staticDurationLanguage
|
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 |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
RouteLegTravelAdvisory class
google.maps.routes
. RouteLegTravelAdvisory
class
Contains additional information that the user should be informed about on a RouteLeg
.
Access by calling const {RouteLegTravelAdvisory} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
speedReadingIntervals
|
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:
|
tollInfo
|
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 |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
RouteLocalizedValues class
google.maps.routes
. RouteLocalizedValues
class
Text representations of properties of the Route
.
Access by calling const {RouteLocalizedValues} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
distance
|
Type:
string optional
Travel distance of the route represented in text form.
|
distanceLanguage
|
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
|
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
|
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
|
Type:
string optional
Duration without taking traffic conditions into consideration, represented in text form.
|
staticDurationLanguage
|
Type:
string optional
The static duration text's BCP-47 language code, such as "en-US" or "sr-Latn".
|
transitFare
|
Type:
string optional
Transit fare represented in text form.
|
transitFareLanguage
|
Type:
string optional
The transit fare text's BCP-47 language code, such as "en-US" or "sr-Latn".
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
RouteModifiers interface
google.maps.routes
. RouteModifiers
interface
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
for a list of valid values. |
vehicleInfo
optional
|
Type:
VehicleInfo
optional
Specifies the vehicle information.
|
RoutePolylineDetails interface
google.maps.routes
. RoutePolylineDetails
interface
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 interface
google.maps.routes
. RoutePolylineOptions
interface
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 class
google.maps.routes
. RouteTravelAdvisory
class
Contains additional information that the user should be informed about on a Route
.
Access by calling const {RouteTravelAdvisory} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
fuelConsumptionMicroliters
|
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
|
Type:
boolean optional
The
Route
may have restrictions that are not suitable for the requested travel mode or route modifiers. |
speedReadingIntervals
|
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:
|
tollInfo
|
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
|
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 |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
RoutingPreference constants
google.maps.routes
. RoutingPreference
constants
Factors to take into consideration when calculating a route.
Access by calling const {RoutingPreference} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
TRAFFIC_AWARE
|
Calculates routes taking live traffic conditions into consideration. In contrast to TRAFFIC_AWARE_OPTIMAL
, some optimizations are applied to significantly reduce latency. |
TRAFFIC_AWARE_OPTIMAL
|
Calculates the routes taking live traffic conditions into consideration, without applying most performance optimizations. Using this value produces the highest latency. |
TRAFFIC_UNAWARE
|
Computes routes without taking live traffic conditions into consideration. Suitable when traffic conditions don't matter or are not applicable. Using this value produces the lowest latency. |
Speed constants
google.maps.routes
. Speed
constants
The classification of polyline speed based on traffic data.
Access by calling const {Speed} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
NORMAL
|
Normal speed, no traffic delays. |
SLOW
|
Slowdown detected, medium amount of traffic. |
TRAFFIC_JAM
|
Traffic delays. |
SpeedPath interface
google.maps.routes
. SpeedPath
interface
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 class
google.maps.routes
. SpeedReadingInterval
class
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.
Access by calling const {SpeedReadingInterval} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
endPolylinePointIndex
|
Type:
number optional
The ending index of this interval in the polyline.
|
speed
|
Type:
Speed
optional
Traffic speed in this interval.
|
startPolylinePointIndex
|
Type:
number optional
The starting index of this interval in the polyline.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value: None
Converts to an object.
|
StepsOverview class
google.maps.routes
. StepsOverview
class
Provides overview information about a list of RouteLeg.steps
.
Access by calling const {StepsOverview} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
multiModalSegments
|
Type:
Array
< MultiModalSegment
>
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
TollInfo class
google.maps.routes
. TollInfo
class
Encapsulates toll information on a Route
or RouteLeg
.
Access by calling const {TollInfo} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
estimatedPrices
|
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. |
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
TransitAgency class
google.maps.routes
. TransitAgency
class
Information about a transit agency.
Access by calling const {TransitAgency} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
name
|
Type:
string optional
The name of this transit agency.
|
phoneNumber
|
Type:
string optional
The transit agency's locale-specific formatted phone number.
|
url
|
Type:
URL
optional
The transit agency's URL.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
TransitDetails class
google.maps.routes
. TransitDetails
class
Additional information about a transit step in a route.
Access by calling const {TransitDetails} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
arrivalStop
|
Type:
TransitStop
optional
Information about the arrival stop for the step.
|
arrivalTime
|
Type:
Date
optional
The estimated time of arrival for the step.
|
departureStop
|
Type:
TransitStop
optional
Information about the departure stop for the step.
|
departureTime
|
Type:
Date
optional
The estimated time of departure for the step.
|
headsign
|
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
|
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
|
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
|
Type:
TransitLine
optional
Information about the transit line used in the step.
|
tripShortText
|
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 |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
TransitLine class
google.maps.routes
. TransitLine
class
Information about a transit line.
Access by calling const {TransitLine} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
agencies
|
Type:
Array
< TransitAgency
>
The transit agency (or agencies) that operates this transit line.
|
color
|
Type:
string optional
The color commonly used in signage for this line. Represented in hexadecimal.
|
iconURL
|
Type:
URL
optional
The URL for the icon associated with this line.
|
name
|
Type:
string optional
The full name of this transit line, For example, "8 Avenue Local".
|
shortName
|
Type:
string optional
The short name of this transit line. This name will normally be a line number, such as "M7" or "355".
|
textColor
|
Type:
string optional
The color commonly used in text on signage for this line. Represented in hexadecimal.
|
url
|
Type:
URL
optional
The URL for this transit line as provided by the transit agency.
|
vehicle
|
Type:
TransitVehicle
optional
The type of vehicle that operates on this transit line.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
TransitPreference interface
google.maps.routes
. TransitPreference
interface
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 class
google.maps.routes
. TransitStop
class
Information about a transit stop.
Access by calling const {TransitStop} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
location
|
Type:
DirectionalLocation
optional
The location of the stop expressed in latitude/longitude coordinates and an optional heading.
|
name
|
Type:
string optional
The name of the transit stop.
|
Methods |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
TransitVehicle class
google.maps.routes
. TransitVehicle
class
Information about a vehicle used in transit routes.
Access by calling const {TransitVehicle} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Properties |
|
---|---|
iconURL
|
Type:
URL
optional
The URL for an icon associated with this vehicle type.
|
localIconURL
|
Type:
URL
optional
The URL for the icon associated with this vehicle type, based on the local transport signage.
|
name
|
Type:
string optional
The name of this vehicle, capitalized.
|
nameLanguage
|
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
|
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 |
|
---|---|
toJSON
|
toJSON()
Parameters: None
Return Value:
Object
Converts to an object.
|
VehicleEmissionType constants
google.maps.routes
. VehicleEmissionType
constants
A set of values describing the vehicle's emission type. Applies only to the DRIVING
travel mode.
Access by calling const {VehicleEmissionType} = await google.maps.importLibrary("routes")
.See Libraries in the Maps JavaScript API
.
Constants |
|
---|---|
DIESEL
|
Diesel fueled vehicle. |
ELECTRIC
|
Electricity powered vehicle. |
GASOLINE
|
Gasoline/petrol fueled vehicle. |
HYBRID
|
Hybrid fuel (such as gasoline + electric) vehicle. |
VehicleInfo interface
google.maps.routes
. VehicleInfo
interface
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 interface
google.maps.routes
. Waypoint
interface
Represents a waypoint in a route.
Properties
string| LatLng
| LatLngLiteral
| LatLngAltitudeLiteral
| DirectionalLocationLiteral
| Place
sideOfRoad
optional
boolean optional
DRIVING
and TWO_WHEELER
ComputeRoutesRequest.travelMode
vehicleStopover
optional
boolean optional
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
boolean optional
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 totrue
, this field cannot be set to true; otherwise, the request fails.
WaypointMarkerDetails interface
google.maps.routes
. WaypointMarkerDetails
interface
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.
|