AI-generated Key Takeaways
-
Maps.Mode
is an enum used to specify the mode of transportation for directions. -
The available modes are
DRIVING
,WALKING
,BICYCLING
, andTRANSIT
. -
TRANSIT
mode requires specifying either departure or arrival time. -
Each mode utilizes specific routes like roads, pedestrian paths, bicycle paths, or public transit routes as appropriate.
An enum representing the mode of travel to use when finding directions.
To call an enum, you call its parent class, name, and property. For example,
Maps.Mode.DRIVING
.
Properties
Property | Type | Description |
---|---|---|
DRIVING | Enum | Driving directions via roads. |
WALKING | Enum | Walking directions via pedestrian paths and sidewalks (where available). |
BICYCLING | Enum | Bicycling directions via bicycle paths and preferred streets (where available). |
TRANSIT | Enum | Transit directions via public transit routes (where available). This mode requires that you set
either the departure or arrival time.
// Log all available data for a public-transit trip. const directions = Maps.newDirectionFinder() .setOrigin('The Cloisters, New York, NY') .setDestination('JFK airport, New York, NY') .setMode(Maps.DirectionFinder.Mode.TRANSIT) .setDepart(new Date()) .getDirections(); const route = directions.routes[0]; Logger.log(route); |