Baidu map simulation polygons covering material mouseover, mouseout event

Baidu Maps v2.0 polygon covering mouseover thing, there is a BUG mouseout event. After the test found that the actual triggered only when a mouseover event on the polygon boundary, leaving the border, whether it is inside or outside into the polygon will trigger mouseout event.

Analog ideas: Map of listening mousemove mouse move events, mouse movement points is obtained; the geometrical algorithm warehouse BMapLib.GeoUtils.isPointInPolygon () method of determining whether a point within the coverage was polygon; need to add anti-shake function, avoiding duplication constantly moving trigger event.

_echarts.mapModal.addEventListener('mousemove', function(e){
       //函数防抖
       clearInterval(_echarts.debounceTimer);
       _echarts.debounceTimer = setTimeout(function() {
            for(let i=0;i<_echarts.plys.length;i++){
                 if (BMapLib.GeoUtils.isPointInPolygon(e.point, _echarts.plys[i])) {
                     _echarts.plys[i].setFillColor('#10618D ');                     
                 }else{
                     _echarts.plys[i].setFillColor('#0A3455');
                 }
            }
      }, 300);
});
Published 258 original articles · won praise 21 · views 50000 +

Guess you like

Origin blog.csdn.net/wsln_123456/article/details/105050504