[Tips & Scripts] Google Address Autocomplete

  • 13 October 2016
  • 36 replies
  • 1233 views


Show first post

36 replies

@Noah I’ve found the iOS white-out issue only happens when using it in a lightbox for me (so far). Can you help me investigate?

I’m experiencing the same glitch it seems. Was there a resolution?

Userlevel 7

Hey @Kelly_Konechny, I’m not able to reproduce this issue at the moment. I’ve followed up with you directly, so check your inbox!

@Noah this script is great and does exactly what we need it to do. We are finding that it doesn’t as intended on iOS mobile devices. When you enter the start of an address the mobile screen goes all white and the experience is lost.

Do you have an update that might fix this issue?

Thanks in advance…

ktk

Noah this is a fantastic script, thank you.

Would like to now take it a step further now - perhaps this should be in a different thread but I am not sure. Once the user hits submit, I would like to pass the address information to the next page and on that page display a google maps street view of the address they had entered on the prior page.

For example check this page out - http://dallas.quickpropertyappraisal.com/. Enter an address and then the following page will have it appear on street view. Very cool.

Thoughts?

Thanks

Userlevel 7

Haha! So glad I could help 😀

Thanks Noah, you are my hero! I was half a day, literal, looking for this solution.

Userlevel 7

@maurexyz this involves making a small change to the code. You will need to find the spot where the ‘autocomplete’ object is being created (should be around line 64-67). It should look like this:

autocomplete = new google.maps.places.Autocomplete(
 /** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
 {types: ['geocode']});

Once you’ve found this, you will then need to add your country restriction. For example, if you were restricting the autocomplete function to France, you would need to add:

componentRestrictions: {country: 'fr'}

Update ‘fr’ with the country code of your choosing. Once this is added, the final code will look like:

autocomplete = new google.maps.places.Autocomplete(
 /** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
 {types: ['geocode'], componentRestrictions: {country: 'fr'}});

I hope this helps!

@Noah what do I have to modify to restrict the results to only one country? 🙏 Thank you

Userlevel 7
Badge +4

Thanks @Noah! <3 this

YES!! Finally, some auto-complete magic. Love it @Noah! 🙌

Reply