canvaskit-map icon indicating copy to clipboard operation
canvaskit-map copied to clipboard

当进行缩放时,marker点会偏移

Open 3DMXM opened this issue 1 year ago • 5 comments

不知道哪里出了问题,大佬能否帮忙看看,代码: https://github.com/3DMXM/canvaskit-map-bug

GIF2

3DMXM avatar Oct 16 '24 03:10 3DMXM

在线运行 Bug: https://stackblitz.com/edit/canvaskit-map-bug?file=src%2FApp.vue

3DMXM avatar Oct 16 '24 03:10 3DMXM

因为你的图片大小是 50x50,但实际显示的方块是左上角 10x10,marker 的中心和看起来小方块中心不一致

ctx.fillRect(0, 0, 50, 50);

改成这样看起来就不偏移了

qiuxiang avatar Oct 16 '24 05:10 qiuxiang

恩,将值改成一样是不偏移了,

还有另一个问题 当顶部存在 header的时候, event.coordinate 的值在不同的缩放情况下,是不一样的, 代码已经在上面更新 image

3DMXM avatar Oct 16 '24 07:10 3DMXM

log输出的坐标是在不同缩放下,鼠标点击 红点 的坐标值 ( marker定义的坐标是 0, 0 )

3DMXM avatar Oct 16 '24 07:10 3DMXM

改成: ```css .map { width: 100%; height: calc(100vh - 50px); position: relative; } .map > canvas { top: 0; } ```

确实有问题,指针中心没考虑到位置偏移

qiuxiang avatar Oct 17 '24 01:10 qiuxiang