Ankur Verma
Ankur Verma

Reputation: 5933

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.........

:(

Upvotes: 3

Views: 5105

Answers (1)

Marcelo
Marcelo

Reputation: 9407

You need to add the places library when you load the API.

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

Upvotes: 6

Related Questions