Google Places AutoComplete API Filter by Multiple Countries

Looking for a way to filter autofill results filtered by two countries, Canada and the USA.

Currently, I can only filter one or the other with parameters like this ...

var options = { types: ['(cities)'], componentRestrictions: {country: 'us'} } var autocomplete = new google.maps.places.Autocomplete(input,options); 

... but I have not seen any documentation that explains how to limit autocomplete results to two countries.

Any help is appreciated.

+4
source share
1 answer

The Google Places API does not currently support this feature. If you think this will be a useful feature, you can send here the "Place API" - "Request Function" here .

UPDATE

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 https://developers.google.com/maps/documentation/javascript/reference#ComponentRestrictions

+7
source

All Articles