It is forbidden to drag and move the map in the div on the leaflet map. Double-click to zoom in and the mouse wheel to zoom in and out of the map.

Example image:
Insert image description here
I want the map to be unable to operate when the mouse is moved to the div:

//  把以下内容 写在地图加载完后 页面渲染完后的方法里 
let _this = this
let leftResultDiv = document.getElementById('leftResult');  //获取div的dom
                    setTimeout(() => {
                          leftResultDiv.onmouseover = function () {  //监听鼠标移入
                            _this.map.dragging.disable(); //地图拖拽
                            _this.map.doubleClickZoom.disable();  //禁止双击放大地图
                            _this.map.scrollWheelZoom.disable();  //禁止鼠标滑轮滚动放大缩小地图

                          }
                       });
                    setTimeout(() => {
                          leftResultDiv.onmouseout  = function () {
                            _this.map.dragging.enable();  //enable  开启
                            _this.map.doubleClickZoom.enable()
                            _this.map.scrollWheelZoom.enable();
                          }
                       });

Guess you like

Origin blog.csdn.net/weixin_44220845/article/details/117423091