Google Places API - Returning invalid street numbers

If I search for 500 Buckingham Place, Eight Mile Plains the Google Places API returns 500 Buckingham Place, Eight Mile Plains, Queensland, Australia with the place id Ej41MDAgQnVja2luZ2hhbSBQbGFjZSwgRWlnaHQgTWlsZSBQbGFpbnMsIFF1ZWVuc2xhbmQsIEF1c3RyYWxpYQ. If I then do a details call on that place id it returns Buckingham Pl, Eight Mile Plains QLD 4113, Australia.

This can be replicated on the Google Maps website at https://www.google.com.au/maps/search/500+Buckingham+Place+Eight+Mile+Plains. The place returned will just be Buckingham Pl, Eight Mile Plains QLD 4113, Australia.

Can I get Google Places API to only return search results for actual street numbers?

EDIT The call I am doing is https://maps.googleapis.com/maps/api/place/autocomplete/json?input=500%20Buckingham%20Place%2C%20Eight%20Mile%20Plains&types=address

Answers:

Answer

from google map api doc:

Addresses are returned in the order of best to least matches. Generally, the more exact address is the most prominent result, as it is in this case. Note that we return different types of addresses, from the most specific street address to less specific political entities such as neighborhoods, cities, counties, states, etc.

So the problem is that when you add a street number that doesn't exist a no perfect matche(s) return. Here is how to find if a answer is not perfect match:

Again in google doc

partial_match indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address.

If you do some test you will see that when a street number don't exist(or the address is not valid or you don't give enough info for a unique address) it return a variable partial_match:true and one or more close matches, like the picture. enter image description here

I made a simple example with autocomplete and geocoder: http://jsfiddle.net/TomKarachristos/qLyrj38d/, it return "not a valid result" when partial_match is true

if (results[0].partial_match) {
  htmlContent = "not a valid result";
  } else {
  [...]
}

Note: The data of google map maybe will not be 100% accurate.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.