gpt4 book ai didi

javascript - 谷歌地图 API : infoWindow flickers/closes automatically because of mouseout event

转载 作者:数据小太阳 更新时间:2023-10-29 04:59:18 24 4
gpt4 key购买 nike

我正在为我正在进行的一个漂亮的新项目创建多边形。每当您将鼠标悬停在 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观察 map 的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();
});
});

关于javascript - 谷歌地图 API : infoWindow flickers/closes automatically because of mouseout event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17164544/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com