问题描述
我在用Angular 8和@agm关闭上面的infoWindow时遇到问题,现在在打开每个窗口时它总是累积,只有在从每个窗口中按X时才能关闭它。
HTML
<agm-map
(mapClick)="close_Window($event)"
[fullscreenControl]="allowFullScreen"
[zoom]="zoom"
(mapReady)="onMapReady($event)"
>
<agm-marker
*ngFor="let poi of stores"
(markerClick)="clicked_Marker(infoWindow)"
[openInfoWindow]="enableAgmWindow"
>
<ng-container *ngIf="enableAgmWindow">
<agm-info-window #infoWindow>
<div class="agm-card__body">
<ng-template *ngTemplateOutlet="agmWindowContainer.template || noTemplate; context: { $implicit: poi }">
</ng-template>
<ng-template #noTemplate let-value></ng-template>
<div class="agm-card__footer"></div>
</div>
</agm-info-window>
</ng-container>
</agm-marker>
</agm-map>
ts
@ViewChild(AgmInfoWindow,{ static: false }) infoWindow;
prevIoUs_info_window: AgmInfoWindow = null;
close_Window() {
if (this.prevIoUs_info_window != null) {
this.prevIoUs_info_window.close();
}
}
clicked_Marker(infoWindow: AgmInfoWindow,index: number) {
//Close prevIoUs window
if (this.prevIoUs_info_window == null) {
this.prevIoUs_info_window = infoWindow;
} else {
this.prevIoUs_info_window.close();
}
this.prevIoUs_info_window = infoWindow;
}
我该怎么办?谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)