Bienvenido, Invitado
Recordarme

TEMA:

Tutorial: Use the Autocomplete for Addresses Google API 9 meses 4 días antes #252944

  • Autor del tema
  • zeroalpha
  • Fuera de línea
  • Fresh Breezer
  • Fresh Breezer
  • Mensajes: 11
  • Gracias recibidas: 1
Thought I would write a basical tutorial to help anyone who wants to use the Google API Autocomplete for addresses in their form which looks like this:


developers.google.com/maps/documentation.../places-autocomplete

This is for a simple one line textfield.

You will need a google API Key: developers.google.com/places/web-service/get-api-key

Now go to your breezingforms>manage form>select your form>Advanced>more options>Form pieces>Before Form>Select Custom

Add this line:
echo '<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=ADDYOURGOOGLEAPIKEYHERE&libraries=places"></script>';

Make sure you replace ADDYOURGOOGLEAPIKEY with your actual key. Your code should look like this:



Now add this javascript to: Scripts>Initialize Script>Select Custom
function init() {
    var input = document.getElementById('ff_elem???');
    var autocomplete = new google.maps.places.Autocomplete(input, options);
    }
google.maps.event.addDomListener(window, 'load', init);

You will need to find your element ID your using for addresses. I simply found it with 'View Source' from my browsers html code or from your website you can Right-Click>Inspect :


Your code should look like this:



CONGRATULATIONS! You now have a working address lookup autocomple working on your form
El siguiente usuario dijo gracias: v8tom

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Tutorial: Use the Autocomplete for Addresses Google API 9 meses 4 días antes #252949

  • Avatar de tihana.krivic
  • tihana.krivic
  • Fuera de línea
  • Moderator
  • Moderator
  • Mensajes: 7379
  • Karma: 3
  • Gracias recibidas: 528
Hi,

thanks for sharing this :)

Regards,
Tihana

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

  • Página:
  • 1
Moderadores: ForumSupport
Tiempo de carga de la página: 0.116 segundos