Google Search Places Auto Complete

Google Search Places Auto Complete

HTML

<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places" type="text/javascript"></script>


      <input id="searchTextField" type="text" size="50" placeholder="Enter a location" autocomplete="on">

JavaScript

function initialize() {
var countryChosenCode = 'in' // from country
 var options = {
  types: ['(cities)'],
   componentRestrictions: {country: countryChosenCode }

 };

 var input = document.getElementById('searchTextField');
 var autocomplete = new google.maps.places.Autocomplete(input, options);
}

 google.maps.event.addDomListener(window, 'load', initialize);