user2954587
user2954587

Reputation: 4861

Google Maps Autocomplete API

I'm trying to get the drop down autocomplete working.

It seems like I should be able to start tying now and the textbox will begin to autcomplete. Right now nothings happening.

var autocompleteOptions = {
componentRestrictions: {country: 'us'}
};

var startInput = $('#start')

var autocompleteStart = new google.maps.places.Autocomplete(startInput, autocompleteOptions);

HTML

<input class="input-box form-control" type="text" id="start" value="Current Location">

Upvotes: 1

Views: 370

Answers (1)

daveoncode
daveoncode

Reputation: 19578

You have to pass an actual DOM node not a jQuery object to the Autocomplete. Try this:

var node = startInput.get(0);
var autocompleteStart = new google.maps.places.Autocomplete(node, autocompleteOptions);

Upvotes: 2

Related Questions