GithubHelp home page GithubHelp logo

Comments (3)

derciesto avatar derciesto commented on June 10, 2024

hi
facing the same issue for a temporary solution is making parameter to optional
file path node_modules\ngx-google-places-autocomplete\objects\options\options.d.ts
import { LatLng } from '../latLng';
import { LatLngBounds } from "../latLngBounds";
import { ComponentRestrictions } from "./componentRestrictions";
export declare class Options {
bounds?: LatLngBounds;
componentRestrictions: ComponentRestrictions;
types: string[];
fields: string[];
strictBounds: boolean;
origin?: LatLng;
constructor(opt?: Partial<Options>);
}

its works for me

from ngx-google-places-autocomplete.

Cassidie avatar Cassidie commented on June 10, 2024

@derciesto Thank you for the information! However, I'm not understanding what you mean, or how it fixes the problem. Could you elaborate? What parameter are you referring to that would help restrict countries by becoming optional?

from ngx-google-places-autocomplete.

Cassidie avatar Cassidie commented on June 10, 2024

For anyone that was also having trouble with this, what I was doing was trying to set the options on the HTML input element as so:
<input type="text" [attr.options]="autocompleteOptions">

That does NOT work. I found an example in the repo that shows you can manually set the places options using ViewChild in ngAfterViewInit. This worked for me, successfully isolated the country.

In template:
 <input type="text" ngx-google-places-autocomplete #places="ngx-places" (onAddressChange)="onChange($event)" />

In Component:
 @ViewChild('places') public placesDirective!: GooglePlaceDirective;

  public ngAfterViewInit() {
    this.placesDirective.options.types = ['address'];
    this.placesDirective.options.componentRestrictions = { country: 'us' };
  }

Hope this helps someone else!

from ngx-google-places-autocomplete.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.