Search code examples
google-mapsgoogle-maps-api-3

Need multiple country componentRestrictions in Google Places Autocomplete


I need Google Places Autocomplete to give me results from countries: SZ, FR, DE, AT, IT. I know that componentRestrictions can operate with only one country. So, is there a way to get results with multiple counties in Google Places Autocomplete?

My page is copy-paste from Place Autocomplete Address Form example:


Solution

  • This feature was introduced in version 3.27 of Maps JavaScript API in January 2017:

    You can now restrict Autocomplete predictions to only surface from multiple countries. You can do this by specifying up to 5 countries in the componentRestrictions field of the AutocompleteOptions.

    https://developers.google.com/maps/documentation/javascript/releases#327