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 a place ID of Ej41MDAgQnVja2luZ2hhbSBQbGFjZSwgRWlnaHQgTWlsZSBQbGFpbnMsIFF1ZWVuc2xhbmQsIEF1c3RyYWxpYQ If I then call the part on this place identifier, it will return 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 return location will be Buckingham Pl, Eight Mile Plains QLD 4113, Australia .

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

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

+5
source share
1 answer

from google map api doc :

Addresses are returned in the order of least matches. As a rule, a more accurate address is the most noticeable result, since it is in this case. Please note that we return different types of addresses, from a particular street address to less specific political objects such as neighborhoods, cities, counties, states, etc.

So the problem is that when you add a street number that does not exist, there is no ideal mat (s). Here's how to find an answer that doesn't fit perfectly:

Google doc again

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

If you run some test, you will see that when the street number does not exist (or the address is invalid or you do not provide enough information for the unique address), it returns the partial_match variable: true and one or more close matches, as in the picture. enter image description here

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

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

Note. Google map data may not be 100% accurate.

+3
source

Source: https://habr.com/ru/post/1247322/


All Articles