I'm trying to have a map with multiple markers each with an infowindow.
Nothing fancy so far.

All infowindows should open onload.
No problem.

And every infowindow should close if I click

on its own marker

on the X in its infowindow.

The latter is also no problem.

But if I click on the markers it behaves not as it should.

The page is loaded. The infowindows are open. Now I click Marker 1 and it closes the infowindow of Marker 2. If I click again Marker 1 an second infowindow opens on Marker 1. The "initial" infowindow on Marker 1 can only be closed with the X in the infowindow.

If I close all infowindows via the X then I can can open and close each infowindow via their markers.
BUT: Opened infowindows will be closed from a click on the other marker, which is not what I want.
Only a click on their own marker should open and close the infowindow.

It seems that the click events are conflicting, but in the moment I don't know how to change this.
Any ideas?
Thanks.

This post didn't address my problem (please correct me if I'm wrong). The infowindows in it behave as follows: if you open a new infowindow via click on its marker the already opened infowindow of another marker is closed. That's not what I want. Only a click on its own marker should close a infowindow not a click on another marker.

The post to which you link does contain the solution: "function closure". You just need to extend it to include the infowindow for each marker since you have a unique infowindow for each marker instead of a global infowindow shared among all the markers.