【问题标题】:get the city names the google map route going through获取城市名称谷歌地图路线经过
【发布时间】:2012-12-27 08:05:15
【问题描述】:

我正在使用 Google 地图 API v3 开发网页。有没有办法收集从 A 点到 B 点的路线所经过的地点或城市名称?我在页面中使用 javascript。

【问题讨论】:

    标签: javascript


    【解决方案1】:

    查看Directions API docs。看起来您获得了一个包含DirectionsRoutes 数组的DirectionsResult 对象。每个DirectionsRoute 都包含一个DirectionsLegs 数组,而该数组又进一步细分为一组DirectionsSteps。从每个步骤中,您可以拉出start_location 和/或end_location,每个都表示为 Lat/Lng。从那里,我将让这个答案接管如何将 Lat/Lng 转换为城市(反向地理编码):

    Google Maps: how to get country, state/province/region, city given a lat/long value?

    简而言之,Google 地图提供的方向被分解为许多子部分,并且在大多数粒度级别上,您都可以提取纬度/经度,并让 Google 的地理编码 API 处理将其转换为城市名称。

    【讨论】:

      猜你喜欢
      • 2018-01-16
      • 1970-01-01
      • 2012-04-04
      • 2023-03-20
      • 1970-01-01
      • 2016-11-21
      • 2011-01-18
      • 2012-06-24
      • 1970-01-01
      相关资源
      最近更新 更多