google map api autocomplete goes to wrong address - google-maps

I've typed in an address that I know exists into a google api autocomplete :
642 Great Western Hwy Girraween NSW 2145
map example link
-The autocomplete recognizes it, but...
The result I get is incorrect:
642 Great Western Hwy, Faulconbridge NSW 2776, Australia
For other addresses like this,
is there any workaround for a fix?
I've investigated the Autocomplete.getPlaces()
and can't seem to find a way around this.
-I even looked into AutocompleteServices objects (where the autocomplete gives the correct prediction - but is not within official address_components.
Any suggestions?

This is ongoing issue on Google side and it was reported in Google issue tracker several days ago. You can find it here:
Locality/postal_code in Place Details does not align with Place Autocomplete description.
Google is looking into it and hopefully they will find solution soon. I would suggest starring the bug to add your vote and subscribe to notifications from Google.
In the meantime the unique workaround I can think of is using a formatted string from autocomplete prediction and resolve it using Geocoding API service instead of getting place details using a place ID.
For example, you execute autocomplete request
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=642%20Great%20Western%20Hwy%20Girraween%20NSW%202145&key=YOUR_API_KEY
It returns the following values in the response JSON:
"description":"642 Great Western Hwy, Girraween NSW 2145, Australia"
"place_id":"EjQ2NDIgR3JlYXQgV2VzdGVybiBId3ksIEdpcnJhd2VlbiBOU1cgMjE0NSwgQXVzdHJhbGlhIjESLwoUChIJ1Ww4O998EmsRmSCZE6S6OVMQggUqFAoSCdtIcBNscBJrESbra3OWkCBW"
If you use place ID to get details it resolves to wrong address
https://maps.googleapis.com/maps/api/place/details/json?placeid=EjQ2NDIgR3JlYXQgV2VzdGVybiBId3ksIEdpcnJhd2VlbiBOU1cgMjE0NSwgQXVzdHJhbGlhIjESLwoUChIJ1Ww4O998EmsRmSCZE6S6OVMQggUqFAoSCdtIcBNscBJrESbra3OWkCBW&key=YOUR_API_KEY
However, if you use geocoding with text from description you get correct address:
https://maps.googleapis.com/maps/api/geocode/json?address=642%20Great%20Western%20Hwy%20Girraween%20NSW%202145&key=YOUR_API_KEY
You can also see this in Geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D642%2520Great%2520Western%2520Hwy%2520Girraween%2520NSW%25202145
I hope this helps!

Related

google directions API keeps changing the destination postalcode

I am having troubles using the google directions api.
for example I want to retreive the distance between two cities, I send the following command :
https://maps.googleapis.com/maps/api/directions/json?origin=8380 Belgium&destination=2030 Belgium&sensor=false&alternatives=true&key=<mykey>
it should return details about the route between postalcode 8380 (belgium) and postalcode 2030 (belgium).
But in the result I see that google had altered postalcode 2030 into 4730 !
That is a complete different location.
See also this
If i simply use the maps url like this
http://www.google.be/maps/dir/8380 Belgium/2030 Belgium
then it works as expected.
How can I force google to NOT change the postal code into something else but keep using the postal code i send ?
EDIT
I have been playing with it and it turns out that if I use B-2030 in stead of 2030 as postalcode, it works as expected.
If I use BE-2030 it gets me close but still 15 km to far.
But using a prefix like B- on all postalcodes is something I rather not do, maybe it will work wrong on some other postal codes, and we also have a lot of foreign addresses I dont want to keep a list of all country codes...
EDIT
I had put this question as a ticket with google, I received an answer that they are aware of this issue and the developers are looking for a fix.
I will update this post when I receive more news from them.
You are right this is a known issue with 4-digit postal codes that was reported in Google issue tracker for a bunch of countries:
https://issuetracker.google.com/issues/75985322
Hopefully Google will solve it soon.
In the meantime it looks like the only reliable workaround consists in resolving the postal codes to their places IDs via place autocomplete service and applying place IDs in directions requests.
E.g. execute the place autocomplete requests for your examples:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=8380%20Belgium&types=(regions)&key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=2030%20Belgium&types=(regions)&key=YOUR_API_KEY
These requests will return place ID ChIJo0saJPpVw0cRzkf6DZ5gRBo for '8380 Belgium' and place ID ChIJ4ejQlRcIxEcRnGOzGMCkbYc for '2030 Belgium'.
So, now you can execute directions request with these place IDs and get expected results
https://maps.googleapis.com/maps/api/directions/json?origin=place_id%3AChIJo0saJPpVw0cRzkf6DZ5gRBo&destination=place_id%3AChIJ4ejQlRcIxEcRnGOzGMCkbYc&mode=driving&alternatives=true&key=YOUR_API_KEY
Here is the same request in directions calculator:
https://directionsdebug.firebaseapp.com/?origin=place_id%3AChIJo0saJPpVw0cRzkf6DZ5gRBo&destination=place_id%3AChIJ4ejQlRcIxEcRnGOzGMCkbYc&mode=driving&alternatives=true
I hope this workaround might be helpful.

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

Link to street view URL using address?

Is it possible to link directly to street view from an URL using only the address (and not lat/lng)?
For example, is there a way to do something like
http://maps.google.com/maps?q=&layer=c&address=Street,number,state&cbp=11,0,0,0,0
Instead of
http://maps.google.com/maps?q=&layer=c&cbll=31.335198,-89.287204&cbp=11,0,0,0,0
?
Lat/lng from geocoding tends to not be recognized by street view as being too far from a street, sometimes getting the wrong street altogether, because the lat/lng it generates may be off the street, as it tries to match the location of a house.
I have looked everywhere and even tried playing with google's URLs on my own, but I can't find anything on it. Most sources won't even mention address. I'm currently using the url sample from this question, but it still isn't really what I'm looking for.
If this is really not possible, could someone link to a source/documentation where it says so?
Edit: Thank you everyone for the answers, but none really address the issue with street view and addresses. I'll look into forwarding this to google. I'll post here if I get a reply.
Let's enhance your code, if you paste the code in browser then you will be redirect to google maps and will show result what you requested.
http://maps.google.com/maps?&q=Space+Needle,Seattle+WA
If you would like to pass the value (address) via php or any other code type then simply it will not work, you cannot use google maps without API to enhance your requirement. Lat & Lng is basic practice to show map and not require any api, but if you would like to pass additional properties then you will have to use google maps api to do so. Detailed documentation can be found here
https://developers.google.com/maps/documentation/embed/guide
but let's try an example try this code in browser
https://www.google.com/maps/embed/v1/place?q=Mumbai,+Maharashtra,+India
You will get an error that api key not found but if you try this one
https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Space+Needle,Seattle+WA
Then you will get output. Hope it helps!
First reverse geocode to find the lat lng using another Google Service API.
Then feed the resulting lat lng into the streetview endpoint parameter.

Google maps API - geocoder doesn't find 'Carson, CA'

I have a customer with store locator functionality based on Google maps API. Couple days ago the complained about locator not able to find 'Carson, CA'
Here's a really simple demo from Google itself and it doesn't work either:
http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html
Is there a way to contact Google support? I tried to search for any contact information but couldn't find anything useful.
It does look like a bug as there is a Carson marked on the map south of Los Angeles. It happens: geocoder data gets updated and sometimes things get missed off. Bugs need to be raised in the issue tracker. Be sure to search first (although I didn't find a previous report for this) and choose the right template when raising a new bug.
http://code.google.com/p/gmaps-api-issues/issues/list
For a store locator app, you may find searching for West Carson provides a decent start point, although this is hardly a usable workaround. Try using the zip code instead.
I don't think this is actually a bug; let me gently suggest that I think you are probably using the wrong API for looking up "Carson, CA." I'm not being harsh, just trying to help. But Geocoding has two basic functions:
Given an address as input, reply with the best Lat-Lng coordinates for that address.
Given coordinates as input, reply with the closest known address (sometimes called Reverse Geocoding).
With "Carson, CA" as input, it doesn't seem like you have given enough information to have defined an address, which probably means that the Geocoder just didn't have enough information. The same goes for the Store Locator; "Carson, CA" isn't a store.
I think what you do want to use for a search of this kind is the Google Places APIdev-guide, because you are actually looking for a place, not coordinates or an address. Using the Google Places Autocomplete, for example, you can set the tool to search for different types, for example: countries, cities, or geocode (and there are others). The first, countries will let you find places such as: Australia, Bahamas, or Canada. The second, cities, will let you find places such as: Albuquerque, Baton Rouge, or Carson, CA. The last, geocode will restrict you to address searches, which is essentially what you are using when using the Geocoder.
I made the same mistake myself the other day when I sent a request to the Geocoder that contained "Wrigley Field"; the result was some address in Georgia on "Wrigley Field Road," which had me very confused until I thought about it for awhile and then it made sense. Wrigley Field is a place, not an address. I have been working with the Autocomplete a bunch lately and that has really made the difference between the two modes of lookup clear. As a possible solution for you, if you don't provide a specific type to the Autocomplete, it will use all of them, which will allow you to find places and/or addresses. It might give you a more functional solution for your site.
Anyway, just trying to offer some helpful feedback and I hope I did help -