Google geocode API can't find address returned

2019-07-12 02:48发布

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:

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

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

2条回答
Bombasti
2楼-- · 2019-07-12 02:55

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:

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.

查看更多
爷的心禁止访问
3楼-- · 2019-07-12 03:13

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!

查看更多
登录 后发表回答