hibiken / react-places-autocomplete

React component for Google Maps Places Autocomplete
https://hibiken.github.io/react-places-autocomplete/
MIT License
1.38k stars 388 forks source link

Get result suggestions in countries only #369

Open sulman2 opened 3 years ago

sulman2 commented 3 years ago

Feature request

I can't search for countries

I should be able to add country as searchOption Types and get result in countries level.

I want the results in countries like if i put cities option then i get cities level suggestions but there is no option for countries or i might be doing wrong. i have checked the places api documentation but couldn't do anything


    if (streetAddress) {
      return ["address"];
    } else if (country) {
      return ["country"]; // Have also tried 1. 'country' 2. '(country)' 3. ['locality','country'] and ['countries'] etc
    } else {
      return ["(cities)"];
    }
  };
  const searchOptions = {
    types: checkType(),
  };```
williamtan2251 commented 3 years ago

try this?

<PlacesAutocomplete
  searchOptions={{
    componentRestrictions: {
       country: 'US'
    }
  }}
/>
proshoumma commented 3 years ago

@williamtan2251 works perfectly, thank you! 👌🏼