Google geocode API can't find address returned by the place API

∥☆過路亽.° 提交于 2019-12-11 03:25:40

问题


I can't get google's geocode api to recognize the address:

The Squaire 12
Am Flughafen
60549 Frankfurt am Main
Germany

The Squaire is a building at the airport in Frankfurt. It doesn't appear to have a normal street address, but a number of businesses in The Squaire have addresses like "The Squaire NUMBER". For example:

  • ALEX: The Squaire 17, 60549 Frankfurt am Main, Germany
  • Bilfinger Facility Services GmbH: THE SQUAIRE 13, Am Flughafen, 60549 Frankfurt am Main, Germany

But no matter what I do, I can't get addresses like that recognized by the google geocode api at:

  • The Squaire 12, Am Flughafen, 60549 Frankfurt am Main, Germany
  • The Squaire 12, 60549 Frankfurt am Main, Germany
  • And lots of other variations

The maddening thing is that the places API finds the place I'm looking for when I search for "squaire" near the airport:

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

The matching result has: place_id: ChIJY9ZMLL4KvUcRxZhQ3e-7ask. When I query the details endpoint:

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

I get formatted_address: "THE Squaire 12, Am Flughafen, 60549 Frankfurt am Main, Germany", but that's exactly the address that won't work in the geocode api.

And when I use the reverse geocode api with the place_id:

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

I get formatted_address: "plug and work Frankfurt, THE SQUAIRE Conference Center, THE Squaire 12, Am Flughafen, 60549 Frankfurt am Main, Germany". Which still doesn't work in the forward geocode 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


回答1:


This was an issue in the Geocoding API: Issue 11031.

It has been fixed in late January, so that Geocoding API will always return the same result/s as Google Maps:

  • The Squaire 12, Am Flughafen, 60549 Frankfurt am Main, Germany ==> "formatted_address" : "Am Flughafen, The Squaire 12, 60549 Frankfurt am Main, Germany"
  • The Squaire 12, 60549 Frankfurt am Main, Germany ==> "formatted_address" : "The Squaire, 60549 Frankfurt am Main, Germany"

This is actually a side effect of how Issue 11031 was fixed, and is a departure from the original behavior of the Geocoding API. xomena's answer was valid at the time he answered, the official recommendation from the Google Maps API documentation was indeed to use Places API Text Search. This is on longer the case, as you'll notice if you re-read the New Forward Geocoder FAQ.




回答2:


Google Geocoding API service doesn't work with business listings. You should use Places API search service instead of Geocoding API to search businesses.

You can combine Places API autocomplete with Geocoding API as suggested in the best practices article. In this case you can get place ID from autocomplete and use it in Geocoding API.

Please take a look at the Geocoding best practices: https://developers.google.com/maps/documentation/geocoding/best-practices

Hope it helps!



来源:https://stackoverflow.com/questions/41370414/google-geocode-api-cant-find-address-returned-by-the-place-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!