Address Search Using Google Search Autocomplete With Restricted Countries



We can easily search the particular address with Street No,Street,City,State and Country using google search autocomplete, below my code is implement in ruby on rails






Here my java script

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

<script type="text/javascript">
 // script for address autocomplete search
$(function(){
    var autocomplete;
    var geocoder;
    var input = document.getElementById('advertiser_address');
    var options = {
      componentRestrictions: {'country':'us'}
    };

    autocomplete = new google.maps.places.Autocomplete(input,options);
});
</script>

here componentRestrictions says that we can search only particular country addresses.  

No comments:

Post a Comment