kremzeek
kremzeek

Reputation: 51

google map api autocomplete goes to wrong address

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?

Upvotes: 0

Views: 1962

Answers (1)

xomena
xomena

Reputation: 32168

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!

Upvotes: 2

Related Questions