【问题标题】:get coordinates of a location by name按名称获取位置的坐标
【发布时间】:2012-12-05 21:36:28
【问题描述】:

我想在我的 Android 应用中接收给定位置名称的经度和纬度值。我知道 Google 有一个地理编码 API,但它似乎强制我在 Google 地图上显示结果:

Geocoding API 只能与 Google 地图结合使用; 禁止在未在地图上显示的情况下对结果进行地理编码。 from here

那么还有其他方法可以接收位置名称的坐标吗?或者我没有正确理解 TOU?

【问题讨论】:

    标签: android google-maps-api-3 coordinates geocoding


    【解决方案1】:

    地理编码和反向地理编码 API 应该能够为您提供帮助。

    但无论如何,雅虎!有非常好的 Geocoding API,它甚至可以给你 JSON 响应。

    我已经尝试过它们,它们非常适合这种用例。

    【讨论】:

    • 谢谢@rock_win,但如果 ADR 是正确的并且 yahoo 没有为所有位置提供全面支持,我想我将不得不坚持使用 google 的 api。
    【解决方案2】:

    如果没有Google's Geocoding API / google maps / any Maps API,则使用位置名称获取位置坐标是not possible。甚至,yahoo API doesn't give full support 用于所有地理位置名称。在雅虎,它只提供一些热门城市的位置信息,而不是每个位置。到目前为止google's map API is better than any other API

    只需在您的应用中隐藏该地图视图,然后覆盖您想要查看的任何其他视图。

    【讨论】:

      【解决方案3】:

      你可以

      Geocoder geocoder = new Geocoder(<your context>);  
      List<Address> addresses;
      addresses = geocoder.getFromLocationName(<String address>, 1);
      if(addresses.size() > 0) {
        double latitude= addresses.get(0).getLatitude();
        double longitude= addresses.get(0).getLongitude();
      }
      

      参考https://stackoverflow.com/a/9698408/2458192

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-10-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-27
        • 1970-01-01
        • 2012-09-17
        相关资源
        最近更新 更多