NotoriousWebmaster
NotoriousWebmaster

Reputation: 3578

Google Maps Autocomplete this.setValues is not a function

Trying to get Autocomplete working. Set up a test page, just HTML and JS, but still getting the "this.setValues is not a function" error. Here's the code:

<!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <input type="text" id="place">

    <script src="https://maps.googleapis.com/maps/api/js?key=API-KEY&libraries=places"></script>

    <script>
      var place = document.querySelector('#place');
      console.log(place);
      var dropdown = google.maps.places.Autocomplete(place);
    </script>
  </body>
</html>

Here's the error: this.setValues is not a function error

Upvotes: 0

Views: 932

Answers (1)

Christopher Werby
Christopher Werby

Reputation: 910

Hi NotoriousWebmaster,

I believe that the problem is that you didn't use the "new" keyword when defining the dropdown variable. Try this: var dropdown = new google.maps.places.Autocomplete(place);

Upvotes: 3

Related Questions