Google Places Autocomplete API filter by multiple countries

google-places-api, javascript

Solution

The Google Places API does not currently support this feature. If you believe this would be a useful feature you can submit a 'Places API - Feature Request' here.

UPDATE

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

Problem

Looking for a way to filter the autocomplete results filtered by 2 countries, Canada and US. Currently I can only filter by one or the other with options 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 restrict autocomplete results to 2 countries. Any help is appreciated.

Original source