Javascript GoogleMapsAPI:infoWindow因鼠标退出事件而自动闪烁/关闭

Javascript GoogleMapsAPI:infoWindow因鼠标退出事件而自动闪烁/关闭,javascript,google-maps,google-maps-api-3,event-listener,Javascript,Google Maps,Google Maps Api 3,Event Listener,我正在为一个漂亮的新项目创建多边形。每当您将鼠标悬停在infoWindow上时,就会触发多边形上的mouseout事件。我不想触发mouseout事件,除非鼠标移动到多边形和信息窗口之外。有什么想法吗?以下是大部分相关代码 infoWindow = new google.maps.InfoWindow({ content: myContent }); var polygon = new google.maps.Polygon({

我正在为一个漂亮的新项目创建多边形。每当您将鼠标悬停在infoWindow上时,就会触发多边形上的mouseout事件。我不想触发mouseout事件,除非鼠标移动到多边形和信息窗口之外。有什么想法吗?以下是大部分相关代码

    infoWindow = new google.maps.InfoWindow({
          content: myContent
    });

    var polygon = new google.maps.Polygon({
          paths: polygonPath,
          strokeColor: data.color,
          strokeOpacity: 0.5,
          strokeWeight: 0,
          fillColor: data.color,
          fillOpacity: 0.5,
          id:polygonId,
          name: data.name,
          shortDesc: data.short_desc,
          map: map 
    }); 


    google.maps.event.addListener(polygon, 'click', function(e){
          infoWindow.open(map);
          infoWindow.setPosition(e.latLng);
    });

    google.maps.event.addListener(polygon, 'mouseout', function(){
          infoWindow.close();
    });

代替多边形的
mouseout
,观察地图的
mousemove
(当鼠标移动到多边形或信息窗口上时,不会触发此操作)

google.maps.event.addListener(polygon, 'click', function(e){
      infoWindow.open(map);
      infoWindow.setPosition(e.latLng);
      google.maps.event.addListenerOnce(map, 'mousemove', function(){
        infoWindow.close();
      });
});