leaflet地图上的 div里 禁止拖拽移动地图,双击放大,鼠标滑轮缩放地图

示例图:
在这里插入图片描述
我要鼠标移到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();
                          }
                       });

猜你喜欢

转载自blog.csdn.net/weixin_44220845/article/details/117423091