【问题标题】:How to get exact City name using postal code? I am using the below API but it is not giving exact city name , It is giving only District name如何使用邮政编码获取准确的城市名称?我正在使用下面的 API,但它没有给出确切的城市名称,它只给出了地区名称
【发布时间】:2016-06-10 05:56:44
【问题描述】:

这是我正在使用的 API,但它仅提供地区名称和州名称,而不是根据邮政编码提供名称。是否有任何其他 API 可以获取确切的城市名称。请帮我解决这个问题。

http://maps.googleapis.com/maps/api/geocode/json?address=&components=postal_code:506366&sensor=false"

【问题讨论】:

标签: ios google-maps google-maps-api-3


【解决方案1】:

查看 maps.google.com 上的邮政编码边界,​​邮政编码似乎与多个地区重叠:

https://www.google.es/maps/place/Telangana+506366,+India/@18.3178586,79.5682081,12.25z/data=!4m5!3m4!1s0x3a3324c84ccde691:0xdedd70d16ab9cfab!8m2!3d18.3214924!4d79.616521

在这种情况下,由于不明确,Geocoding API 不会返回地址组件中的位置。

但是,我希望响应中的 postcode_localities 数组根据文档

是一个数组,表示邮政编码中包含的所有地区。仅当结果是包含多个地区的邮政编码时才会出现这种情况。

https://developers.google.com/maps/documentation/geocoding/intro#Results

此时它看起来像一个错误。我可以建议在公共问题跟踪器中提出问题:https://code.google.com/p/gmaps-api-issues/

【讨论】:

  • 不是错误,让我在附加答案中解释。
【解决方案2】:

有点棘手:postcode_localities 仅在结果是包含多个地区的邮政编码时出现。但是,506366(印度)仅与这些地方重叠,它不包含任何地方。这就是地址中没有locality 的原因。

同时,没有完全包含这些地区的邮政编码,因此您也不会在他们的地址中看到postal_code:

https://maps.googleapis.com/maps/api/geocode/json?&address=Parlapalle%20506366%20india https://maps.googleapis.com/maps/api/geocode/json?&address=Akinepalle%20506366%20india

这是一个返回 postcode_localities 的示例:13100(法国): https://maps.googleapis.com/maps/api/geocode/json?components=country%3AFR%7Apostal_code%3A13100

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-08
    • 2012-05-07
    • 1970-01-01
    • 2019-10-27
    • 1970-01-01
    • 2015-06-29
    • 2020-05-14
    • 1970-01-01
    相关资源
    最近更新 更多