TransitPreferences
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
TransitTravelMode
列舉 |
TRANSIT_TRAVEL_MODE_UNSPECIFIED |
未指定交通方式。 |
BUS |
目前搭乘公車。 |
SUBWAY |
提供地鐵行程。 |
TRAIN |
這裡是搭乘火車。 |
LIGHT_RAIL |
並可搭乘輕軌或電車。 |
RAIL |
以及搭乘火車。這相當於 SUBWAY 、TRAIN 和 LIGHT_RAIL 的組合。 |
TransitRoutingPreference
列舉 |
TRANSIT_ROUTING_PREFERENCE_UNSPECIFIED |
未指定任何偏好設定。 |
LESS_WALKING |
表示計算出的路線應優先選擇步行距離較短的選項。 |
FEWER_TRANSFERS |
表示計算出的路線應優先選擇轉乘次數較少的選項。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間: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. |"]]