I'm using Google Maps Places V3 autocomplete. I would like to have a functionality where if a user starts typing an word into the searchfield and press enter , the first item from the autocomplete drop down is should be selected. like on http://www.onradpad.com/.
I have found many threads on SO on this topic but i cant get the exact results.Help me with this issue.
<!doctype html>
<html>
<head>
<script src="http://maps.google.com/maps/api/js?libraries=places®ion=uk&language=en&sensor=false"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e){
var compformautoaddrfill = new google.maps.places.Autocomplete(document.getElementById('compAddr'), {
componentRestrictions: {country: "be"}
});
google.maps.event.addListener(compformautoaddrfill, 'place_changed', function() {
console.log(compformautoaddrfill.getPlace().address_components.length,compformautoaddrfill.getPlace());
});
});
</script>
</head>
<body>
<input type="text" id="compAddr">
</body>
</html>