Search code examples
angulartypescriptgoogle-mapsagm-map

GoogleMap infowindow close listener


I'm using agm-map in angular to display a map and markers:

<agm-map #map >
    <agm-marker 
        *ngIf="searchDataService.search"
        *ngFor="let store of searchDataService.filteredStores" 
        [latitude]="store.lat" 
        [longitude]="store.lon"
        (markerClick)='select_marker(store, infoWindow)'>
        <agm-info-window #infoWindow >
                <div [ngClass]="['marker-tooltip', 'store-text']">
                    {{store.type}} {{store.id}}<br>
                    {{store.address}}<br>{{store.zip}} {{store.city}}
                </div>
            </agm-info-window>
    </agm-marker>
</agm-map>

is there any way I can set up a listener for when the infoWindow will be closed by clicking the close button in itself? I'm already handling the case when it closes when other marker it's clicked.

I'm also pretty new to angular and web development in general, so I'm struggling to find documentation for (markerClick), so I don't really know what object the infoWindow is. I guess I could figure out myself if I could find the documentation. Any advice on that?

any idea?


Solution

  • You have one event emitter, that might help you,

    <agm-info-window (infoWindowClose)="close($event)">
      <strong>InfoWindow content</strong>
    </agm-info-window>
    

    Reference: https://angular-maps.com/api-docs/agm-core/components/agminfowindow#infoWindowClose