Google maps api geocoder - restrict to multiple countries
Asked Answered
E

0

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

Eyecup answered 19/7, 2018 at 13:3 Comment(3)
Please provide error traceback.Subjunctive
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. developers.google.com/maps/documentation/javascript/examples/…Carve
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!Ketch

© 2022 - 2024 — McMap. All rights reserved.