Displaying a zip / postal code in the Google Places auto-complete drop-down list

I experimented with Google Places auto-complete for use on the form, but can't figure out how to display the zip / postal code in the autocomplete drop-down list or the selected input value.

The autocomplete return value contains zipcode, so I can extract it and paste it into the corresponding form input, but it does not appear when the web visitor enters his data.

The goal is to have a very simple form, name, address, phone, email and hide hidden input data (state, city, street, zip code, etc.).

My concern is that if the correct data is sent along with the form, if website visitors do not see their zip code, they will be worried that they did not send the full address.

I found that as soon as you select the correct address, and then go back to enter the zip code, the API inserts the zip in the right place and shows it. But it will not appear when you first enter the address.

Any ideas on the available option that the zip might display first?

+6
source share
1 answer

But it will not appear when you first enter the address

... because it is not available when entering the address. Details for the forecast will be requested when you select an item, and not when you enter anything. Therefore, the answer is simple: it is impossible.

What you can do: create your own autocomplete and fill it with data.

First you need to request predictions through autocompleteService , and then request details through PlacesService.getDetails ()

+5
source

All Articles