iPaul
iPaul

Reputation: 75

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!

Upvotes: 4

Views: 12171

Answers (2)

Fabian Claasen
Fabian Claasen

Reputation: 284

You can add the type=(regions) filter to the url (as query param) and then you can search on postal codes. It is not completely fine because it still can't find all the postal codes I think. But this might be what you need.

Upvotes: 2

pscl
pscl

Reputation: 3402

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.

Upvotes: 3

Related Questions