Skip to content
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

Open
wuxianshi opened this issue May 17, 2023 · 10 comments

Comments

@wuxianshi
Copy link

如题

@sakitam-fdd
Copy link
Owner

@wuxianshi 这种可以考虑在逻辑层处理,就是简单加个锁,标绘工具激活后其他的事件逻辑阻止掉

@wuxianshi
Copy link
Author

@sakitam-fdd 但是在绘制结束时解锁之后还是会触发底下图层的点击事件呀,比如标绘某个图案的最后一笔落点在已有图层上就会触发其点击事件

@wuxianshi
Copy link
Author

@sakitam-fdd 请问是在哪里把原生Draw自带的鼠标跟随圆圈去掉呀?我想加回去T - T,逻辑层做处理一直有问题

@wuxianshi
Copy link
Author

@sakitam-fdd 我在逻辑层用了定时器才解决了这个问题,但是我觉得定时器并不是一个比较好的解决方案

@sakitam-fdd
Copy link
Owner

我觉得可能理解有问题,有个伪代码你看下:

let isActive = false;

// 你的外部图层事件
map.on('click', (e) => {
  if(isActive) return;
  // 你的逻辑
});

plot.plotDraw.on('drawStart', (e) => {
  isActive = true;
});

plot.plotDraw.on('drawEnd', (e) => {
  isActive = false;
});

@wuxianshi
Copy link
Author

@sakitam-fdd drawEnd事件会比click事件先触发吧

@sakitam-fdd
Copy link
Owner

@wuxianshi 要不试下,我理解的是 drawEnd 会比 click 后触发,因为 drawEnd 是由 click 双击事件模拟的;而且如果一开始就不想触发 click,那么isActive初始值可以置为 true。

@wuxianshi
Copy link
Author

@sakitam-fdd 像圆、矩形这些图形的drawEnd都是单击事件触发的吧,测试过都是比map的单击事件先触发
image

@sakitam-fdd
Copy link
Owner

sakitam-fdd commented Jun 5, 2023

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;
});

image

处理 drawEnd 的逻辑:

if (this.plotType === PlotTypes.POINT || this.plotType === PlotTypes.PENNANT) {

@wuxianshi
Copy link
Author

@sakitam-fdd
image
我用的是singleclick,难怪比drawEnd后执行,请问有什么比较好的解决方案吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants