Google maps 谷歌地图:在鼠标上方打开信息窗口,关闭&;单击重新打开

Google maps 谷歌地图:在鼠标上方打开信息窗口,关闭&;单击重新打开,google-maps,google-maps-api-3,mouseover,infowindow,Google Maps,Google Maps Api 3,Mouseover,Infowindow,我有一个带有信息窗口的标记的页面,我在单击时打开了该页面。我决定在鼠标上方打开信息窗口,它正在工作 但我发现,对于这些懒惰的互联网访问者来说,必须将鼠标移到信息窗口的十字位置才能关闭它,这有点要求太高。所以我在点击标记时添加了一个Close事件,它也在工作 我无法理解的是,如何在标记器单击时重新打开信息窗口,而不是必须鼠标移出才能在标记器上重新鼠标移动 我的代码: google.maps.event.addListener(CalMarker, 'mouseover', function() {

我有一个带有信息窗口的标记的页面,我在单击时打开了该页面。我决定在鼠标上方打开信息窗口,它正在工作

但我发现,对于这些懒惰的互联网访问者来说,必须将鼠标移到信息窗口的十字位置才能关闭它,这有点要求太高。所以我在点击标记时添加了一个Close事件,它也在工作

我无法理解的是,如何在标记器单击时重新打开信息窗口,而不是必须鼠标移出才能在标记器上重新鼠标移动

我的代码:

google.maps.event.addListener(CalMarker, 'mouseover', function() {
    infowindow.setContent(contentStringCal);
    infowindow.open(map,CalMarker);
});
google.maps.event.addListener(CalMarker, 'click', function() {
    infowindow.close(map,CalMarker);
});
有人能帮我点击标记重新打开窗口吗

提前谢谢

附言:在发帖的时候不能说“嗨”,这很奇怪。

试试这个:

google.maps.event.addListener(CalMarker, 'mouseover', function() {
    //open the infowindow when it's not open yet
    if(contentStringCal!=infowindow.getContent())
    {
      infowindow.setContent(contentStringCal);
      infowindow.open(map,CalMarker);
    }
});

google.maps.event.addListener(CalMarker, 'click', function() {
    //when the infowindow is open, close it an clear the contents
    if(contentStringCal==infowindow.getContent())
    {
      infowindow.close(map,CalMarker);
      infowindow.setContent('');
    }
    //otherwise trigger mouseover to open the infowindow
    else
    {
      google.maps.event.trigger(CalMarker, 'mouseover');
    }
});

//clear the contents of the infwindow on closeclick
google.maps.event.addListener(infowindow, 'closeclick', function() {
      infowindow.setContent('');
});
演示: