When you enter some text in SearchBox it will show you a drop-down with a few choices but if you instead press Enter button it will return most corresponding answer immediatelly.
How to achieve this behavior programatically?
I tried to emulate press Enter event on this control and calling .getPlaces() method manually but nothing happens.
Is there any solution for this problem?
It seems that the listeners for the searchBox will be bound on focus and removed on blur.
So you must first trigger the focus-event and then the keydown-event of the input associated with the searchBox.
When you trigger the keydown-event, pass as argument an object with the property keyCode:13
//input associated with the searchBox
var input = document.getElementById('pac-input');
google.maps.event.trigger( input, 'focus')
google.maps.event.trigger( input, 'keydown', {keyCode:13})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With