Integrating Google places api data


#1

Hi,

Here’s how to integrate google places api data into LeadsHook. It works well, apart from only recording partial city entry, upon submitting the form (instead of the complete data provided by google places).

For example, if I type in “Las”, then google automatically finds “Las Vega, NV”. Upon clicking the appropriate choice, from the dropdown, “Las Vega, NV” shows as the value. But, when I click the next button, only “Las” is stored in the custom field.

I can script something to force the value to be stored. But, it occurred to me, I might be missing something obvious. Is there a simpler way to achieve this?

VIDEO - https://cl.ly/a5c041d84ffc

STEPS:

  1. Follow these instructions to get a google maps api key:
    https://developers.google.com/maps/documentation/javascript/get-api-key

  2. Create “city” custom field in LeadsHook

  3. Add input with id=“city-search” and name=“city”
    <p>The city I live in is <input id="city-search" name="city" placeholder="Enter a city" type="text" /></p>

  4. Add google places api script to node, to trigger upon entry
    <script> function initMap() { var citySearch = document.getElementById("city-search"); var autocomplete = new google.maps.places.Autocomplete(citySearch); } </script>

<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY_HERE&libraries=places&callback=initMap"></script>

  1. Lock down your api by restricting access to certain domains

#3

Hi @Wynne_Pirini,

Our current feature didn’t work for you?

Does it need an enhancement?

image

Nik


#4

Oh, whoops :slight_smile:

I didn’t see this feature there. No, I don’t think it needs improving. It looks really nice.

Thanks Nik.


#5

Hi @Wynne_Pirini,

You’re a power user so I figured you’re messing with code because something was missing.

I guess that’s your hammer! :slight_smile:

Here’s the article on email, phone and address verification with links to detailed setup instructions.

Hope you’re well.

Nik


#6

Hi Nik,

I admit, I was interested in figuring out how the google places worked, in general.

Thanks for the knowledgebase link.

And, I’m doing well thanks. Hope you’re well, too :slight_smile:

Cheers,
Wynne