Use google maps idle event with the sebastianm angular 2 google maps

628 Views Asked by At

enter image description hereAfter seeing that i can load the google maps API in my Compnent Class for the sebastianm angular 2 google maps like:

this.mapsAPILoader.load().then(() => {
        let autocomplete = new google.maps.places.Autocomplete(this.searchElementRef.nativeElement, {
            types: ["(regions)"],
            componentRestrictions: {country: "za"}

        });

I would like to use the google maps events, For example in my Component Class, i have a member function that's triggered by a click event, in this function i wanted to listen to the idle event like:

getMessage(): void {
         this.myService.getMessage().then((res) => {     
         this.map = res;
         this.lat = this.map.maps[0].geometry.location.lat;
         this.lng = this.map.maps[0].geometry.location.lng;
         console.log(this.lat,this.lng);  
         google.maps.event.addListener(map, 'idle', function() {
           //HERE I WANT TO SCROLL to THE MAP ELEMENT IN THE DOM
        });
        })

}

I am new to using the google maps API and i am struggling to get the map object that is required by functions like addListener/addDomListener, how do i get the required map object which is the first parameter for the addListener/addDomListener as stated in the google maps API. Thanks in advance

0

There are 0 best solutions below