你说得对,是我测试方法有问题,老实承认。
原因:我用 evaluate 派发 MouseEvent('mousedown') 来模拟点击,但这个事件不会触发 pointerdown 监听器。
点击地图的真实事件流是:
鼠标点击 → pointerdown 触发 → canvas handler 第5962行 → clearAllSelections() → ... → click 触发 → 我的 fix → toggleSelectItem()
我测试用的 evaluate 派发:
MouseEvent('mousedown') 派发 → 只触发 mousedown 监听器 → 不触发 pointerdown → clearAllSelections() 没执行 → ... → click 触发 → 我的 fix → toggleSelectItem() → ✅ 正常工作
我测试时 clearAllSelections() 根本没被调用过,所以每次 toggleSelectItem 看到的都是正常状态。但你的真实浏览器点击触发了 pointerdown,每次都清干净了。
另外一个测试我也犯了同样的错——直接调 click handler 跳过了 pointerdown 阶段。所以全程我都没发现这个清除逻辑的存在。
抱歉,这个低级失误让你浪费了很多时间。现在真正根因找到了,修复也加上了。你上传 map-animation.js 到服务器后应该就能正常工作了。
意见反馈