0

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

Thabo
  • 1,303
  • 2
  • 19
  • 40
  • It's not the `this.map` variable you create on line 2 of the getMessage method, or `this.map.maps[0]`? – duncan Jan 26 '17 at 13:36
  • I am not sure, but that is a response from the NodeJS server i am using the Google maps client in the server – Thabo Jan 26 '17 at 13:39
  • Or perhaps it is the thing is i am not sure if that object is of the Maps type – Thabo Jan 26 '17 at 13:41
  • what does `console.log(this.map)` give you? – duncan Jan 26 '17 at 13:43
  • @duncan, i am AFK now can i reply again later? i will attach a screenshot of the response from the developer tools or just the JSON object i am getting from the server as a comment here – Thabo Jan 26 '17 at 13:55
  • Yes perfect, in your own time! – duncan Jan 26 '17 at 14:43
  • @duncan forgive me for the wait, i have edited my question, i've added the picture that show the response – Thabo Jan 26 '17 at 18:23
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/134117/discussion-between-teebo-and-duncan). – Thabo Jan 26 '17 at 19:59

0 Answers0