问题
I am using google geocode api, https://developers.google.com/maps/documentation/geocoding/intro. For zipcode 96101 , it is returning "No Results Found".
Although it is avialble https://www.google.com/maps?q=96101+zip+code&um=1&ie=UTF-8&sa=X&ved=0ahUKEwid57W5k- here
Any idea?
回答1:
Have you tried using components filtering to search a postal code? When I execute the following request, I get a postal code in the response
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A96101%7Ccountry%3AUS&key=YOUR_API_KEY
Also check if API key is correct and billing is enabled in your project. After migration to Google Maps Platform in July 2018 they are mandatory.
You can also see this result in Geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D%26options%3Dtrue%26in_country%3DUS%26in_postal_code%3D96101
I hope this helps!
Update
There are plenty of similar questions asked in the public issue tracker. For example, this issue:
https://issuetracker.google.com/issues/77308684
The answer from Google is the following:
Submitting a request specifying only postal code or string '11937+US' is an incomplete and ambiguous address that may lead to unexpected results. Per documentation [1]: In the new geocoder, ambiguous, "incomplete and badly formatted queries", such as misspelled or nonexistent addresses, are prone to produce ZERO_RESULTS.
If your intent is to search postal codes in the USA please use component filters - either using region biasing or country restriction [2]:
Please also take a look at the Geocoding best practices and FAQs: https://developers.google.com/maps/documentation/geocoding/best-practices https://developers.google.com/maps/faq#geocoder_queryformat
[1] https://developers.google.com/maps/documentation/geocoding/faq#trbl_zero_results
[2] https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering
回答2:
5-digit postal codes are hard to find in the Geocoding API, sometimes even with country name, because they are surprisingly ambiguous in a worldwide context. See https://issuetracker.google.com/73030863 for more details.
There is a workaround there which is to use Places API Autocomplete with specific parameters.
来源:https://stackoverflow.com/questions/51862745/google-geocode-api-longitude-and-latitude-unavailble-for-zip-96101