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
Javascript 点击并关闭谷歌地图上的点击事件_Javascript_Google Maps_Extjs3 - Fatal编程技术网

Javascript 点击并关闭谷歌地图上的点击事件

Javascript 点击并关闭谷歌地图上的点击事件,javascript,google-maps,extjs3,Javascript,Google Maps,Extjs3,我想在同一个标记上打开两个信息窗口。在“点击”事件时,第一个信息窗口应该关闭(我已经在地图上显示了),然后打开第二个信息窗口。在关闭第二个信息窗口时,我想打开第一个窗口 这是我的密码: var infowindow = new google.maps.InfoWindow({ content: content, marker:marker, maxWidth: 300, image:image,

我想在同一个标记上打开两个信息窗口。在“点击”事件时,第一个信息窗口应该关闭(我已经在地图上显示了),然后打开第二个信息窗口。在关闭第二个信息窗口时,我想打开第一个窗口

这是我的密码:

var infowindow = new google.maps.InfoWindow({
            content: content,
            marker:marker,
            maxWidth: 300,
            image:image,
            id:vehicleNo
        });         
var openinfowindow = new google.maps.InfoWindow({
            content: contentone,
            marker:marker,
            maxWidth: 300,
            image:image,
            id:vehicleNo
        }); 
google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){         
                return function() {                             
                    openinfowindow.close();                 
                    infowindow.setContent(content);
                    infowindow.open(map,marker);
            };              
        })(marker,content,infowindow)); 

    google.maps.event.addListener(infowindow,'closeclick',function(){
            openinfowindow.setContent(contentone);
            openinfowindow.open(map,marker);                                
    });

由于信息窗口之间的唯一区别是所需的内容,因此您可以使用单个信息窗口并简单地切换内容:

    var infowindow = new google.maps.InfoWindow({
        contents:[content,contentOne],
        marker:marker,
        maxWidth: 300,
        image:image,
        id:vehicleNo
    });         

    google.maps.event.addListener(marker,'click', (function(marker,
                                                            contents,
                                                            infowindow){         
      return function() {                                       
                infowindow.contents=[contents[0],contents[1]];
                infowindow.setContent(contents[0]);
                infowindow.open(map,marker);
      };              
    })(marker,infowindow.contents,infowindow)); 

    google.maps.event.addListener(infowindow,'closeclick',function(){
        var that=this;
        that.contents.reverse();
        that.setContent(this.contents[0]);
        setTimeout(function(){
          that.open(map,marker);},
          100);                                
    });

问题是什么?寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现它所需的最短代码。没有明确问题陈述的问题对其他读者没有用处。请参阅:。它仅适用于单个标记,但不适用于多个标记。对于多个标记,我们到底需要做什么?请帮帮我