我目前正在使用Angular 6开发仪表板。我的仪表板实现了带有标记和详细信息的地图(使用AGM)(使用snazzy-info-window插件)。
我目前无法将回调函数传递给名为“ afterOpen”的属性,该属性可通过snazzy-info-window使用...
有人可以帮我吗?我整个下午都在抓这个问题!
这是我的HTML:
<agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
<agm-marker *ngFor="let m of mobis; let i = index" [latitude]="m.lat" [longitude]="m.lng">
<agm-snazzy-info-window [maxWidth]="15" [closeWhenOthersOpen]="true" (afterOpen)="infoWindowClicked()">
<ng-template>
<img src="../../assets/mobi-info-logo.png" srcset="../../assets/mobi-info-logo@2x.png 2x,
../../assets/mobi-info-logo@3x.png 3x" class="mobi-info-logo">
<div class="mobi-info-name">{{m.name}}</div>
<div class="mobi-info-battery">
<img src="../../assets/empty-battery-icon-png.png" class="toolbar-logo" style="right: 1vh;">
<div class="centered">{{m.battery_lvl}}%</div>
</div>
<div class="mobi-info-name">4 kms parcourus</div>
<div class="mobi-info-button" (click)="sidenav.toggle()">ACTION</div>
</ng-template>
</agm-snazzy-info-window>
</agm-marker>
</agm-map>
这是TS:
infoWindowClicked(): void {
console.log('Info window has opened.');
console.log(this)
}
我想要的是,当我单击显示在地图上的一个标记时,将调用“ infoWindowClicked”函数,这样我就知道该标记已被单击,并且可以通过打印“ this获得此信息在控制台中(如github的库中的说明:https://github.com/atmist/snazzy-info-window#callbacks)