Closing any open info windows in google maps api v3

后端 未结 6 1553
旧时难觅i
旧时难觅i 2021-01-31 03:25

As the title states, on a given event (for me this happens to be upon opening a new google.maps.InfoWindow I want to be able to close any other currently open info

6条回答
  •  忘掉有多难
    2021-01-31 04:27

    I have decided to create an array of all dynamically created Infobox. When you click on any first travel the array and then you close all open only one in which you have clicked.

    var allInfos = [];
    
    function closeInfos() {
            for (i = 0; i < allInfos.length; i++) {
                allInfos[i].close();
            }
    }
    

    Once created the infobox, dynamically are you adding it to the array each as follows:

    allInfos.push(infowindow);
    

提交回复
热议问题