打开和关闭InfoWindow onclick [英] Open and Close InfoWindow onclick

查看:150
本文介绍了打开和关闭InfoWindow onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我在eventListener中进行编码,以便信息窗口执行以下操作: 如果当前关闭,则打开 并关闭它(如果当前处于打开状态).

Can anyone help me code inside my eventListener so that an infowindow will do the following: open if it's currently closed, and close if it's currently open.

我尝试了以下操作,但没有成功...

I've tried the following to no success...

google.maps.event.addListener(marker, 'click', function() {
if(infowindow.closed == true){
infowindow.open(map, marker)
}
else{
infowindow.close(map, marker)
}
})

推荐答案

您可以使用以下内容:

    infoWindowClosed = true;

    google.maps.event.addListener(marker, 'click', function() {
        if (infoWindowClosed) {
            infowindow.open(map, marker);
            infoWindowClosed = false;
        } else {
            infowindow.close(map, marker)
            infoWindowClosed = true;
        }
    })

这篇关于打开和关闭InfoWindow onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆