Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] AdvancedMarker onDragEnd event triggers Map's onClick event

未关闭
#421 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
react, typescript
领域
frontend

调研方向

使用链接的 CodeSandbox 复现该行为,从 src/app.tsx 以及其中显示的 AdvancedMarker 和 Map 事件处理程序开始。跟踪拖动如何到达 onDragEnd 和 Map onClick,然后验证拖动标记不再触发地图点击回调,而普通的地图点击仍会触发该回调。

由索引模型根据 Issue 内容生成。

描述

bug
Description

I have a Map instance with an onClick that sets the position of a marker to the latLng of the clicked position.

This marker is draggable, and onDragEnd shows an InfoWindow with the new position. The problem is that when onDragEnd ends the Map's onClick event fires. Both onClick and onDragEnd sets the position, but since they have a small difference this leads to the marker to jump to a close (but not exactly intended) position.

I expected the onClick event to not fire when AdvancedMarker onDragEnd fires.

Steps to Reproduce

Code SandBox:
SandBox

Steps:

  1. Open console
  2. Click on map to relocate marker
  3. Drag marker, pay attention to console.
  4. Drag map.
  5. Drag marker again, pay attention to console
Environment
  • Library version: @vis.gl/[email protected]
  • Google maps version: weekly
  • Browser and Version: 127.0
  • OS: Windows 11
Logs

No response

主要语言
TypeScript
星标
1.9k
派生
195
平均合并
2 天 11 小时
30 天内合并 PR
14

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

visgl/react-google-maps 的其他 Issue

查看 visgl/react-google-maps 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。