Close infoWindow when new opens?
new开发者_开发技巧 google.maps.event.addListener(marker, 'click', function() {
infowindow.close(map, marker); //the code is not working..
infowindow.open(map, marker);
})
Store all the info windows in an array. And use the following function to close the currently open window.
I.E:
var infoWindow = new google.maps.InfoWindow;
infoWindowArray.push(infoWindow);
function resetInfoWindow(){
if(infoWindowArray){
for(i in infoWindowArray){
infoWindowArray[i].close();
}
}
}
Call the function resetInfoWindow()
like this:
google.maps.event.addListener(marker, 'click', function() {
resetInfoWindow();
infoWindow.setContent(str1);
infoWindow.open(map, marker);
});
精彩评论