-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
标绘时由于缺失跟随鼠标移动的圆圈,会导致点击绘制时触发底下图层的点击事件 #16
Comments
@wuxianshi 这种可以考虑在逻辑层处理,就是简单加个锁,标绘工具激活后其他的事件逻辑阻止掉 |
@sakitam-fdd 但是在绘制结束时解锁之后还是会触发底下图层的点击事件呀,比如标绘某个图案的最后一笔落点在已有图层上就会触发其点击事件 |
@sakitam-fdd 请问是在哪里把原生Draw自带的鼠标跟随圆圈去掉呀?我想加回去T - T,逻辑层做处理一直有问题 |
@sakitam-fdd 我在逻辑层用了定时器才解决了这个问题,但是我觉得定时器并不是一个比较好的解决方案 |
我觉得可能理解有问题,有个伪代码你看下: let isActive = false;
// 你的外部图层事件
map.on('click', (e) => {
if(isActive) return;
// 你的逻辑
});
plot.plotDraw.on('drawStart', (e) => {
isActive = true;
});
plot.plotDraw.on('drawEnd', (e) => {
isActive = false;
}); |
@sakitam-fdd drawEnd事件会比click事件先触发吧 |
@wuxianshi 要不试下,我理解的是 drawEnd 会比 click 后触发,因为 drawEnd 是由 click 双击事件模拟的;而且如果一开始就不想触发 click,那么isActive初始值可以置为 true。 |
@sakitam-fdd 像圆、矩形这些图形的drawEnd都是单击事件触发的吧,测试过都是比map的单击事件先触发 |
let isActive = true;
// 你的外部图层事件
map.on('click', (e) => {
if (isActive) return;
console.log('click');
// 你的逻辑
});
plot.plotDraw.on('drawStart', (e) => {
isActive = true;
});
plot.plotDraw.on('drawEnd', (e) => {
console.log('drawEnd');
isActive = false;
}); 处理 drawEnd 的逻辑: ol-plot/packages/ol-plot/src/core/PlotDraw.js Line 304 in 47a2dbf
|
@sakitam-fdd |
如题
The text was updated successfully, but these errors were encountered: