I'm using the geocomplete.js API along with the google maps api.
searching for auto complete addresses, suburbs or anything works, and when I press the enter key the fields are auto filled.
My problem is when I try to fire off the enter key programmatically, it doesnt register as the user having pressed enter. so the text boxes dont fill with geolocation details as they normally would if i were to physically press enter.
How can I auto input into the text field and gather the results from the dropdown automatically?
here is the code
<input type="text" id="inputmap" />
<div id="map"></div>
<form action="" id="mapform">
latitude: <input type="text" data-geo="lat" /> <br>
longitude: <input type="text" data-geo="lng" /> <br>
Address: <input type="text" data-geo="formatted_address" /> <br>
Country: <input type="text" data-geo="country" /> <br>
Country Code: <input type="text" data-geo="country_short" /> <br>
PCode: <input type="text" data-geo="postal_code" /> <br>
Locality: <input type="text" data-geo="locality" /> <br>
Sub-Locality: <input type="text" data-geo="sublocality" /> <br>
</form>
<script>
$('#inputmap').geocomplete({
map: '#map',
details: '#mapform',
detailsAttribute: "data-geo"
});
$(document).ready(function()
{
var e = jQuery.Event("keydown");
e.keyCode = 50;
setTimeout(function()
{
$('#inputmap').val("sydney").focus();
}, 1000);
setTimeout(function()
{
$('#inputmap').trigger(e);
alert("pressed");
}, 3000);
});
</script>