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

Markers shift slightly when the map is double clicked #13351

Open
C2thehris opened this issue Dec 14, 2024 · 1 comment · May be fixed by #13352
Open

Markers shift slightly when the map is double clicked #13351

C2thehris opened this issue Dec 14, 2024 · 1 comment · May be fixed by #13352

Comments

@C2thehris
Copy link

C2thehris commented Dec 14, 2024

When a user is using a map with custom markers, the markers shift slightly when the map is double clicked. This is most visible when the map has a fixed zoom or is at its highest zoom level.

mapbox-gl-js version: Latest

browser: Any (Tested with Chromium + Firefox)

Steps to Trigger Behavior

  1. Zoom into the highest zoom level (or a use a map with fixed zoom)
  2. Double click on the map
  3. Markers sometimes shake slightly

Link to Demonstration

This can be seen by using the custom-markers demo. (see below video)

Expected Behavior

https://github.com/user-attachments/assets/7250fed0-3b62-4e1e-b851-2a68f9f50b70
https://github.com/user-attachments/assets/1ecad5c0-9133-4cfa-946f-34623b88225e

Actual Behavior

https://github.com/user-attachments/assets/85cf749d-b01c-414d-8f1b-05580dfea41e
https://github.com/user-attachments/assets/0f9666e4-8287-4068-aaac-0b4540d0c305

@C2thehris
Copy link
Author

C2thehris commented Dec 14, 2024

This issue is caused by

this._updateDOM();

The marker does not snap to a rounded pixel (as intended by #11167). I think the solution here would be to round the coordinates here if the marker's position hasn't changed.

My workaround (which doesn't preserve the nice behavior for animated markers) is (uses react-map-gl):

  useEffect(() => {
    if (markerRef.current == null) return;
    const marker = markerRef.current;
    marker._updateMoving = () => marker._update();
  }, [markerRef.current]);

@C2thehris C2thehris linked a pull request Dec 14, 2024 that will close this issue
8 tasks
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

Successfully merging a pull request may close this issue.

1 participant