5
votes

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

1
How are you doing the search? Are you using the web service or the Google Maps Javascript API v3 Places Library?geocodezip
@geocodezip I have added an API call exampleTimothy Ruhle
i don't understand the problem. What do you will like to put in and what to get as answer exacly?Thomas Karachristos
@TomKarachristos It is returning a result from the autocomplete api for a street number that does not exist. I do not want it to return results in this case. In my example Buckingham Place only goes up to a street number of 52, but you can search for anything number above that and the autocomplete api will still return it as a valid place. This happens for all streets.Timothy Ruhle

1 Answers

4
votes

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.