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"
}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-09-13。
[null,null,["最后更新时间 (UTC):2025-09-13。"],[],["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,[]]