简体   繁体   中英

Google maps autocomplete not working

I want to get the auto complete behaviour of the Google maps, but I am not getting the exact reason why it is showing this

* Uncaught TypeError: Cannot read property 'Autocomplete' of undefined *

where as I used this

  var addressValue = document.getElementById('geoFenceAddress');
  alert(addressValue);
  var autocomplete = new google.maps.places.Autocomplete(addressValue);
  autocomplete.bindTo('bounds', geoFenceAddress);

I have an element with id ' geoFenceAddress ' and infact the alert is showing this [Object HTMLInputElement] .

I am not understanding where I am lacking , please shed some light.........

:(

您需要在加载API时添加场所库。

<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM