Skip to content

fix Geometry cursor Not working properly #2149

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

Merged
merged 8 commits into from
Jan 10, 2024
Merged

Conversation

deyihu
Copy link
Collaborator

@deyihu deyihu commented Dec 7, 2023

fix #1991

fix #2148

@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2023

Codecov Report

Attention: 57 lines in your changes are missing coverage. Please review.

Comparison is base (2462b72) 83.82% compared to head (5f6329d) 83.58%.

Files Patch % Lines
src/core/util/pick.js 5.17% 55 Missing ⚠️
src/layer/OverlayLayer.js 83.33% 1 Missing ⚠️
src/map/Map.Topo.js 87.50% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2149      +/-   ##
==========================================
- Coverage   83.82%   83.58%   -0.24%     
==========================================
  Files         169      170       +1     
  Lines       18812    18867      +55     
==========================================
+ Hits        15769    15770       +1     
- Misses       3043     3097      +54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

if (!geometry) {
continue;
}
if (geometry.options.cursor) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个判断有点宽泛了,感觉最合理的做法是判断当前点是否于geometry的containerExtent相交,只有相交才return true,尽量避免该查询

Copy link
Collaborator Author

@deyihu deyihu Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有道理,不过:

  • 用户设置cursor这个是小概率事件,大部分用户没有这个需求,花大代价做小概率的事情
  • 如果用包围盒判断,那么需要计算所有的geometry的bbox,那么性能更差了,还不如没有这个判断函数了,包围盒的计算还是很复杂的
  • VectorLayer已经拥有了颜色判断,当且仅当当前画布处有颜色才会走具体的事件逻辑,应该考虑其他图层也实现类似逻辑,或者在地图上实现这个逻辑,即没有颜色的地方应该直接忽略这个地图的事件继续往下走,即当前鼠标处有颜色值,那么其一定在图形内
  • 可以在地图画布上实现这逻辑,当地图画布处为空时,直接不走地图的事件系统

Copy link
Member

@fuzhenn fuzhenn Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果用包围盒判断,那么需要计算所有的geometry的bbox,那么性能更差了,还不如没有这个判断函数了,包围盒的计算还是很复杂的

这个倒是不会,geometry的bbox计算不咋耗性能,比webgl图层去read pixel要好很多

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

经过测试,改方法不可行,太耗时了,改用地图画布颜色检测,即地图画布的全局图形法

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

刚试了下,不行,因为地图画布可能一直不是空的,比如有tilelayer的情况下,永远有颜色值的

Copy link
Collaborator Author

@deyihu deyihu Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

经过验证还是要通过判断图层的颜色值是否为空来完成,参考VectorLayer的实现
@fuzhenn

@fuzhenn
Copy link
Member

fuzhenn commented Jan 10, 2024

该PR解决了以下问题:

  • 没有正常设置geometry的cursor
  • 原有版本里,图层没有geometry监听mousemove相关事件,不再需要pick像素,减少了主线程的卡顿

但如讨论里所示,这个pr里对于设置过options.cursor的Geometry存在以下问题:

  • GroupGLLayer中存在TileLayer时,无法单纯从pick的像素值判断该点是否有Geometry
  • mousemove时仍然需要pick像素

要彻底解决,需要找到某种能快速判断某个Geometry是否和像素点相关,尽量避免读取像素

@fuzhenn fuzhenn merged commit 6ea51dc into maptalks:master Jan 10, 2024
@deyihu deyihu deleted the 2148 branch January 10, 2024 06:50
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

Successfully merging this pull request may close these issues.

【BUG】图形设置 cursor 属性无效, 一直是 pointer 状态 cursor 设置不生效
3 participants