在页面加载时获取谷歌自动完成API值

时间:2014-04-16 14:19:10

标签: javascript jquery google-maps google-maps-api-3

var autocomplete = new google.maps.places.Autocomplete(input, optionsAuto);

google.maps.event.addDomListener(window, 'load', function(){
  //get the autocomplete input value here
  //I want to use autocomplete.getPlace() here

});

我可以使用' place_changed'侦听器传递自动完成对象,但在刷新页面时无法获取值。

1 个答案:

答案 0 :(得分:0)

尝试使用javascript DOMContentLoaded

document.addEventListener( "DOMContentLoaded", function(){
   //get the autocomplete input value here
   //I want to use autocomplete.getPlace() here
});