赞
踩
dragNoClick = () => { const lock = (e) => { //获取相机位置 this.lockStart = this.map.controls.target.clone(); }; const unlock = (e) => { const target = this.map.controls.target; //起始点距离小于0.1认为是没有挪动 点击事件 if (!this.lockStart || this.lockStart.distanceTo(target) > 0.1) { this.lockTiles = false; } else { //点击事件 this.lockTiles = true; } }; const controls = this.map.controls; controls.addEventListener("start", lock); controls.addEventListener("end", unlock);
//t===事件名称 fn===回调 handleEvent = (t, fn) => { this.map.on(t, (e) => { if (e.length <= 0) { return; } //点击事件 区别拖拽事件 if (t === "click") { if (this.lockTiles) { fn(e); } } else { fn(e); } });
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。