Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 禁用事件点击谷歌地图v3_Google Maps_Google Maps Api 3 - Fatal编程技术网

Google maps 禁用事件点击谷歌地图v3

Google maps 禁用事件点击谷歌地图v3,google-maps,google-maps-api-3,Google Maps,Google Maps Api 3,我为我的GMAPv3添加了自定义谷歌地图信息窗口 当我单击信息窗口内容和信息窗口关闭按钮时,如何禁用“单击”事件 我放在上面的示例代码 这里有一个部分解决方案。我不想花时间浏览和学习InfoBox,Infowindow已经解决了 单击/打开信息框时,以下内容将删除单击事件。您需要找到一种在关闭信息框时重新添加的方法。资讯箱!=Infowindow,我没有API来做它 您需要添加/更改: 将:var-listener添加到脚本顶部 更改: google.maps.event.addListener

我为我的GMAPv3添加了自定义谷歌地图信息窗口 当我单击信息窗口内容和信息窗口关闭按钮时,如何禁用“单击”事件

我放在上面的示例代码


这里有一个部分解决方案。我不想花时间浏览和学习InfoBox,Infowindow已经解决了

单击/打开信息框时,以下内容将删除单击事件。您需要找到一种在关闭信息框时重新添加的方法。资讯箱!=Infowindow,我没有API来做它

您需要添加/更改:

将:
var-listener
添加到脚本顶部

更改:

google.maps.event.addListener(map, 'click', function(event) {

              alert("google.maps.event.addListener");
            });

更改:

google.maps.event.addListener(markers[i], "click", function (e) {
            var infoBox = new InfoBox({
                latlng: this.getPosition(),
                map: map,
                content: this.content
            });
            google.maps.event.removeListener(listener)
          });

CODEPEN:

 listener = google.maps.event.addListener(map, 'click', function(event) {
          alert("google.maps.event.addListener");
        });
google.maps.event.addListener(markers[i], "click", function (e) {
            var infoBox = new InfoBox({
                latlng: this.getPosition(),
                map: map,
                content: this.content
            });
            google.maps.event.removeListener(listener)
          });
 google.maps.event.addListener(markers[i], "click", function (e) {
        var infoBox = new InfoBox({
            latlng: this.getPosition(),
            map: map,
            content: this.content
        });
        google.maps.event.removeListener(listener)
      });