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
Map shaking after setMaxBounds and setMinZoom #8532
Comments
Can reproduce in Chrome 106.0.5249.91 on Windows 10, I see a very small but noticeable wobble, stops for me if window is resized. Also sometimes had to resize the window to reproduce. |
I believe that the issue comes from the dynamic restriction of Maybe it can work for you too until someone with more knowledge joins the discussion. 😄 |
Reproduced in Chrome 106.0.5249.103 I also see wobble. Yes, the shaking stops if I change the window size or zoom but that's not the solution |
@SashaLifashkin can you please share a video |
https://jsfiddle.net/fd3mertj/1/ |
Unfortunately this solution didn't work for me. |
This seems to be an intermittent problem, but I can repeat it. It takes a bit of adjusting the screen to figure out a screen size that does reproduce the issue – and even then it can seemingly fix itself without intervention. We have We are supposed to break out of this recursion in Map.panInsideBounds by checking if a recalculated center is identical to the current center: Lines 503 to 514 in 4372a9f
But our centers do not match up. Here are the
Taking a look at
I believe this might be related to floating point precision between the map bounds and its projected center. Each new projected center throws the bounds off slightly, leading to a different projected center. I think we already have code that's attempting to fix this in Lines 1545 to 1550 in 4372a9f
I'd propose expanding that to ignore up to 1px offsets, as we seem to be seeing here. I'll put a PR together with that proposal, if nobody objects? |
@rjackson great analysis! Please submit a PR of course. |
Do we perhaps feel like this fix deserves a backport for v1? |
Don't know, I think we should look that we get away from |
Agreed, however #8536 was already cherry-picked, so I think we're going to do a release anyways. |
Yes that's true. Let us cherry pick this, because we make a release anyway |
Done 👍 |
Checklist
Steps to reproduce
const map = L.map('map').setView([50.450036, 30.5241361], 13)
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution:
'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
}).addTo(map)
map.setMaxBounds(map.getBounds()).setMinZoom(map.getZoom())
Expected behavior
The map is limited by the maximum borders and the minimum zoom without any unexpected behavior.
Current behavior
Map is limited by the maximum borders and the minimum zoom, but the map is moving (shaking).
I have looked at these issues: #1946, #2107, #2011, #2081, #1866, #2187. But it seems that there is no solution to my problem there, so I don't think it's a duplicate to any of previous issues. If it is, could you please help me to resolve this issue?
Thank you!
Minimal example reproducing the issue
https://jsfiddle.net/fd3mertj/1/
Environment
The text was updated successfully, but these errors were encountered: