I have one text field and I am using two different autocompletion methods depending on selected radion button(first option: google maps api, second option: twitter-typeahead). My question is how to disable google maps autocompletion?
$('#search_type_name').click(function(){
google.maps.event.clearInstanceListeners(geoAutocomplete);
$("#local").typeahead(null, {
displayKey: 'name',
source: numbers.ttAdapter()
});
});
$('#search_type_address').click(function(){
$("#local").typeahead('destroy');
$("#local").off();
geoAutocomplete = new google.maps.places.Autocomplete(
(document.getElementById('local')),
{types: ['geocode']}
);
geoAutocomplete.addListener('place_changed');
});
You must also remove the listeners bound to the <input>
google.maps.event.clearInstanceListeners($("#local")[0]);
Currently you only remove the listeners of the Autocomplete-instance(place_changed
), but not the listeners that have been added by the Maps-API(key-events, focus, blur etc.)