Skip to content

fix: change GlobeControl if Map.prototype.setProjection is called#7075

Open
CommanderStorm wants to merge 3 commits intomaplibre:mainfrom
CommanderStorm:GlobeControll-based-on-setProjection
Open

fix: change GlobeControl if Map.prototype.setProjection is called#7075
CommanderStorm wants to merge 3 commits intomaplibre:mainfrom
CommanderStorm:GlobeControll-based-on-setProjection

Conversation

@CommanderStorm
Copy link
Member

@CommanderStorm CommanderStorm commented Feb 7, 2026

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.
  • Write tests for all new functionality.
  • Add an entry to CHANGELOG.md under the ## main section.

Resolves #7005

If I add a GlobeControl to the Map and subsequently call Map.prototype.setProjection(), the control should automatically update its state to reflect the new projection.
This now happens this way.

CC @1ec5

@CommanderStorm CommanderStorm requested a review from HarelM February 7, 2026 16:13
@CommanderStorm CommanderStorm changed the title fix: change GlobeControll based on setProjection fix: change GlobeControl if Map.prototype.setProjection is called Feb 7, 2026
@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.52%. Comparing base (933100a) to head (80f380f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7075      +/-   ##
==========================================
- Coverage   92.53%   92.52%   -0.01%     
==========================================
  Files         288      288              
  Lines       23928    23930       +2     
  Branches     5081     5081              
==========================================
+ Hits        22141    22142       +1     
- Misses       1787     1788       +1     

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CommanderStorm CommanderStorm marked this pull request as ready for review February 7, 2026 16:29
});

test('updates control state when Map.setProjection() is called', async () => {
await new Promise(resolve => map.on('load', resolve));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use await map.once('load').


// Call setProjection to globe
map.setProjection({type: 'globe'});
await new Promise(resolve => setTimeout(resolve, 0));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a sleep utility as far as I remember.

expect(button.classList.contains('maplibregl-ctrl-globe-enabled')).toBe(true);
expect(button.classList.contains('maplibregl-ctrl-globe')).toBe(false);

// Call setProjection back to mercator
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a different test, it's best to test one thing.

@HarelM
Copy link
Collaborator

HarelM commented Feb 8, 2026

Added a few minor comments on the tests, thanks for taking the time to open this PR!

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.

Programmatically changing projection should update globe control

3 participants