react-places-autocomplete icon indicating copy to clipboard operation
react-places-autocomplete copied to clipboard

Get result suggestions in countries only

Open sulman2 opened this issue 4 years ago • 2 comments

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(),
  };```

sulman2 avatar May 14 '21 18:05 sulman2

try this?

<PlacesAutocomplete
  searchOptions={{
    componentRestrictions: {
       country: 'US'
    }
  }}
/>

williamtan2251 avatar Jun 04 '21 02:06 williamtan2251

@williamtan2251 works perfectly, thank you! 👌🏼

proshoumma avatar Jun 25 '21 10:06 proshoumma