Google Geocode API Longitude and Latitude unavailble for zip 96101 - google-maps

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?

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.

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

Related

Google geocoding API returns ZERO_RESULTS for postal code

I am trying to geocode user entered data using the Google maps API, and got an error for the Australian postal code "2010"
maps.google.com/maps/api/geocode/json?components=country:AU|postal_code:2010
However, if I search in Google maps, I get a result. Am I doing something wrong in my request?
Your request is completely OK, but unfortunately, Google experience issues with searching 4-digit postal codes. This bug has already been reported in Google issue tracker and you can see it here:
4-digit postal codes are hard to geocode (AT, AU, BE, DK, NZ, SI)
I would suggest starring the bug to add your vote and subscribe to further notifications from Google.
Also you can see that suggested workaround by Google is using place autocomplete request with types (region) and country components filter.
So, in your case you can run the following query
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=2010&types=(regions)&components=country%3AAU&key=YOUR_API_KEY
It will return a place ID for postal code 2010: ChIJ3QyubXuuEmsREIe6P2t9ARw
And you can use geocoding with place ID to get required information
https://maps.googleapis.com/maps/api/geocode/json?place_id=ChIJ3QyubXuuEmsREIe6P2t9ARw&key=YOUR_API_KEY
I hope this helps!
I experienced a similar issue periodically, when geocoding US zip-codes. Appending the country name after the zip-code seemed to fix the problem. So, instead of 60162 use 60162 USA.
When a URL is opened in the browser based on its IP context, it identifies the country and automatically deduces the query format for a zip code is 99.999-99.
The format above is for Brazil, but there are different standards for each country such as USA and Portugal.
One solution when calling an API via CURL, either by code or by terminal, include the "&components = country: US" parameter, changing the "US" country code to what you want to filter.
The Google API returns ZERO_RESULTS for safety, because a search would be too slow and could do a global search worldwide and not just the country. For performance and speed reasons, Google creates this automatic ID for help, but unfortunately is not provided to developers about this process.
Good luck!

Google maps geocode returns ZERO_RESULTS for some queries when I use Country Code

I have been working on an application which uses google maps api. recently i found geocoding not compatible with some address like,
http://maps.googleapis.com/maps/api/geocode/json?address=ae
which the address is country code. But it was working properly before. But today
09/08/2017 i found this issue. and additionally I found geolocation also fails to determine the location frequently in official website
https://developers.google.com/maps/documentation/javascript/geolocation.
Please guide.
Thanks.
For the searching of the country by its code I would suggest applying component filtering instead of the address parameter. It should work better in this use case. Passing country code as address parameter is treated as incomplete street address and the result is prone to be ZERO_RESULTS for incomplete addresses. Change your query to
https://maps.googleapis.com/maps/api/geocode/json?components=country%3AAE&key=YOUR_API_KEY
Regarding to the second issue, this is a bug reported at Chrome issue tracker:
https://bugs.chromium.org/p/chromium/issues/detail?id=753242
It looks like Google team has already adjusted the usage quota for the API key that they use internally and solved this issue.

Google Geocoding API no longer displays localities every time

I'm a french developer and I have question about GMAP Geocoding API.
I'm on a new website work, which use this API.
The Geocoding API is used to get geocoded boundaries of french cities when user enter a french postal code.
So I request the API by this URL : https://maps.googleapis.com/maps/api/geocode/json?address=MY_ZIP_CODE&components=country:fr&key=my_key
In France, sometimes there is multiple cities for one postal code.
The default city is written in the JSON in address_components, "types" : [ "locality", "political" ] and all the cities are writtent in "postcode_localities".
(have an example in screenshot).
Last week, everything was working good.
But today, I've got a big probleme... When I use postal code (69510, 69310, 69600, etc....) multiple cities or alone city aren't no longer displayed.... But it works good for "69530".
It's embarassing for me because the website I'm bulding use the postal code to do a geolocated search with km radius...
Do you know if this API was update ?
I've search on Google.... But I've never find an answer.
Thanks in advance for your help !!
Have a nice day
My screenshot that show the API JSON answer
I was experiencing this problem as well yesterday. #xomena was right.
They updated their API at the end of November/beginning of December, and started more strictly encouraging best practices – using the Geocoding API for complete postal code strings (for example, “48 Pirrama Rd, Pyrmont, NSW, Australia”), and the Places API for more ambiguous addresses and semantic locations, including businesses and points of interest.
Specifically their blog post said:
Future Changes to Geocoding API
We plan to roll out an update to the Geocoding API at the end of November 2016 that will increase the difference between Geocoding and Places performance for ambiguous and unambiguous queries. This change will improve the quality of Geocoding results for unambiguous queries, but will be more likely to return ZERO_RESULTS for ambiguous or incomplete queries where the Geocoding API was unable to find a high quality result.
If you are already using the above best practices, you should see an improvement in your Geocoding API results. If you are currently using the Geocoding API for incomplete or ambiguous queries, or for queries that may contain non-address information such as business names or apartment numbers, we recommend that you switch to the Places API instead, as it is likely to give better quality results for your use case.
Try using the Place Search API instead! https://developers.google.com/places/web-service/search
Please file a bug in the Google Maps API issue tracker.
This is not related to the new geocoder, you'll see that adding new_forward_geocoder=false to your requests makes no difference.
The postcode_localities field is never exposed in Places API.
I am experiencing the same problem as described by #Jean-Baptiste.
I opened an issue : http://code.google.com/p/gmaps-api-issues/issues/detail?id=11087
Thanks for your answers.
That's true, the Places API can't give an autocompletion and the Autocomplete API doesn't give me satisfaction.
I've change my JS API parser and I get geocoding datas even if the postcode localities exists. If the zip code exists, so the geocoding datas exist.
That's a solution.... The visitor knows the zip code of the city where he lives. And for a major part of cities, the zip code is ok.
I saw that www.booking.com has the same problem...
Screenshot of the same problem on booking.com
That's solved for me ;-)
Thanks !!

Geocoding localities (towns/cities) with Google geocoding API

Is there a way to restrict the Google geocoding API to search only for settlements as opposed to full addresses? The API documentation specifies a 'components' argument but that seems intended to specify a specific locality rather than localities in general.
For example a search for the town of Maskiot in Israel..
http://maps.googleapis.com/maps/api/geocode/json?address=Maskiot&sensor=false&components=country:IL
returns 'Maskit Street' near Tel Aviv, but the actual place I'm after is miles away, as a Google Maps search shows:
https://www.google.co.uk/maps/place/Maskiyot/#32.3178645,35.502754,15z/data=!3m1!4b1!4m2!3m1!1s0x151cf24adf97e761:0x4c10482c54ff115c
Very grateful for advice.
This problem is the result of the fact that you misspelled the name of the place.
In your original request you were using "Maskiot" whereas the place is actually "Maskiyot". If you change this name in your original request it all works fine.

google maps api geocoding is less precise than manual search, why?

i am using a php script (followed this tutorial http://www.bitconsultants.net/2010/geocoding-with-google-maps-and-the-zend-framework/) to get the latitude and longitude of different adresses,
the problem is that if i manually search an address in google maps it gives me the right location,
while using the php script, the json response from google is even 500meters away from the manual search result, which makes it kind of pointless for my needs...
i am passing the address in this format
$address = "{$data['street']}, {$data['postcode']}, {$data['city']}, {$data['province']}";
and i am passing google a key
thank you
Are your addresses really well formed? Could you please give a concrete example?
Such difference could occur if the postal address is not found at given city or town and Google tries to partially match the given address. See *partial_match* on API documentation.
Also: unfortunately the link you gave above does not work here ("Forbidden" error).
i found out why, don't use php urlencode() on the $address, it does something strange with "," and maybe other stuff, so google doesn't understands well your url