Enum Mode

  • The Mode enum represents different modes of travel for finding directions.

  • You access the Mode enum by calling its parent class, name, and property, such as Maps.Mode.DRIVING.

  • Properties of the Mode enum include DRIVING, WALKING, BICYCLING, and TRANSIT.

  • The TRANSIT mode requires setting either a departure or arrival time.

Mode

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

PropertyTypeDescription
DRIVINGEnumDriving directions via roads.
WALKINGEnumWalking directions via pedestrian paths and sidewalks (where available).
BICYCLINGEnumBicycling directions via bicycle paths and preferred streets (where available).
TRANSITEnumTransit 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.
constdirections=Maps.newDirectionFinder()
.setOrigin('The Cloisters, New York, NY')
.setDestination('JFK airport, New York, NY')
.setMode(Maps.DirectionFinder.Mode.TRANSIT)
.setDepart(newDate())
.getDirections();
constroute=directions.routes[0];
Logger.log(route);

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

Last updated 2024年11月26日 UTC.