jquery - limit Google maps of countries in the autocomplete list to "INDIA, USA and UK" -
this code not working. please tell me exact solution
<script src="maps.googleapis.com/maps/api/…; type="text/javascript"></script> <script type="text/javascript"> function initialize() { var input = document.getelementbyid('searchtextfield'); /* restrict multiple cities? */ var options = { types: ['(cities)'], componentrestrictions: {country: ["usa", "uk"]} }; var autocomplete = new google.maps.places.autocomplete(input, options); } google.maps.event.adddomlistener(window, 'load', initialize); </script>
first of all, cannot filter multiple countries. it's known issue reported here.
then code, have use 2 characters string country code :
componentrestrictions can used restrict results specific groups. currently, can use componentrestrictions filter country. country must passed as 2 character, iso 3166-1 alpha-2 compatible country code. source.
here one-country working sample jsfiddled (taken google samples list).
Comments
Post a Comment