Routes Preferred API 目前僅適用於特定客戶。如需瞭解詳情,請
聯絡銷售人員。
選擇要傳回的欄位
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
呼叫 ComputeRoutes()
方法時,您必須指定要在回應中傳回的欄位。方法是使用回應欄位遮罩,並透過網址參數 $fields
或 fields
提供,或是使用 HTTP/gRPC 標頭 X-Goog-FieldMask
。詳情請參閱「系統參數」。
欄位遮罩
欄位遮罩值是以半形逗號分隔的欄位路徑清單。每個欄位路徑都是以半形句號分隔的欄位名稱清單,代表訊息階層。欄位名稱可以是 JSON 物件鍵,也可以是 protobuf 欄位標記名稱。欄位路徑從頂層回應訊息型別開始,後面可選擇性加上一或多個半形句號,然後是下一層的欄位名稱。一般來說,欄位路徑的建構方式如下:
topLevelField[.secondLevelField][.thirdLevelField][...]
特殊情況的欄位遮罩是萬用字元「*」,會選取所有根層級欄位。
範例
以下範例說明如何為 ComputeRoutes()
方法設定欄位遮罩。
範例 1
所有可用欄位的欄位遮罩 (適用於手動檢查)。
X-Goog-FieldMask: *
範例 2
路線層級時間長度、距離和折線的欄位遮罩 (實際工作環境設定範例)。
X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.polyline
我們不建議在實際工作環境中使用萬用字元 (*) 回應欄位遮罩,或在頂層 (路徑) 指定欄位遮罩。只選取需要的欄位:
如要進一步瞭解如何建構欄位路徑,請參閱 field_mask.proto。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-25 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-25 (世界標準時間)。"],[],["To specify which fields to return from the `ComputeRoutes()` method, use a response field mask via the `$fields`, `fields` URL parameter, or the `X-Goog-FieldMask` header. Field masks use comma-separated field paths, formatted as `topLevelField[.secondLevelField]`. Avoid the wildcard `*` or top-level `routes` in production. Instead, specify needed fields, like `routes.duration,routes.distanceMeters,routes.polyline`, to reduce latency, ensure stable performance, and decrease response size.\n"]]