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

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

Open
JosuerBague opened this issue Jun 17, 2024 · 3 comments
Open
Labels
bug Something isn't working

Comments

@JosuerBague
Copy link

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

@JosuerBague JosuerBague added the bug Something isn't working label Jun 17, 2024
@usefulthink
Copy link
Collaborator

I think this behavior at least matches the behavior of the maps API itself. Not sure right now what can be done about it, but I will have a look.

@benjaminsinaiko
Copy link

I just ran into that same issue with a routes/directions feature. The onClick will add a marker, when there are 2 markers the directions service is kicked off. But when there is only 1 marker, and it is dragged, the onDragEnd updates marker 1 AND adds a second marker as the map onClick is fired.

The ugly workaround I'm using now is setting a isDragEvent ref true when the onDragEnd fires, and then in the onClick ignoring the event if the ref is true, and then setting it false. Don't love it but if this is how the maps api works don't see it getting "fixed" anytime soon.

@JosuerBague
Copy link
Author

@benjaminsinaiko I'll try and give it a go. Thanks for the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants