【问题标题】:google map geocoding api returns result for invalid zip code谷歌地图地理编码 api 返回无效邮政编码的结果
【发布时间】:2019-12-23 06:42:30
【问题描述】:

Google 地理编码 API 返回以下邮政编码的结果:“0”、“00”、“000”、“00000”

点击此 api 后 - https://maps.googleapis.com/maps/api/geocode/json?address=00000&key=mysecretkey 它返回“formatted_address”:“6009 Wayzata Blvd Suite #108, St Louis Park, MN 55416, USA”

这些是有效的邮政编码吗?理想情况下它不应该返回结果。

【问题讨论】:

    标签: google-maps google-geocoding-api zipcode


    【解决方案1】:

    您应该注意以下几点:

    • 当您在 Geocoding API 请求中发送 address=00000 参数时,它将在格式化的地址或地名中搜索匹配。在这种情况下,服务不会只匹配邮政编码。

    • Google 的数据库中可能存在错误数据,可能会导致意外结果。

    在您的示例中,它似乎是 Google 数据库中的错误数据。

    让我们看看对您的请求的响应

    https://maps.googleapis.com/maps/api/geocode/json?address=00000&key=YOUR_API_KEY

    正如您在响应中看到的,地点 ID 是“ChIJgyA2iZU0s1IReyHBw0yPjZg”。现在检查此地点 ID 的地点详细信息请求的输出

    https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJgyA2iZU0s1IReyHBw0yPjZg&key=YOUR_API_KEY

    响应将包含以下内容

    {
        ....
        id: "3fff72184719b7835304f285f40e677e9914933e",
        international_phone_number: "+1 763-300-8722",
        name: "00000",
        place_id: "ChIJgyA2iZU0s1IReyHBw0yPjZg",
        formatted_address: "6009 Wayzata Blvd Suite #108, St Louis Park, MN 55416, USA",
        types: [
            "lodging",
            "point_of_interest",
            "establishment"
        ],
        .....
    } 
    

    请注意,该商家在 Google 数据库中的名称为“00000”,因此 Geocoding API 正在按预期工作,但显然这里存在数据问题。

    您可以使用此链接查看该地点并向 Google 报告不良数据

    https://maps.google.com/?cid=10992599825345749371

    我希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 2016-03-23
      • 1970-01-01
      相关资源
      最近更新 更多