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

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

Open
3DMXM opened this issue Oct 16, 2024 · 5 comments
Open

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

3DMXM opened this issue Oct 16, 2024 · 5 comments

Comments

@3DMXM
Copy link

3DMXM commented Oct 16, 2024

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

GIF2

@3DMXM
Copy link
Author

3DMXM commented Oct 16, 2024

@qiuxiang
Copy link
Owner

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

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

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

@3DMXM
Copy link
Author

3DMXM commented Oct 16, 2024

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

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

@3DMXM
Copy link
Author

3DMXM commented Oct 16, 2024

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

@qiuxiang
Copy link
Owner

qiuxiang commented Oct 17, 2024

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

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

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