6

Im using google geocoder and I want to restrict result to some countries (for example I don't want to search in USA).

Using:

componentRestrictions: {
                  country: 'de'
}

Works fine, but I would like to add more countries, tried passing array:

componentRestrictions: {
                  country: ['de','at','ch']
              }

But it gives an error

Is there anyway to add more than one country to restrictions?

Thanks

kroma
  • 103
  • 1
  • 2
  • 9
  • Please provide error traceback. – kchomski Jul 19 '18 at 13:13
  • 1
    I'm currently looking for an answer to this too. For now, it appears that the Geocoding API doesn't accept an array of countries like the places.Autocomplete does. https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-multiple-countries – Dryden Long Dec 19 '18 at 23:57
  • 3
    Sorry to revive an old question, but if anyone stumbles across this, using the python library, I needed to add `components=country:DE` to the request url. Did it like this: `googlemaps.Client(key='my_key', requests_kwargs={'params': {'components': ['country:DE']}}` Hope this helps someone! – RHSmith159 Apr 18 '19 at 14:00

0 Answers0