从预览版中迁移
Routes API 于 2022 年 9 月发布为公开预览版(正式版之前的版本)。正式发布前的产品或功能受 Google Maps Platform 服务专用条款约束。如需了解详情,请参阅发布阶段说明。
本部分介绍了如何将应用从预览版迁移到 GA 版。
向正式版添加的新功能
正式版中新增了以下预览版中未包含的新功能:
现有预览版功能的变更
现在,您必须向请求中添加新的数组 extraComputations
字段,以便在 GA 中显式启用以下功能:
在预览版中,您使用了字段掩码来指定在响应中返回这些地图项的信息。现在,您必须同时满足以下条件:
- 设置新的
extraComputations
数组请求参数即可启用这些功能。
- 设置字段掩码,以指定要在响应中返回信息。
我需要注意什么?
除非通过设置 extraComputations
明确启用,否则以下字段将不再包含在 computeRouteMatrix 响应中:
travelAdvisory.tollInfo
(过路费信息)
除非通过设置 extraComputations
明确启用,否则以下字段将不再包含在 computeRoutes 响应中:
routes.legs.travelAdvisory.tollInfo
(过路费信息)
routes.travelAdvisory.tollInfo
(过路费信息)
routes.travelAdvisory.fuelConsumptionMicroliters
(燃油消耗)
routes.travelAdvisory.speedReadingIntervals
(多段线上的交通信息)
routes.legs.travelAdvisory.speedReadingIntervals
(多段线上的交通信息)
我需要做什么?
如需接收多段线的过路费信息、油耗或路况响应字段,您必须将新的请求数组字段 extraComputations
设置为包含以下一个或多个值:
如需接收过路费信息,请将新的 extraComputations
数组字段设置为 "TOLLS"
。
如需接收油耗,请将新的 extraComputations
数组字段设置为 "FUEL_CONSUMPTION"
。
如需接收多段线的路况信息,请将新的 extraComputations
数组字段设置为 "TRAFFIC_ON_POLYLINE"
。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-06。
[null,null,["最后更新时间 (UTC):2025-02-06。"],[[["The Routes API has transitioned from Preview to General Availability (GA), introducing new features and changes to existing ones."],["You can now specify locations using address strings and Plus Codes in addition to place IDs and coordinates."],["Toll info, fuel consumption, and traffic on a polyline now require explicit enablement using the `extraComputations` field in requests."],["The `geocodingResults` array has been added to the response, providing place IDs and metadata for locations specified as address strings or Plus Codes."],["Existing implementations relying on implicit inclusion of toll info, fuel consumption, or traffic on a polyline data need to be updated to utilize the `extraComputations` field."]]],["The Routes API's GA release introduces new location specification options, including address strings and Plus Codes, and includes a `geocodingResults` array in the response. To enable toll info, fuel consumption, and traffic on a polyline, users must now set the `extraComputations` array in their requests. `extraComputations` values are \"TOLLS\", \"FUEL_CONSUMPTION\", and \"TRAFFIC_ON_POLYLINE\". The field mask must still be used. Certain fields will be omitted in the response unless enabled by `extraComputations`.\n"]]