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

drag to rotate breaks if the maps bearing/pitch is changed inside of a move event #4104

Open
UberMouse opened this issue May 13, 2024 · 3 comments

Comments

@UberMouse
Copy link

maplibre-gl-js version: 4.2.0

browser: Tested on Vivaldi, Firefox and Safari

Steps to Trigger Behavior

  1. Lock the bearing to a specific value by calling map.setBearing inside of a move handler whenever the maps bearing does not match the specific value
  2. Use the compass to change the pitch up and down, it works correctly
  3. Try and do the same with drag to rotate, it locks and stops working as soon as the bearing changes slightly and the move handler calls map.setBearing

The same behaviour can be observed with pitch locking but the JSBin does not set that up

Link to Demonstration

https://jsbin.com/posuvohigo/edit?html,output

Expected Behavior

Drag to rotate behaves the same as the compass, allowing you to change the pitch but preventing the bearing from changing

Actual Behavior

Drag to rotate locks up and stops working as soon as you accidentally move the mouse left/right while changing the pitch causing the bearing to change

For further context, we are trying to restrict changing the pitch and/or the bearing as a toggleable setting in our map-viewer. As far as I can find, maplibre has no support for functionality like that. So I have implemented the functionality in a move handler, forcing the pitch/bearing to the value it was when it was locked whenever it changes. Works fine with the compass, does not when you try and drag to rotate. In Firefox/Safari the behaviour is much worse than in Chromium based browsers and the map interactions stop working after doing a drag to rotate.

The implementation in the JSBin is fundamentally the same as in our map-viewer, just simplified.

@HarelM
Copy link
Member

HarelM commented May 13, 2024

I believe you should use CameraUpdateTransform instead.
https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/CameraUpdateTransformFunction/

@UberMouse
Copy link
Author

Nice hadn't seen that, works perfectly for our use case, thanks. I'll leave the issue open as this behaviour still seems like a bug, given the compass handles it correctly.

@HarelM
Copy link
Member

HarelM commented May 18, 2024

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