开发者

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);
    });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜