When you type within the input box, google places autocomplete API helps you find similar places quickly by displaying searches that might be similar to the one you're typing. It provides your applications with the type-ahead-search behavior, the Google Places autocomplete is a feature of the Google Places API.
Here is the implementation of google places autocomplete API.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true"></script>
$(document).ready(function()
{
// Google Places Autocomplete
var pickUpAddress = document.getElementById('pickUpAddress');
// prevents enter key to submit form//
$('#pickUpAddress).keydown(function (e)
{
if (e.which == 13 && $('.pac-container:visible').length) return false;
});
function initialize()
{
var options = {
types: ['geocode'],
componentRestrictions: {country: "usa"} // For Particular country, please change accordingly
};
var autocomplete = new google.maps.places.Autocomplete(pickUpAddress, options);
}
google.maps.event.addDomListener(window, 'load', initialize);
});
0 Comment(s)