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

Avoid constraining with Mercator transform when Globe is used #5186

Merged
merged 8 commits into from
Dec 18, 2024

Conversation

ibesora
Copy link
Collaborator

@ibesora ibesora commented Dec 11, 2024

This fixes a subtle bug I found while trying to create a test for another issue.
When a Map is created and before the style is loaded, a Mercator transform is created as a default. When a style that uses globe is loaded, a new transform is created. This is not a problem in general but it is when setting center and zoom values that are valid when using globe and not when using Mercator.

What this PR does is avoid constraining the center and zoom values when a style is defined until the style is loaded and we can be sure we are constraining them with the correct transform.

TLDR:
Before: Notice how both the hash and the camera position change after a reload when using invalid Mercator values

Screen.Recording.2024-12-11.at.10.36.43.mov

After: Notice how the hash and the camera are in the same position after a reload

Screen.Recording.2024-12-11.at.10.37.29.mov

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

@HarelM
Copy link
Collaborator

HarelM commented Dec 11, 2024

Let's wait a bit with merging this as I want to finalize the transform and projection changes and merge them to main. I hope that's OK.

@HarelM
Copy link
Collaborator

HarelM commented Dec 12, 2024

The relevant PR was merged, I think you can go ahead and update this branch...

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.83%. Comparing base (35ea568) to head (6ac68ab).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5186   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files         281      281           
  Lines       38829    38833    +4     
  Branches     6772     6787   +15     
=======================================
+ Hits        35657    35663    +6     
+ Misses       3044     3043    -1     
+ Partials      128      127    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ibesora ibesora requested a review from HarelM December 16, 2024 11:15
@HarelM
Copy link
Collaborator

HarelM commented Dec 16, 2024

Is there simpler way to achieve this? It seems a bit hacky with the resize and style.load events...

@ibesora ibesora force-pushed the ib/lazy-constrain-transform branch from 3909e27 to 77f5090 Compare December 18, 2024 08:47
@HarelM HarelM enabled auto-merge (squash) December 18, 2024 10:50
@HarelM HarelM merged commit 5d5a2cd into maplibre:main Dec 18, 2024
16 of 17 checks passed
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 this pull request may close these issues.

2 participants