Google Geocoding API no longer displays localities every time - json

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 !!

Related

Google Geocode API Longitude and Latitude unavailble for zip 96101

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

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 geocoding inaccuracy (in Israel)

I'm trying to use Google Geocoding API, but i keep on getting a very inaccurate answer (off by 3.2 KM).
Here is an example:
http://maps.google.com/maps/api/geocode/json?sensor=true&address=Hava%27ad+Haleumi+21+Jerusalem
I get the coordinate 31.7857,35.2007.
Ff you look up "Hava'ad Haleumi 21 Jerusalem" in maps.google.com, you can see that the location is 3.2KM away from what Google Geocoding API gave me.
Does anyone know why this happens?
Thank you.
Actually, the Google Maps API does not support geocoding in Israel beyond city level, so your solution is to do what you did and finding an alternate geocoding service.
The reason you got the correct location when searching on maps.google.com is because the API uses a different provider than maps.google.com due to licensing issues.
Here is a spreadsheet detailing the coverage area for Google Maps.
It's possible to use waze.co.il instead of google:
Their JSON API is
http://www.waze.co.il/WAS/mozi?q=yourAddress&token=yourToken
(Also, as stated in this thread http://www.waze.co.il/forum/viewtopic.php?f=21&t=6113
reverse geocoding is a paid service.)
Take a look at the response. You are getting a partial match and the location type is approximate. If you look at the veiwport you will probably find that the location you are looking for falls within that viewport. *Edit - Actually it looks like it just matched to city - Jersulem in this case - which is why you are probably off by so far

Geocoding with Google Maps API - accuracy and limitations

It is easy to use the Google Maps API to find a specific street address and return the latitude and longitude. For example, link.
However, it appears that typing in the name of a specific location, for example a park, causes problems. Often these don't have a specific street number (at least, not easily findable). Despite the fact that Cadigal Reserve is located at the same address as in the link above, if I enter that as part of the query string and remove the street number, the results become rather useless: link
Typing this directly into maps.google.com easily finds the park itself (and of course, you could then find the latitude/longitude by looking in the URL).
Is there not any way of using the Google Maps API to geocode a park location like this?
It is important to understand that geocoding is not an exact science. The recommended practice if you have addresses that you know should geocode to a specific location is to build a cache and use local (client-side) geocoding.
In version 2 of the api you would build your own client-side cache that contains pre-computed geocoder responses by extending the GeocodeCache. Once a cache is defined, you would call the setCache() method and away you go. This is pretty much explained here:
http://code.google.com/apis/maps/documentation/javascript/v2/services.html#Geocoding_Caching
However, AFAIK GeocodeCache was removed in V3 of the api...
So, I would suggest implementing your own client -side caching-strategy of known addresses and their corresponding coordinates. When your application receives a geocode request for a known address the response would come from your cache (rather than Google's geocoding servers).
Failing all that you can always use a payed geocoding service that, in theory, will have a much more accurate dataset (as well as a higher limit on requests, etc).
Finally, you should also take a look through the Geocoding Strategies document as it gives a good handle on some of the issues here.

How to handle inaccurate Google Maps locations?

When I type in addresses in Google maps for locations in Asia, quite a lot of them are off by more than 200 metres. For example, "blk 85 bedok north road, singapore" is off by more than 300 metres. While I don't expect Google Maps to be spot on every time, sometimes the error is too great for certain use cases. What options do I have to handle inaccurate Google Maps locations in a web app? The web app should let the user enter an address or postal code as part of an entry and I will geocode the address and store the lat-long.
You could use bing, yahoo's and google's Geo Location api's to find latitude and longitude for a location, average the results together and use the result. Thus, if they all agree, you still get a good location, but if they disagree you get the best approximation of all three.
You could even programmatically compare the results from each engine and throw out any that don't agree with the others (for instance, if bing and yahoo agree and google does not, you could throw out google).
Beyond that, if you have a collection of addresses you know to be wrong, you could simply store the correct longitude and latitude for those points, and override the results in those cases.
Of course, to get around this problem at all, you'll need to geocode the addresses, check their validity in some way (as described above), and plot them using their latitude and longitude.
You don't have any fixes for this really, you're at the mercy of the accuracy of google maps here. The important part is you don't know if the address in inaccurate when doing one search to the next, so nothing you can do to handle it.
You can post a topic here and google will see it and often respond as well: Google Maps Local Listing Forums. I'd open something there with some of your examples and hope they get more accurate...that's all you can do in this case.
There are always other alternatives as well, yahoo and bing have mapping APIs, but I have no idea how much better or worse off you'd be going that route.
The problem is not the lat/lng data, in fact, they are correct. The problem is that the geo coords of the map tiles of the public Google maps api are inaccurate. The maps at maps.google.com are provided by a different map provider than the map tiles used with the public Google Maps API that you can embed in your website, use in your own applications, etc.
Check my recent posting at Google Maps & apps with mapview have different current positions
Is the result out on maps.google.com as well as through the maps api?
If on google maps live site the result is accurate then you can do an ajax search to return the correct lon/lat.
I have used this when geocoding UK postcodes
Geocoding UK Postcodes with Google Map API
I tried to reply to the upper answer, but I am not qualified enough yet. Just be aware that whatever you're using for geocoding, sometimes has restrictions on the use of that data. For example, google's geocoding API isn't allowed to be used to display information retrieved anywhere but google maps. The same might be for the others, I don't know what your project is, but it's something to be aware of.