I am asking a question that many people ask, but no one gave a clear answer, almost on AGM (Angular 2 package for Google map)
Here is my code, but my first opened marker does not want to close, and the other markers close half the time
clickedMarker(marker: Marker, infoWindow, index: number) {
if (this.infoWindow && this.infoWindow !== infoWindow) {
this.infoWindow.close();
}
this.infoWindow = infoWindow;
}
Can someone help me to fix this close problem, using the close function or the event emitter https://angular-maps.com/api-docs/agm-core/components/AgmInfoWindow.html#source
Thanks for your time and help ;)
EDIT : FOUND THE ANSWER
I had my <agm-info-window #infoWindow> displaying multiple information using <a *ngIf="myCondition"..>{{address}}</a> but it looks like it was not rendering the popup when the condition was evaluate to true again.
I replaced it by <a [class.hidden]="!myCondition">..</a> and it fixed the multiple display of markers.
Another good practice is to close when there is a click on map, and to close it if opened :
clickedMap($event) {
if (this.infoWindow) {
this.infoWindow.close();
}
}
It might help in the future... who knows ?