Hi,
I'm interested in restricting search to a country. Is this possible using this plugin?
Thanks
Tim
Hi @Roconda
Thanks for your interest!
After looking at Google Places Autocomplete API Docs I can say that it does support restricting the search query.
Try passing (country) to the query.types prop:
var Example = React.createClass({
render() {
return (
<GooglePlacesAutocomplete
query={{
key: 'YOUR API KEY',
language: 'en', // language of the results
types: '(country)', // default: 'geocode'
}}
If that answers your question, please consider closing this issue.
Thanks,
Max
Hi @myaskevich,
Thanks for your response! I wasn't probably clear enough what I ment with restricting to a country. Currently I'm creating an app which only supports The Netherlands. So all I want to do is search to locations located in The Netherlands.
The types: 'country' property only supports searching to countries if I understand it correctly, right?
Thanks,
Tim
Hello @Roconda and @myaskevich,
I believe the default way of restricting the country is through componentRestrictions: {country: 'whatever_country'} and I attempted to do it the default way, but it seems like this implementation of autocomplete doesn't support this feature? Could you clarify @myaskevich if this is true?
Hey @Roconda @yangster24
Thanks, now it's much clearer for me.
I just got the component to restrict all results to the Netherlands out of box by using query.components prop:
var Example = React.createClass({
render() {
return (
<GooglePlacesAutocomplete
query={{
key: 'YOUR API KEY',
components: 'country:nl'
}}
See components optional autocomplete query parameter for more info.
Thank you very much @myaskevich, this is exactly what I needed!
This doesn't seem to work for me
query={{
language: "en",
components: "country:uk",
}}
But it still brings up addresses for any country...
This doesn't seem to work for me
query={{ language: "en", components: "country:uk", }}But it still brings up addresses for any country...
If you want to search in United Kingdom only, I think you should use GB (Great Britain) according to ISO 3166
Most helpful comment
Hey @Roconda @yangster24
Thanks, now it's much clearer for me.
I just got the component to restrict all results to the Netherlands out of box by using
query.componentsprop:See
componentsoptional autocomplete query parameter for more info.