I have tried google it but can't find the one to apply to my code. i want my infowindow(s) to close everytime someone presses another place on the map or opens another infowindow somewhere else.
Can someone please help?
var myLatlng = new google.maps.LatLng(val.coords.split(',')[0].trim(),val.coords.split(',')[1].trim());
var infowindow = null;
var contentString = '<div id="content">'+
'<div id="siteNotice"> content'+
'</div>';
var infowindow1 = new google.maps.InfoWindow({
content: contentString,
maxWidth: 250
});
var marker1 = new google.maps.Marker({
position: myLatlng,
map: map,
icon: image,
});
google.maps.event.addListener(marker1, 'click', function() {
infowindow1.open(map,marker1);
});
});
});