Introducing Places UI Kit: A ready-to-use, low-cost component library that lets you bring the familiar Google Maps UI for Places to any map of your choice. Try it out, andshare your input to help shape the future of GMP!

Directions

DirectionsServiceclass

google.maps.DirectionsServiceclass

A service for computing directions between two or more places.

Access by callingconst {DirectionsService} = await google.maps.importLibrary("routes").
SeeLibraries in the Maps JavaScript API.

Constructor

DirectionsService
DirectionsService()
Parameters:  None
Creates a new instance of aDirectionsService that sends directions queries to Google servers.

Methods

route
route(request[, callback])
Parameters: 
Return Value: Promise<DirectionsResult>
Issue a directions search request.

DirectionsRequestinterface

google.maps.DirectionsRequestinterface

A directions query to be sent to theDirectionsService.

Properties

destination
Type: string|LatLng|Place|LatLngLiteral
Location of destination. This can be specified as either a string to be geocoded, or aLatLng, or aPlace. Required.
origin
Type: string|LatLng|Place|LatLngLiteral
Location of origin. This can be specified as either a string to be geocoded, or aLatLng, or aPlace. Required.
travelMode
Type: TravelMode
Type of routing requested. Required.
avoidFerriesoptional
Type: booleanoptional
Iftrue, instructs the Directions service to avoid ferries where possible. Optional.
avoidHighwaysoptional
Type: booleanoptional
Iftrue, instructs the Directions service to avoid highways where possible. Optional.
avoidTollsoptional
Type: booleanoptional
Iftrue, instructs the Directions service to avoid toll roads where possible. Optional.
drivingOptionsoptional
Type: DrivingOptionsoptional
Settings that apply only to requests wheretravelMode isDRIVING. This object will have no effect for other travel modes.
languageoptional
Type: stringoptional
A language identifier for the language in which results should be returned, when possible. See thelist of supported languages.
optimizeWaypointsoptional
Type: booleanoptional
If set totrue, theDirectionsService will attempt to re-order the supplied intermediate waypoints to minimize overall cost of the route. If waypoints are optimized, inspectDirectionsRoute.waypoint_order in the response to determine the new ordering.
provideRouteAlternativesoptional
Type: booleanoptional
Whether or not route alternatives should be provided. Optional.
regionoptional
Type: stringoptional
Region code used as a bias for geocoding requests. The region code accepts accTLD ("top-level domain") two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom's ccTLD is "uk" (.co.uk) while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland").
transitOptionsoptional
Type: TransitOptionsoptional
Settings that apply only to requests wheretravelMode is TRANSIT. This object will have no effect for other travel modes.
unitSystemoptional
Type: UnitSystemoptional
Default: The unit system used in the country of origin.
Preferred unit system to use when displaying distance.
waypointsoptional
Type: Array<DirectionsWaypoint>optional
Array of intermediate waypoints. Directions are calculated from the origin to the destination by way of each waypoint in this array. See the developer's guide for the maximum number of waypoints allowed. Waypoints are not supported for transit directions. Optional.

DirectionsStatusconstants

google.maps.DirectionsStatusconstants

The status returned by theDirectionsService on the completion of a call toroute(). Specify these by value, or by using the constant's name. For example,'OK' orgoogle.maps.DirectionsStatus.OK.

Access by callingconst {DirectionsStatus} = await google.maps.importLibrary("routes").
SeeLibraries in the Maps JavaScript API.

Constants

INVALID_REQUESTTheDirectionsRequest provided was invalid.
MAX_WAYPOINTS_EXCEEDEDToo manyDirectionsWaypoints were provided in theDirectionsRequest. See the developer's guide for the maximum number of waypoints allowed.
NOT_FOUNDAt least one of the origin, destination, or waypoints could not be geocoded.
OKThe response contains a validDirectionsResult.
OVER_QUERY_LIMITThe webpage has gone over the requests limit in too short a period of time.
REQUEST_DENIEDThe webpage is not allowed to use the directions service.
UNKNOWN_ERRORA directions request could not be processed due to a server error. The request may succeed if you try again.
ZERO_RESULTSNo route could be found between the origin and destination.

DirectionsResultinterface

google.maps.DirectionsResultinterface

The directions response retrieved from the directions server. You can render these using aDirectionsRenderer or parse this object and render it yourself. You must display the warnings and copyrights as noted in theGoogle Maps Platform Terms of Service. Note that though this result is "JSON-like," it is not strictly JSON, as it indirectly includesLatLng objects.

Properties

request
The DirectionsRequest that yielded this result.
routes
An array ofDirectionsRoutes, each of which contains information about the legs and steps of which it is composed. There will only be one route unless theDirectionsRequest was made withprovideRouteAlternatives set totrue.
available_travel_modesoptional
Type: Array<TravelMode>optional
Contains an array of available travel modes. This field is returned when a request specifies a travel mode and gets no results. The array contains the available travel modes in the countries of the given set of waypoints. This field is not returned if one or more of the waypoints are 'via waypoints'.
geocoded_waypointsoptional
An array ofDirectionsGeocodedWaypoints, each of which contains information about the geocoding of origin, destination and waypoints.

DirectionsRendererclass

google.maps.DirectionsRendererclass

Renders directions obtained from theDirectionsService.

This class extendsMVCObject.

Access by callingconst {DirectionsRenderer} = await google.maps.importLibrary("routes").
SeeLibraries in the Maps JavaScript API.

Constructor

DirectionsRenderer
DirectionsRenderer([opts])
Parameters: 
Creates the renderer with the given options. Directions can be rendered on a map (as visual overlays) or additionally on a<div> panel (as textual instructions).

Methods

getDirections
getDirections()
Parameters:  None
Return Value: DirectionsResult
Returns the renderer's current set of directions.
getMap
getMap()
Parameters:  None
Return Value: Map
Returns the map on which theDirectionsResult is rendered.
getPanel
getPanel()
Parameters:  None
Return Value: HTMLElement|null
Returns the panel<div> in which theDirectionsResult is rendered.
getRouteIndex
getRouteIndex()
Parameters:  None
Return Value: number
Returns the current (zero-based) route index in use by thisDirectionsRenderer object.
setDirections
setDirections(directions)
Parameters: 
Return Value:  None
Set the renderer to use the result from theDirectionsService. Setting a valid set of directions in this manner will display the directions on the renderer's designated map and panel.
setMap
setMap(map)
Parameters: 
Return Value:  None
This method specifies the map on which directions will be rendered. Passnull to remove the directions from the map.
setOptions
setOptions(options)
Parameters: 
Return Value:  None
Change the options settings of thisDirectionsRenderer after initialization.
setPanel
setPanel(panel)
Parameters: 
Return Value:  None
This method renders the directions in a<div>. Passnull to remove the content from the panel.
setRouteIndex
setRouteIndex(routeIndex)
Parameters: 
  • routeIndexnumber
Return Value:  None
Set the (zero-based) index of the route in theDirectionsResult object to render. By default, the first route in the array will be rendered.
Inherited:addListener,bindTo,get,notify,set,setValues,unbind,unbindAll

Events

directions_changed
function()
Arguments:  None
This event is fired when the rendered directions change, either when a newDirectionsResult is set or when the user finishes dragging a change to the directions path.

DirectionsRendererOptionsinterface

google.maps.DirectionsRendererOptionsinterface

This object defines the properties that can be set on aDirectionsRenderer object.

Properties

directionsoptional
Type: DirectionsResultoptional
The directions to display on the map and/or in a<div> panel, retrieved as aDirectionsResult object fromDirectionsService.
draggableoptional
Type: booleanoptional
Iftrue, allows the user to drag and modify the paths of routes rendered by thisDirectionsRenderer.
hideRouteListoptional
Type: booleanoptional
Default:false
This property indicates whether the renderer should provide a user-selectable list of routes shown in the directions panel.
infoWindowoptional
Type: InfoWindowoptional
TheInfoWindow in which to render text information when a marker is clicked. Existing info window content will be overwritten and its position moved. If no info window is specified, theDirectionsRenderer will create and use its own info window. This property will be ignored ifsuppressInfoWindows is set totrue.
mapoptional
Type: Mapoptional
Map on which to display the directions.
markerOptionsoptional
Type: MarkerOptionsoptional
Options for the markers. All markers rendered by theDirectionsRenderer will use these options.
paneloptional
Type: HTMLElementoptional
The<div> in which to display the directions steps.
polylineOptionsoptional
Type: PolylineOptionsoptional
Options for the polylines. All polylines rendered by theDirectionsRenderer will use these options.
preserveViewportoptional
Type: booleanoptional
Default:false
If this option is set totrue or the map's center and zoom were never set, the input map is centered and zoomed to the bounding box of this set of directions.
routeIndexoptional
Type: numberoptional
The index of the route within theDirectionsResult object. The default value is 0.
suppressBicyclingLayeroptional
Type: booleanoptional
Suppress the rendering of theBicyclingLayer when bicycling directions are requested.
suppressInfoWindowsoptional
Type: booleanoptional
Suppress the rendering of info windows.
suppressMarkersoptional
Type: booleanoptional
Suppress the rendering of markers.
suppressPolylinesoptional
Type: booleanoptional
Suppress the rendering of polylines.

DirectionsWaypointinterface

google.maps.DirectionsWaypointinterface

ADirectionsWaypoint represents a location between origin and destination through which the trip should be routed.

Properties

locationoptional
Type: string|LatLng|LatLngLiteral|Placeoptional
Waypoint location. Can be an address string, aLatLng, or aPlace. Optional.
stopoveroptional
Type: booleanoptional
Default:true
Iftrue, indicates that this waypoint is a stop between the origin and destination. This has the effect of splitting the route into two legs. Iffalse, indicates that the route should be biased to go through this waypoint, but not split into two legs. This is useful if you want to create a route in response to the user dragging waypoints on a map.

DirectionsGeocodedWaypointinterface

google.maps.DirectionsGeocodedWaypointinterface

A single geocoded waypoint.

Properties

partial_matchoptional
Type: booleanoptional
Whether the geocoder did not return an exact match for the original waypoint, though it was able to match part of the requested address.
place_idoptional
Type: stringoptional
The place ID associated with the waypoint. Place IDs uniquely identify a place in the Google Places database and on Google Maps. Learn more aboutPlace IDs in the Places API developer guide.
typesoptional
Type: Array<string>optional
An array of strings denoting the type of the returned geocoded element. For a list of possible strings, refer to the Address Component Types section of the Developer's Guide.

DirectionsRouteinterface

google.maps.DirectionsRouteinterface

A single route containing a set of legs in aDirectionsResult. Note that though this object is "JSON-like," it is not strictly JSON, as it directly and indirectly includesLatLng objects.

Properties

bounds
The bounds for this route.
copyrights
Type: string
Copyrights text to be displayed for this route.
legs
An array ofDirectionsLegs, each of which contains information about the steps of which it is composed. There will be one leg for each stopover waypoint or destination specified. So a route with no stopover waypoints will contain oneDirectionsLeg and a route with one stopover waypoint will contain two.
overview_path
Type: Array<LatLng>
An array ofLatLngs representing the entire course of this route. The path is simplified in order to make it suitable in contexts where a small number of vertices is required (such as Static Maps API URLs).
overview_polyline
Type: string
Anencoded polyline representation of the route in overview_path. This polyline is an approximate (smoothed) path of the resulting directions.
summary
Type: string
Contains a short textual description for the route, suitable for naming and disambiguating the route from alternatives.
warnings
Type: Array<string>
Warnings to be displayed when showing these directions.
waypoint_order
Type: Array<number>
IfoptimizeWaypoints was set totrue, this field will contain the re-ordered permutation of the input waypoints. For example, if the input was:
  Origin: Los Angeles
  Waypoints: Dallas, Bangor, Phoenix
  Destination: New York
and the optimized output was ordered as follows:
  Origin: Los Angeles
  Waypoints: Phoenix, Dallas, Bangor
  Destination: New York
then this field will be anArray containing the values [2, 0, 1]. Note that the numbering of waypoints is zero-based.
If any of the input waypoints hasstopover set tofalse, this field will be empty, since route optimization is not available for such queries.
fareoptional
Type: TransitFareoptional
The total fare for the whole transit trip. Only applicable to transit requests.

DirectionsLeginterface

google.maps.DirectionsLeginterface

A single leg consisting of a set of steps in aDirectionsResult. Some fields in the leg may not be returned for all requests. Note that though this result is "JSON-like," it is not strictly JSON, as it directly and indirectly includesLatLng objects.

Properties

end_address
Type: string
The address of the destination of this leg. This content is meant to be read as-is. Do not programmatically parse the formatted address.
end_location
Type: LatLng
TheDirectionsService calculates directions between locations by using the nearest transportation option (usually a road) at the start and end locations.end_location indicates the actual geocoded destination, which may be different than theend_location of the last step if, for example, the road is not near the destination of this leg.
start_address
Type: string
The address of the origin of this leg. This content is meant to be read as-is. Do not programmatically parse the formatted address.
start_location
Type: LatLng
TheDirectionsService calculates directions between locations by using the nearest transportation option (usually a road) at the start and end locations.start_location indicates the actual geocoded origin, which may be different than thestart_location of the first step if, for example, the road is not near the origin of this leg.
steps
An array ofDirectionsSteps, each of which contains information about the individual steps in this leg.
traffic_speed_entry

Deprecated: This array will always be empty.

Type: Array<*>
Information about traffic speed along the leg.
via_waypoints
Type: Array<LatLng>
An array of non-stopover waypoints along this leg, which were specified in the original request.

Deprecated in alternative routes. Version 3.27 will be the last version of the API that adds extravia_waypoints in alternative routes.

When using the Directions Service to implement draggable directions, it is recommended to disable dragging of alternative routes. Only the main route should be draggable. Users can drag the main route until it matches an alternative route.

arrival_timeoptional
Type: Timeoptional
An estimated arrival time for this leg. Only applicable for TRANSIT requests.
departure_timeoptional
Type: Timeoptional
An estimated departure time for this leg. Only applicable for TRANSIT requests.
distanceoptional
Type: Distanceoptional
The total distance covered by this leg. This property may be undefined as the distance may be unknown.
durationoptional
Type: Durationoptional
The total duration of this leg. This property may beundefined as the duration may be unknown.
duration_in_trafficoptional
Type: Durationoptional
The total duration of this leg, taking into account the traffic conditions indicated by thetrafficModel property. This property may beundefined as the duration may be unknown.

DirectionsStepinterface

google.maps.DirectionsStepinterface

A singleDirectionsStep in aDirectionsResult. Some fields may beundefined. Note that though this object is "JSON-like," it is not strictly JSON, as it directly includesLatLng objects.

Properties

encoded_lat_lngs
Type: string
Anencoded polyline representation of the step. This is an approximate (smoothed) path of the step.
end_location
Type: LatLng
The ending location of this step.
end_point

Deprecated: Please useDirectionsStep.end_location.

Type: LatLng
The ending location of this step.
instructions
Type: string
Instructions for this step.
lat_lngs

Deprecated: Please useDirectionsStep.path.

Type: Array<LatLng>
A sequence ofLatLngs describing the course of this step. This is an approximate (smoothed) path of the step.
maneuver
Type: string
Contains the action to take for the current step (turn-left,merge,straight, etc.). Values are subject to change, and new values may be introduced without prior notice.
path
Type: Array<LatLng>
A sequence ofLatLngs describing the course of this step. This is an approximate (smoothed) path of the step.
start_location
Type: LatLng
The starting location of this step.
start_point

Deprecated: Please useDirectionsStep.start_location.

Type: LatLng
The starting location of this step.
travel_mode
Type: TravelMode
The mode of travel used in this step.
distanceoptional
Type: Distanceoptional
The distance covered by this step. This property may beundefined as the distance may be unknown.
durationoptional
Type: Durationoptional
The typical time required to perform this step in seconds and in text form. This property may beundefined as the duration may be unknown.
polylineoptional

Deprecated: Please useDirectionsStep.encoded_lat_lngs.

Type: DirectionsPolylineoptional
Contains an object with a single property, 'points', that holds anencoded polyline representation of the step. This polyline is an approximate (smoothed) path of the step.
stepsoptional
Type: Array<DirectionsStep>optional
Sub-steps of this step. Specified for non-transit sections of transit routes.
transitoptional
Type: TransitDetailsoptional
Transit-specific details about this step. This property will be undefined unless the travel mode of this step isTRANSIT.
transit_detailsoptional
Type: TransitDetailsoptional
Details pertaining to this step if the travel mode isTRANSIT.

DirectionsPolylineinterface

google.maps.DirectionsPolylineinterface

An object containing apoints property to describe the polyline of aDirectionsStep.

Properties

points
Type: string

Placeinterface

google.maps.Placeinterface

Contains information needed to locate, identify, or describe a place for aDirectionsRequest orDistanceMatrixRequest. In this context, "place" means a business, point of interest, or geographic location. For fetching information about a place, seePlacesService.

Properties

locationoptional
Type: LatLng|LatLngLiteraloptional
TheLatLng of the entity described by this place.
placeIdoptional
Type: stringoptional
The place ID of the place (such as a business or point of interest). The place ID is a unique identifier of a place in the Google Maps database. Note that theplaceId is the most accurate way of identifying a place. If possible, you should specify theplaceId rather than aquery. A place ID can be retrieved from any request to the Places API, such as aTextSearch. Place IDs can also be retrieved from requests to the Geocoding API. For more information, see theoverview of place IDs.
queryoptional
Type: stringoptional
A search query describing the place (such as a business or point of interest). An example query is "Quay, Upper Level, Overseas Passenger Terminal 5 Hickson Road, The Rocks NSW". If possible, you should specify theplaceId rather than aquery. The API does not guarantee the accuracy of resolving the query string to a place. If both theplaceId andquery are provided, an error occurs.

TravelModeconstants

google.maps.TravelModeconstants

The valid travel modes that can be specified in aDirectionsRequest as well as the travel modes returned in aDirectionsStep. Specify these by value, or by using the constant's name. For example,'BICYCLING' orgoogle.maps.TravelMode.BICYCLING.

Access by callingconst {TravelMode} = await google.maps.importLibrary("routes").
SeeLibraries in the Maps JavaScript API.

Constants

BICYCLINGSpecifies a bicycling directions request.
DRIVINGSpecifies a driving directions request.
TRANSITSpecifies a transit directions request.
WALKINGSpecifies a walking directions request.

DrivingOptionsinterface

google.maps.DrivingOptionsinterface

Configures theDirectionsRequest when the travel mode is set toDRIVING.

Properties

departureTime
Type: Date
The desired departure time for the route, specified as aDate object. TheDate object measures time in milliseconds since 1 January 1970. This must be specified for aDrivingOptions to be valid. The departure time must be set to the current time or some time in the future. It cannot be in the past.
trafficModeloptional
Type: TrafficModeloptional
The preferred assumption to use when predicting duration in traffic. The default isBEST_GUESS.

TrafficModelconstants

google.maps.TrafficModelconstants

The assumptions to use when predicting duration in traffic. Specified as part of aDirectionsRequest orDistanceMatrixRequest. Specify these by value, or by using the constant's name. For example,'bestguess' orgoogle.maps.TrafficModel.BEST_GUESS.

Access by callingconst {TrafficModel} = await google.maps.importLibrary("routes").
SeeLibraries in the Maps JavaScript API.

Constants

BEST_GUESSUse historical traffic data to best estimate the time spent in traffic.
OPTIMISTICUse historical traffic data to make an optimistic estimate of what the duration in traffic will be.
PESSIMISTICUse historical traffic data to make a pessimistic estimate of what the duration in traffic will be.

TransitOptionsinterface

google.maps.TransitOptionsinterface

The TransitOptions object to be included in aDirectionsRequest when the travel mode is set to TRANSIT.

Properties

arrivalTimeoptional
Type: Dateoptional
The desired arrival time for the route, specified as a Date object. The Date object measures time in milliseconds since 1 January 1970. If arrival time is specified, departure time is ignored.
departureTimeoptional
Type: Dateoptional
The desired departure time for the route, specified as a Date object. The Date object measures time in milliseconds since 1 January 1970. If neither departure time nor arrival time is specified, the time is assumed to be "now".
modesoptional
Type: Array<TransitMode>optional
One or more preferred modes of transit, such as bus or train. If no preference is given, the API returns the default best route.
routingPreferenceoptional
Type: TransitRoutePreferenceoptional
A preference that can bias the choice of transit route, such as less walking. If no preference is given, the API returns the default best route.

TransitModeconstants

google.maps.TransitModeconstants

The valid transit mode e.g. bus that can be specified in aTransitOptions. Specify these by value, or by using the constant's name. For example,'BUS' orgoogle.maps.TransitMode.BUS.

Access by callingconst {TransitMode} = await google.maps.importLibrary("routes").
SeeLibraries in the Maps JavaScript API.

Constants

BUSSpecifies bus as a preferred mode of transit.
RAILSpecifies rail as a preferred mode of transit.
SUBWAYSpecifies subway as a preferred mode of transit.
TRAINSpecifies train as a preferred mode of transit.
TRAMSpecifies tram as a preferred mode of transit.

TransitRoutePreferenceconstants

google.maps.TransitRoutePreferenceconstants

The valid transit route type that can be specified in aTransitOptions. Specify these by value, or by using the constant's name. For example,'LESS_WALKING' orgoogle.maps.TransitRoutePreference.LESS_WALKING.

Access by callingconst {TransitRoutePreference} = await google.maps.importLibrary("routes").
SeeLibraries in the Maps JavaScript API.

Constants

FEWER_TRANSFERSSpecifies that the calculated route should prefer a limited number of transfers.
LESS_WALKINGSpecifies that the calculated route should prefer limited amounts of walking.

TransitFareinterface

google.maps.TransitFareinterface

A fare of aDirectionsRoute consisting of value and currency.

Properties

currency
Type: string
AnISO 4217 currency code indicating the currency in which the fare is expressed.
text
Type: string
The value of the fare, expressed in the givencurrency, as a string.
value
Type: number
The numerical value of the fare, expressed in the givencurrency.

TransitDetailsinterface

google.maps.TransitDetailsinterface

Details about the departure, arrival, and mode of transit used in this step.

Properties

arrival_stop
The arrival stop of this transit step.
arrival_time
Type: Time
The arrival time of this step, specified as a Time object.
departure_stop
The departure stop of this transit step.
departure_time
Type: Time
The departure time of this step, specified as a Time object.
headsign
Type: string
The direction in which to travel on this line, as it is marked on the vehicle or at the departure stop.
headway
Type: number
The expected number of seconds between equivalent vehicles at this stop.
line
Details about the transit line used in this step.
num_stops
Type: number
The number of stops on this step. Includes the arrival stop, but not the departure stop.
trip_short_name
Type: string
The text that appears in schedules and sign boards to identify a transit trip to passengers, for example, to identify train numbers for commuter rail trips. The text uniquely identifies a trip within a service day.

TransitStopinterface

google.maps.TransitStopinterface

Details about a transit stop or station.

Properties

location
Type: LatLng
The location of this stop.
name
Type: string
The name of this transit stop.

TransitLineinterface

google.maps.TransitLineinterface

Information about the transit line that operates this transit step.

Properties

agencies
The transit agency that operates this transit line.
color
Type: string
The color commonly used in signage for this transit line, represented as a hex string.
icon
Type: string
The URL for an icon associated with this line.
name
Type: string
The full name of this transit line, e.g. "8 Avenue Local".
short_name
Type: string
The short name of this transit line, e.g. "E".
text_color
Type: string
The text color commonly used in signage for this transit line, represented as a hex string.
url
Type: string
The agency's URL which is specific to this transit line.
vehicle
The type of vehicle used, e.g. train or bus.

TransitAgencyinterface

google.maps.TransitAgencyinterface

Information about an agency that operates a transit line.

Properties

name
Type: string
The name of this transit agency.
phone
Type: string
The transit agency's phone number.
url
Type: string
The transit agency's URL.

TransitVehicleinterface

google.maps.TransitVehicleinterface

Information about the vehicle that operates on a transit line.

Properties

icon
Type: string
A URL for an icon that corresponds to the type of vehicle used on this line.
local_icon
Type: string
A URL for an icon that corresponds to the type of vehicle used in this region instead of the more general icon.
name
Type: string
A name for this type of TransitVehicle, e.g. "Train" or "Bus".
type
The type of vehicle used, e.g. train, bus, or ferry.

VehicleTypeconstants

google.maps.VehicleTypeconstants

Possible values for vehicle types.

Access by callingconst {VehicleType} = await google.maps.importLibrary("routes").
SeeLibraries in the Maps JavaScript API.

Constants

BUSBus.
CABLE_CARA vehicle that operates on a cable, usually on the ground. Aerial cable cars may be of the typeGONDOLA_LIFT.
COMMUTER_TRAINCommuter rail.
FERRYFerry.
FUNICULARA vehicle that is pulled up a steep incline by a cable.
GONDOLA_LIFTAn aerial cable car.
HEAVY_RAILHeavy rail.
HIGH_SPEED_TRAINHigh speed train.
INTERCITY_BUSIntercity bus.
METRO_RAILLight rail.
MONORAILMonorail.
OTHEROther vehicles.
RAILRail.
SHARE_TAXIShare taxi is a sort of bus transport with ability to drop off and pick up passengers anywhere on its route. Generally share taxi uses minibus vehicles.
SUBWAYUnderground light rail.
TRAMAbove ground light rail.
TROLLEYBUSTrolleybus.

UnitSystemconstants

google.maps.UnitSystemconstants

The valid unit systems that can be specified in aDirectionsRequest.

Access by callingconst {UnitSystem} = await google.maps.importLibrary("core").
SeeLibraries in the Maps JavaScript API.

Constants

IMPERIALSpecifies that distances in theDirectionsResult should be expressed in imperial units.
METRICSpecifies that distances in theDirectionsResult should be expressed in metric units.

Distanceinterface

google.maps.Distanceinterface

A representation of distance as a numeric value and a display string.

Properties

text
Type: string
A string representation of the distance value, using theUnitSystem specified in the request.
value
Type: number
The distance in meters.

Durationinterface

google.maps.Durationinterface

A representation of duration as a numeric value and a display string.

Properties

text
Type: string
A string representation of the duration value.
value
Type: number
The duration in seconds.

Timeinterface

google.maps.Timeinterface

A representation of time as a Date object, a localized string, and a time zone.

Properties

text
Type: string
A string representing the time's value. The time is displayed in the time zone of the transit stop.
time_zone
Type: string
The time zone in which this stop lies. The value is the name of the time zone as defined in the IANA Time Zone Database, e.g. "America/New_York".
value
Type: Date
The time of this departure or arrival, specified as a JavaScript Date object.

DirectionsTravelModeconstants

google.maps.DirectionsTravelModeconstants

Deprecated: Deprecated as of 2011. Use {\@link mapsapi.directions.service.directionsConstants.TravelMode} instead.

DirectionsUnitSystemconstants

google.maps.DirectionsUnitSystemconstants

Deprecated: Deprecated as of 2011. Use {\@link mapsapi.directions.service.directionsConstants.UnitSystem} instead.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-18 UTC.