[GIS] Transit Directions: Preferred Vehicle Type

google mapsgoogle-maps-apitransit

I would like to be able to get transit directions through the JS api, that is limited to a single vehicle type (e.g. Bus). This functionality is available on maps.google.com, but how do i submit the vehicle type as part of the DirectionsRequest?.
Using the code below will provide routes via Bus, Train

google.maps.DirectionsTravelMode.TRANSIT

But if i want to restrict only to Train, how do i do it?

Best Answer

google.maps.VehicleType object specification

Possible values for vehicle types. These values are specifed as strings, i.e. 'BUS' or 'TRAIN'.

BUS Bus.

CABLE_CAR A vehicle that operates on a cable, usually on the ground. Aerial cable cars may be of the type GONDOLA_LIFT.

COMMUTER_TRAIN Commuter rail.

FERRY Ferry.

FUNICULAR A vehicle that is pulled up a steep incline by a cable.

GONDOLA_LIFT An aerial cable car.

HEAVY_RAIL Heavy rail.

HIGH_SPEED_TRAIN High speed train.

INTERCITY_BUS Intercity bus.

METRO_RAIL Light rail.

MONORAIL Monorail.

OTHER Other vehicles. RAIL Rail.

SHARE_TAXI Share 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. SUBWAY Underground light rail.

TRAM Above ground light rail.

TROLLEYBUS Trolleybus.

https://developers.google.com/maps/documentation/javascript/3.exp/reference#VehicleType

Related Question