使用谷歌地图空闲事件与sebastianm角度2谷歌地图

时间:2017-01-26 11:49:43

标签: google-maps angular google-maps-api-3 angular2-google-maps

enter image description here看到我可以在我的Compnent Class中为 sebastianm angular 2 google maps 加载google maps API,如:

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

        });

我想使用google maps事件,例如在我的Component Class中,我有一个由click事件触发的成员函数,在这个函数中我想听 idle < / strong>事件如:

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
        });
        })

}

我是使用谷歌地图API的新手,我很难获得 addListener / addDomListener 等功能所需的地图对象,我如何获得必需的地图对象,这是google maps API中所述的 addListener / addDomListener 的第一个参数。 提前致谢

0 个答案:

没有答案