开发者

Close infoWindow when new opens?

开发者 https://www.devze.com 2023-01-13 03:55 出处:网络
new开发者_开发技巧 google.maps.event.addListener(marker, \'click\', function() { infowindow.close(map, marker);//the code is not working..
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);
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消