-
Notifications
You must be signed in to change notification settings - Fork 509
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
Conversation
Codecov ReportAttention:
❗ 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. |
if (!geometry) { | ||
continue; | ||
} | ||
if (geometry.options.cursor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个判断有点宽泛了,感觉最合理的做法是判断当前点是否于geometry的containerExtent相交,只有相交才return true,尽量避免该查询
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有道理,不过:
- 用户设置cursor这个是小概率事件,大部分用户没有这个需求,花大代价做小概率的事情
- 如果用包围盒判断,那么需要计算所有的geometry的bbox,那么性能更差了,还不如没有这个判断函数了,包围盒的计算还是很复杂的
- VectorLayer已经拥有了颜色判断,当且仅当当前画布处有颜色才会走具体的事件逻辑,应该考虑其他图层也实现类似逻辑,或者在地图上实现这个逻辑,即没有颜色的地方应该直接忽略这个地图的事件继续往下走,即当前鼠标处有颜色值,那么其一定在图形内
- 可以在地图画布上实现这逻辑,当地图画布处为空时,直接不走地图的事件系统
There was a problem hiding this comment.
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要好很多
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
经过测试,改方法不可行,太耗时了,改用地图画布颜色检测,即地图画布的全局图形法
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
刚试了下,不行,因为地图画布可能一直不是空的,比如有tilelayer的情况下,永远有颜色值的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
经过验证还是要通过判断图层的颜色值是否为空来完成,参考VectorLayer的实现
@fuzhenn
该PR解决了以下问题:
但如讨论里所示,这个pr里对于设置过options.cursor的Geometry存在以下问题:
要彻底解决,需要找到某种能快速判断某个Geometry是否和像素点相关,尽量避免读取像素 |
fix #1991
fix #2148