Google地理编码API无法找到地方API返回的地址

时间:2016-12-28 22:11:15

标签: google-maps google-api google-places-api google-geocoder google-geocoding-api

我无法让谷歌的地理编码api识别地址:

Squaire 12
Am Flughafen
60549 Frankfurt am Main
德国

Squaire是法兰克福机场的一幢建筑物。它似乎没有正常的街道地址,但The Squaire的许多企业都有“The Squaire NUMBER”这样的地址。例如:

但无论我做什么,我都无法获得谷歌地理编码api认可的地址:

令人抓狂的是,当我在机场附近搜索“squaire”时,地方API会找到我正在寻找的地方:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=XYZ&location=50.0509194,8.5684084&radius=1000&keyword=squaire

匹配结果为:place_id: ChIJY9ZMLL4KvUcRxZhQ3e-7ask。当我查询详细信息端点时:

https://maps.googleapis.com/maps/api/place/details/json?key=XYZ&placeid=ChIJY9ZMLL4KvUcRxZhQ3e-7ask

我得到formatted_address: "THE Squaire 12, Am Flughafen, 60549 Frankfurt am Main, Germany",但这正是地理编码api中无效的地址。

当我使用带有place_id的反向地理编码api时:

https://maps.googleapis.com/maps/api/geocode/json?key=XYZ&place_id=ChIJY9ZMLL4KvUcRxZhQ3e-7ask

我得到formatted_address: "plug and work Frankfurt, THE SQUAIRE Conference Center, THE Squaire 12, Am Flughafen, 60549 Frankfurt am Main, Germany"。哪个仍然无法在前向地理编码api中使用:

https://maps.googleapis.com/maps/api/geocode/json?address=plug%20and%20work%20Frankfurt,%20THE%20SQUAIRE%20Conference%20Center,%20THE%20Squaire%2012,%20Am%20Flughafen,%2060549%20Frankfurt%20am%20Main,%20Germany

2 个答案:

答案 0 :(得分:4)

这是地理编码API中的一个问题:Issue 11031

它已于1月下旬修复,因此Geocoding API将始终返回与Google地图相同的结果:

这实际上是Issue 11031如何修复的副作用,并且与原始编码API的原始行为背道而驰。 xomena的回答在他回答的时候是有效的,Google Maps API文档的官方建议确实是使用Places API文本搜索。这种情况持续时间较长,因为如果您重新阅读New Forward Geocoder FAQ,您会注意到。

答案 1 :(得分:1)

Google地理编码API服务不适用于商家信息。您应该使用Places API search服务而不是地理编码API来搜索商家。

您可以按照最佳做法文章中的建议,将Places API自动填充功能与Geocoding API结合使用。在这种情况下,您可以从自动填充中获取地点ID,并在地理编码API中使用它。

请查看地理编码最佳做法: https://developers.google.com/maps/documentation/geocoding/best-practices

希望它有所帮助!

相关问题