Google Places Address Autocomplete

This short and simple tutorial will teach you how to enable Google Places address autocomplete on any text input field. I have been asked many times to add the address autocomplete feature to the search forms created by GEO my WP. This tutorial will make it easy to do. Here you can learn more about Google places services.

To start using Google Places API you will first need to call its library. If you are using Geo my WP or any of the other plugin that uses Google API ( Gravity Forms GEO Fields, Geo Job Manager and so on ) the library is already included and so you can skip this part. Otherwise you will need to include the library yourself. To do so copy paste the script below to the functions.php file of your theme/child them.

Below is the script that generates the address autocomplete. Again, add the script below to the functions.php file of your theme/child theme. The only thing you will need to modify in the code is the gacFields array. This array holds the ID tag of all the input text fields which you'd like to use the address autocomplete on. And so you will need to change the fields "gmw-address-1", "gmw-address-7" to any of your fields. After done so you can test the input field for the address autocomplete.