使用HERE或Google Maps API检索路线上的所有州

问题描述 投票:0回答:1

我正在开发一种资源,要求我们了解HERE或Google地图提供的路线上的所有州。我试图从两个API中提取leg / step数据,但这些步骤有时不包括所有状态。

即如果路线是从加利福尼亚州的洛杉矶到新墨西哥州的阿尔伯克基,我们需要提取加利福尼亚州,亚利桑那州和新墨西哥州。

google-maps here-api directions
1个回答
0
投票

在HERE Routing API中,您可以通过添加所谓的summaryByCountry参数轻松检索此信息。这是一个示例请求:

SummaryByCountry的示例请求:

https://route.api.here.com/routing/7.2/calculateroute.xml?app_id = {YOUR_APP_ID}&app_code = {YOUR_APP_CODE}&waypoint0 = geo!50.8857,14.81589&waypoint1 = geo!50.8681536,14.8308207&routeattributes = wp,sm,sh,sc&mode = faster; car

SummaryByCountry的示例响应

<Route>
. . .
<Summary>
<Distance>2218</Distance>
<TrafficTime>109</TrafficTime>
<BaseTime>109</BaseTime>
<Flags>motorway</Flags>
<TravelTime>109</TravelTime>
</Summary>
<SummaryByCountry>
<Distance>297</Distance>
<TrafficTime>21</TrafficTime>
<BaseTime>21</BaseTime>
<Flags>motorway</Flags>
<TravelTime>21</TravelTime>
<Country>DEU</Country>
</SummaryByCountry>
<SummaryByCountry>
<Distance>1471</Distance>
<TrafficTime>58</TrafficTime>
<BaseTime>58</BaseTime>
<Flags>motorway</Flags>
<TravelTime>58</TravelTime>
<Country>POL</Country>
</SummaryByCountry>
<SummaryByCountry>
<Distance>450</Distance>
<TrafficTime>30</TrafficTime>
<BaseTime>30</BaseTime>
<Flags>motorway</Flags>
<TravelTime>30</TravelTime>
<Country>CZE</Country>
</SummaryByCountry>
</Route>

更多细节可以在这里找到:https://developer.here.com/documentation/routing/topics/resource-param-type-route-representation-options.html

© www.soinside.com 2019 - 2024. All rights reserved.