TransitPreferences
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
基于 TRANSIT
的路线的偏好设置,这些路线会影响返回的路线。
TransitTravelMode
枚举 |
TRANSIT_TRAVEL_MODE_UNSPECIFIED |
未指定公交出行方式。 |
BUS |
乘公交车旅行。 |
SUBWAY |
乘地铁。 |
TRAIN |
乘火车旅行。 |
LIGHT_RAIL |
搭乘轻轨或电车出行。 |
RAIL |
乘火车旅行。这相当于 SUBWAY 、TRAIN 和 LIGHT_RAIL 的组合。 |
TransitRoutingPreference
枚举 |
TRANSIT_ROUTING_PREFERENCE_UNSPECIFIED |
未指定偏好设置。 |
LESS_WALKING |
表示计算出的路线应首选步行距离较短的路线。 |
FEWER_TRANSFERS |
表示计算出的路线应首选换乘次数较少的路线。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003e\u003ccode\u003eTransitPreferences\u003c/code\u003e influence the \u003ccode\u003eTRANSIT\u003c/code\u003e based routes that are returned.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify transit travel modes such as \u003ccode\u003eBUS\u003c/code\u003e, \u003ccode\u003eSUBWAY\u003c/code\u003e, \u003ccode\u003eTRAIN\u003c/code\u003e, \u003ccode\u003eLIGHT_RAIL\u003c/code\u003e, and \u003ccode\u003eRAIL\u003c/code\u003e or use the default of all supported modes.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTransitPreferences\u003c/code\u003e also allow you to indicate preferences for \u003ccode\u003eLESS_WALKING\u003c/code\u003e or \u003ccode\u003eFEWER_TRANSFERS\u003c/code\u003e when calculating a route.\u003c/p\u003e\n"]]],["The content outlines preferences for `TRANSIT` routes, using a JSON structure with `allowedTravelModes` and `routingPreference`. `allowedTravelModes` specifies transit modes like `BUS`, `SUBWAY`, `TRAIN`, `LIGHT_RAIL`, or `RAIL`. `routingPreference` allows choosing between `LESS_WALKING` or `FEWER_TRANSFERS`, to influence the transit route, and it allows for selecting no preferences. All available preferences have a corresponding unspecified value. The default `allowedTravelModes` is all available options.\n"],null,["# TransitPreferences\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n- [TransitTravelMode](#TransitTravelMode)\n- [TransitRoutingPreference](#TransitRoutingPreference)\n\nPreferences for `TRANSIT` based routes that influence the route that is returned.\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"allowedTravelModes\": [ enum (/maps/documentation/routes/reference/rest/v2/TransitPreferences#TransitTravelMode) ], \"routingPreference\": enum (/maps/documentation/routes/reference/rest/v2/TransitPreferences#TransitRoutingPreference) } ``` |\n\n| Fields ||\n|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `allowedTravelModes[]` | `enum (`[TransitTravelMode](/maps/documentation/routes/reference/rest/v2/TransitPreferences#TransitTravelMode)`)` A set of travel modes to use when getting a `TRANSIT` route. Defaults to all supported modes of travel. |\n| `routingPreference` | `enum (`[TransitRoutingPreference](/maps/documentation/routes/reference/rest/v2/TransitPreferences#TransitRoutingPreference)`)` A routing preference that, when specified, influences the `TRANSIT` route returned. |\n\nTransitTravelMode\n-----------------\n\nA set of values used to specify the mode of transit.\n\n| Enums ||\n|-----------------------------------|---------------------------------------------------------------------------------------------|\n| `TRANSIT_TRAVEL_MODE_UNSPECIFIED` | No transit travel mode specified. |\n| `BUS` | Travel by bus. |\n| `SUBWAY` | Travel by subway. |\n| `TRAIN` | Travel by train. |\n| `LIGHT_RAIL` | Travel by light rail or tram. |\n| `RAIL` | Travel by rail. This is equivalent to a combination of `SUBWAY`, `TRAIN`, and `LIGHT_RAIL`. |\n\nTransitRoutingPreference\n------------------------\n\nSpecifies routing preferences for transit routes.\n\n| Enums ||\n|------------------------------------------|----------------------------------------------------------------------------------|\n| `TRANSIT_ROUTING_PREFERENCE_UNSPECIFIED` | No preference specified. |\n| `LESS_WALKING` | Indicates that the calculated route should prefer limited amounts of walking. |\n| `FEWER_TRANSFERS` | Indicates that the calculated route should prefer a limited number of transfers. |"]]