我使用
Angular Google Maps(AGM)组件.
我需要在标记鼠标悬停上打开信息窗口.
如何在我的函数onMouSEOver中检索infowindow实例以打开它?
我需要在标记鼠标悬停上打开信息窗口.
如何在我的函数onMouSEOver中检索infowindow实例以打开它?
<agm-map [fitBounds]="latlngBounds" [zoom]="15"> <agm-marker *ngFor="let m of markers; let i = index" [latitude]="m.geoCode.latitude" [longitude]="m.geoCode.longitude" (mouSEOver)="onMouSEOver(m)" > <agm-info-window [disableAutoPan]="false"> <div> <a (click)="onClickInfoView({id:m.id})" class="btn btn-attention pull-right">test<i class="fa fa-angle-double-right"></i></a> </div> </agm-info-window> </agm-marker> </agm-map> onMouSEOver(data) { ???? /* how to open here the info window? }
最后我找到了一个解决方案:
<agm-map #gm [fitBounds]="latlngBounds" [zoom]="15"> <agm-marker *ngFor="let m of markers; let i = index" [latitude]="m.geoCode.latitude" [longitude]="m.geoCode.longitude" (mouSEOver)="onMouSEOver(infoWindow,gm)" > <agm-info-window [disableAutoPan]="false" #infoWindow> <div> {{m.name}} {{m.rating}} </div> <div> <a (click)="onClickInfoView({id:m.id})" class="btn btn-attention pull-right">Daje <i class="fa fa-angle-double-right"></i></a> </div> </agm-info-window> </agm-marker> </agm-map> onMouSEOver(infoWindow,gm) { if (gm.lastOpen != null) { gm.lastOpen.close(); } gm.lastOpen = infoWindow; infoWindow.open(); }