-1

I am using Google Autocomplete Place API it is working fine by using the below piece of code.

autocompleteform = new google.maps.places.Autocomplete(
             (document.getElementById('autocomplete')),
                {}
            );

Now the issue is it is auto-suggesting addresses from the whole world. I want to show the result of a particular country let say Switzerland, how to do this?

ishaq
  • 65
  • 7
  • Your question is not about Google Cloud Platform. You should change the tag to "google-places", "google-places-api" or similar. – John Hanley Aug 30 '21 at 19:28
  • 2
    Duplicate of [How to limit google autocomplete results to City and Country only](https://stackoverflow.com/questions/8282026/how-to-limit-google-autocomplete-results-to-city-and-country-only) – MrUpsidown Sep 13 '21 at 10:09

1 Answers1

0

I solved this myself using API documentation and example. Here is the line of code that I added.

/* Restrict to switzerland only */
 autocompleteform.setComponentRestrictions(
     {
         'country': ['CH']
      }
 );
ishaq
  • 65
  • 7