Need multi-page country components in Google Places auto-complete

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

My page is copy-paste from Post a sample autofill form :

+6
source share
3 answers

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

Now you can restrict Autocomplete predictions to just a few countries. You can do this by specifying up to 5 countries in the componentRestrictions field of the AutocompleteOptions object.

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

+8
source

Starting with version 3.2.7, you can use an array for componentRestrictions. For instance:

 { country: ["fr","ch","be"] } 

However, the number of countries is limited to 5.

+6
source

Be careful, because if you are limited to "FR", it ignores the French departments. To have cities in all of France, you need:

 'fr', 'gp', 're', 'mq', 'gf', 'nc', 'yt', 'pf' 

But since it is more than 5, it is impossible to limit the whole of France.

Google Maps believes the French overseas departments are not in France; this is a big problem.

0
source

All Articles