I have an input field with google autocomplete attached on it. I'd like to populate this field with some default values, focus the input and automatically open the prediction box below the input.
I obviously have no problem setting the input value and focus, but I can't find a way to open the suggestions box. It opens on any user keypress; anyway, simulating the keypress event on the input didn't work.
So I'm wondering if there's a way to trigger the event that makes the autocomplete box show up.
I have the following example code:
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
<input type="text" id="q" />
JS:
var input = document.getElementById('q');
var autocomplete = new google.maps.places.Autocomplete(input);
$('#q').val('Rome, ').focus();
// how to open suggestions box ?