Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places autocomplete API not returning postal codes

I have been googling this for hours and I have not found a solution. When I call:

"https://maps.googleapis.com/maps/api/place/autocomplete/json?input="+WebUtility.UrlEncode(MYADDRESSSPEC)+"&key="+MYAPIKEY;

I get things like:

123 Main St, Somewhere, Ohio United States
123 Main St, Somewhere Else, Indiana, United States

I've looked at the optional arguments and I cannot find one for ZIP/postal code. I noticed the textsearch API does return ZIP codes. I could run it through autocomplete as someone is typing the address and THEN run each result through the textsearch API but I want to accomplish this in just ONE web service call. Does anyone know how? Thanks in advance!

like image 327
iPaul Avatar asked Oct 25 '25 04:10

iPaul


1 Answers

I don't think the autocomplete API supports returning postcodes in the predictions array. Your best bet (albeit cumbersome) is to do the autocomplete query and run a details query for each of the place_id entries returned.

like image 92
pscl Avatar answered Oct 27 '25 01:10

pscl