mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

fix(Globe): add transform logic for points during globe-mercator projection transition

Open Gerbuuun opened this issue 2 months ago • 1 comments

Description

Resolves #12592

[!IMPORTANT] This PR is written with a lot of help from Claude Opus 4.5 Although parts of the code are generated using a LLM, the solution does actually fix the problem. Everything is checked by me and this PR message is written by only me.

Problem

During the transition between the globe projection and mercator projection, the location of markers shift from their location on the map.

Root Cause

The locationPoint function in the Globe projection class:

https://github.com/mapbox/mapbox-gl-js/blob/5e6eb16e88a6e551a0d599ab834d19e42ed8d546/src/geo/projection/globe.ts#L55-L72

only calculates the location as if the map was still a globe and does not take into account the morphing of the displayed map.

Solution

Add logic for during the transition. The added logic is based on the mercator_tile_position shader function.

Look at the pins around the UK and Belarus. The shifting is no longer present.

Before

https://github.com/user-attachments/assets/f18023dc-ed56-40c0-a5e0-96d86535c87c

After

https://github.com/user-attachments/assets/878536cf-dec2-445c-b3a4-7d6595377caf

Launch Checklist

  • [x] Make sure the PR title is descriptive and preferably reflects the change from the user's perspective.
  • [x] Add additional detail and context in the PR description (with screenshots/videos if there are visual changes).
  • [x] Manually test the debug page.
  • [x] Write tests for all new functionality and make sure the CI checks pass.
  • [x] Document any changes to public APIs.
  • [x] Post benchmark scores if the change could affect performance.
  • [x] Tag @mapbox/map-design-team @mapbox/static-apis if this PR includes style spec API or visual changes.
  • [x] Tag @mapbox/gl-native if this PR includes shader changes or needs a native port.
  • [x] Tag @mapbox/gl-native if this PR disables any test because it also needs to be disabled on their side.
  • [x] Create a ticket for gl-native to groom in the MAPSNAT JIRA queue if this PR includes shader changes or features not present in the native side or if it disables a test that's not disabled there.

Gerbuuun avatar Dec 04 '25 23:12 Gerbuuun

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Dec 04 '25 23:12 CLAassistant