Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to restrict search to only cities? #87

Open
haidepzai opened this issue Apr 25, 2021 · 1 comment
Open

How to restrict search to only cities? #87

haidepzai opened this issue Apr 25, 2021 · 1 comment

Comments

@haidepzai
Copy link

Hi,

I really like this autocomplete function and I want to limit my search to cities only.
I tried with this solution here

[options]="{ types: ['(cities)'], componentRestrictions: {country: 'us'} }"

But it says
Type '{ types: string[]; componentRestrictions: { country: string; }; }' is missing the following properties from type 'Options': bounds, fields, strictBounds, origin

So I tried with that option

public options: Options ={ bounds: undefined, fields: [""], strictBounds: false, types: ['cities'], componentRestrictions: {country: ''} };

But bounds cannot be undefined. I am not sure if the options are correct but I just want to limit my search to city only

@mayurgudi
Copy link

Hi,

I really like this autocomplete function and I want to limit my search to cities only. I tried with this solution here

[options]="{ types: ['(cities)'], componentRestrictions: {country: 'us'} }"

But it says Type '{ types: string[]; componentRestrictions: { country: string; }; }' is missing the following properties from type 'Options': bounds, fields, strictBounds, origin

So I tried with that option

public options: Options ={ bounds: undefined, fields: [""], strictBounds: false, types: ['cities'], componentRestrictions: {country: ''} };

But bounds cannot be undefined. I am not sure if the options are correct but I just want to limit my search to city only

Try this ...

myOptions: any; // class variable

constructor() {
this.myOptions = new Options({ types: ['(cities)'], componentRestrictions: {country: 'us'} });
}

In HTML ,
<input type="text" ngx-google-places-autocomplete [options]="myOptions">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants