[fix] fit to bounds - fix initial basemap and deck projections mismatch - #3155
Merged
Conversation
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR synchronizes initial zoom between the basemap and Deck layers by enforcing a minimum zoom based on viewport height and corrects a typo in the fitBounds call.
- Added allowFloat flag and enforced
minZoomlogic ingetCenterAndZoomFromBoundsto match Deck’snormalizeViewportProps - Corrected
heightparameter in thefitBoundscall (was incorrectly usingwidth) - Updated
geoViewport.viewportinvocation to use alet-bound zoom for mutation
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/utils/src/projection-utils.ts | Added minZoom enforcement and default center adjustment logic |
| src/reducers/src/map-state-updaters.ts | Fixed typo: use height instead of width for fitBounds call |
Comments suppressed due to low confidence (2)
src/utils/src/projection-utils.ts:62
- [nitpick] Add a comment explaining why the center latitude is reset to zero when
zoom≤minZoom, so future readers understand the expected behavior and its relation to Deck’s normalization logic.
center[1] = 0;
src/utils/src/projection-utils.ts:59
- Consider adding unit tests for cases where the computed
zoomis belowminZoomto verify that the enforced minimum zoom and center adjustment behave as intended.
const minZoom = Math.log2(height / MAPBOX_TILE_SIZE);
ilyabo
approved these changes
Jul 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this fix, the initial zoom levels for the basemap and Deck layers could differ, requiring user input to synchronize the projections. This issue affected any layer whose bounds included latitude values closer the poles.
Example how dataset looked right after loading before the fix:

After the fix:
