Google Maps: close infowindow

Hi,
I implemented the following super-cool page:
https://wonderwix.wixsite.com/test
BUT when opening one infowindow, others are not closed.
For that, I used the addListener function as following:
marker.addListener(‘click’, function() {
info.close();
info.setContent(geoCords.content);
info.open(map, marker);
});
Unfortunately, other open infowindows stays open…

Will appreciate your advise:)
Thanks,
Dafna

You need a closure, google closure on mapmarkers google maps. I am not with my code, if you don’t find it, ping me.

ping:)

trying to implemnt, but I get only 1 marker…

Thanks!!!

// Creating a closure to retain the correct data
// The closure function needs to be inside the loop where you
// plot out all markers ending with (marker, data)

(function(marker, data) {
// Attaching a click event to the current marker
google.maps.event.addListener(marker, “click”, function(e) {
infoWindow.setContent(“” + data.title + “
” + data.description);
infoWindow.open(map, marker);
});
})(marker, data);

it’s still not working…
All I get is 1 marker without a listener
Thanks for your help!
BTW - I build the content string html in the code, outside the frame

            markersData.forEach((data)=>  { 
	    console.log("LENGTH: " + markersData.length); 
                let marker = new google.maps.Marker({ 
	                animation: google.maps.Animation.BOUNCE, 
                    	position: data.position, 
	                icon: { 
		                url: data.icon, 
		                scaledSize: new google.maps.Size(40, 40) 
		            	}, 
	                title: data.title, 
                     	map: map 
                    	}) 
	    let info = new google.maps.InfoWindow({ 
	            content: data.content 
            	        }) 


	(function(marker, data) {    
	    google.maps.event.addListener(marker, "click", function(e) { 
                	info.setContent(data.content); 
		info.open(map, marker); 
	    }); 
	})(marker, data);

maybe there is a way to close all infowindows before opening the new one?
Thanks:)

Look at aroundme.ai and menu On Map, is that what you want?

YES! exactly!
Thanks:)

Send me an dm on hello@wixshow.com and I will send it to you

Popping-up the post… still can’t close other infowindows when openning a new one.
Really need your advise!
Thanks:) Dafna