Routes Preferred API 目前僅適用於特定客戶。如需瞭解詳情,請
聯絡銷售人員。
Google 會運用 AI 技術將內容翻譯成您偏好的語言,但可能會出錯。
選擇要傳回的欄位
透過集合功能整理內容
您可以依據偏好儲存及分類內容。
呼叫 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
在正式環境中,不建議使用萬用字元 (*) 回應欄位遮罩,或在頂層 (routes) 指定欄位遮罩。只選取所需欄位:
如要進一步瞭解如何建構欄位路徑,請參閱 field_mask.proto。
[[["容易理解","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"]],["上次更新時間:2026-11-02 (世界標準時間)。"],[],["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"]]