react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

Fix changing zoom and center at once

Open tomhicks opened this issue 11 months ago • 0 comments

What this does

Previously, if you wanted to zoom in and pan the map in the same viewport operation when you were very zoomed out, it would get "stuck" at latitudes near the equator.

If you're zoomed right out such that the equator is at the center of your viewport, and want to zoom in to a point at a much higher zoom level away from the equator, because the center change is handled first, the center change is constrained, so the latitude doesn't change. Then the zoom happens, and you end up at the wrong place.

By changing the order to zoom first, we ensure that the constraining that happens during the center change happens with the correct available center range.

Testing

The unit tests still pass, but it's hard to exercise the exact scenario here because it's dependent on the viewport constraining behaviour which is mocked out in this repo.

tomhicks avatar Mar 21 '24 19:03 tomhicks