谷歌地图API - 打开新的信息窗口时如何关闭所有打开的信息窗口



>我有以下函数可以打开标记的信息窗口,我正在努力了解如何在打开另一个信息窗口之前关闭活动/打开的信息窗口,以便一次只有一个信息窗口处于活动状态?

google.maps.event.addListener(map_marker, 'click', function () {
    info_window.setContent(this.html)
    info_window.open(self.map, this)
    document.querySelector("#js-reset-zoom").classList.remove('active')
})
this.map_markers.push( map_marker )

请参阅另一个问题的答案。关闭谷歌地图API v3中的所有信息窗口

google.maps.event.addListener(map_marker, 'click', function () {
if (info_window) {
    info_window.close();
}
info_window.setContent(this.html)
info_window.open(self.map, this)
document.querySelector("#js-reset-zoom").classList.remove('active')

})

this.map_markers.推送( map_marker )

最新更新