Routes Preferred API 目前僅適用於特定客戶。如需瞭解詳情,請
聯絡銷售人員。
設定折線品質
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
多邊形線的品質可用以下術語加以描述:
- 組成折線的點數
- 點越多,多邊形就越平滑 (尤其是曲線)。
- 點的浮點精確度
- 點會以經緯度值指定,並以單精度浮點格式表示。這項做法適用於小值 (可精確表示),但由於浮點四捨五入錯誤,精確度會隨著值增加而降低。
指定折線品質
呼叫 ComputeRoutes()
方法時,您會使用 PolylineQuality
列舉值指定多邊形線的品質。
如要建立由最多點組成的多邊形,請使用 HIGH_QUALITY
值,以產生最高解析度的多邊形。不過,這會導致回應延遲時間增加。
如要建立路線的低解析度概覽,請使用 OVERVIEW
值,這是由最少數量的點組成的多邊形。這個選項會產生延遲時間最短的回應。
範例
以下範例說明如何在要求主體中設定多邊形線品質。
{
"origin":{
"location":{
"latLng":{
"latitude":37.419734,
"longitude":-122.0827784
}
}
},
"destination":{
"location":{
"latLng":{
"latitude":37.417670,
"longitude":-122.079595
}
}
},
"polylineQuality":"HIGH_QUALITY"
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-04-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-04-25 (世界標準時間)。"],[[["\u003cp\u003ePolyline quality is determined by the number of points and their floating-point precision, impacting smoothness and accuracy.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eHIGH_QUALITY\u003c/code\u003e setting yields the most detailed polyline with maximum points, potentially increasing response time.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOVERVIEW\u003c/code\u003e setting creates a simplified polyline with minimal points, prioritizing faster response.\u003c/p\u003e\n"],["\u003cp\u003eYou can adjust the polyline quality using the \u003ccode\u003ePolylineQuality\u003c/code\u003e enumeration when making API requests, as shown in the example.\u003c/p\u003e\n"]]],["Polyline quality depends on the number of points and their floating-point precision. The `ComputeRoutes()` method uses `PolylineQuality` to set this. `HIGH_QUALITY` creates a polyline with the maximum points, resulting in high resolution but increased latency. `OVERVIEW` generates a low-resolution polyline with minimal points, reducing latency. The request body sets `polylineQuality` to specify either `HIGH_QUALITY` or `OVERVIEW`, which will influence the polyline's precision.\n"],null,["The quality of a polyline can be described in the following terms:\n\nThe number of points that make up the polyline\n: The more points there are, the smoother the polyline (especially in curves).\n\nThe floating-point precision of the points\n: Points are specified as latitude and longitude values, which are\n represented in single-precision floating-point format. This works well for\n small values (which can be represented precisely), but precision decreases\n as values increase because of floating-point rounding errors.\n\nSpecifying polyline quality\n\nWhen you call the `ComputeRoutes()` method, you use a\n[`PolylineQuality`](/maps/documentation/routes_preferred/reference/rest/v1alpha/TopLevel/computeRoutes#polylinequality)\nenumeration value to specify the quality of the polyline.\n\nUse the `HIGH_QUALITY` value when you want to create a polyline composed of the\nmaximum number of points, to produce a polyline of the highest resolution. This\nincreased quality comes at the expense of response latency.\n\nUse the `OVERVIEW` value when you want to create a low-resolution overview of\nthe route, which is a polyline composed of a minimal number of points. This\noption produces responses with the lowest latency.\n\nExample\n\nThe following example demonstrates how to set the polyline quality in the\nrequest body. \n\n```cplint\n{\n \"origin\":{\n \"location\":{\n \"latLng\":{\n \"latitude\":37.419734,\n \"longitude\":-122.0827784\n }\n }\n },\n \"destination\":{\n \"location\":{\n \"latLng\":{\n \"latitude\":37.417670,\n \"longitude\":-122.079595\n }\n }\n },\n \"polylineQuality\":\"HIGH_QUALITY\"\n}\n```"]]