javascript - Fire a fuction after Google Maps AutoComplement -


im trying run function after user select address on google address list. tried onblur action fire before user select address giving me incomplete one.

i read these topics:

how fire place_changed event google places auto-complete on enter key

google places api - place_changed listener not working

events other 'place_changed' google maps autocomplete

and tried place_changed still cant run function.

html

<html>  <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">     <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=edited(my key)&libraries=places"></script><script src="mapa.js" language="javascript" type="text/javascript"></script> <script type="text/javascript" src="jquery-ui.custom.min.js"></script> <script type="text/javascript" src="jquery.min.js"></script>  </head>  <body>             <input type="text" name="street" id="0" onfocus="autocomplete(this);">   </body> </html> 

javascript

function autocomplete(adress) {      var input = document.getelementbyid(adress.id);     var options = { componentrestrictions: {       country: 'fr'      }};      new google.maps.places.autocomplete(input, options);      google.maps.event.addlistener(gmaps, 'place_changed', function () {        getplace(adress);      });  }  function getplace(adress) {    alert(adress.value);    } 

what missing?

for alternative solution there anyway make onblur or onchange fire after user select on auto complete list? better solution problem think.

any appreciated.

ok saw missing.

on new google.maps.places.autocomplete(input, options); had save on variable gmaps = new google.maps.places.autocomplete(input, options); , call on listener:

google.maps.event.addlistener(gmaps, 'place_changed', function () {    getplace(adress);  }); 

rookie mistake.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -