Skip to content

Conversation

@Gerbuuun
Copy link

@Gerbuuun Gerbuuun commented Dec 4, 2025

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:

override locationPoint(tr: Transform, lngLat: LngLat, altitude?: number): Point {
const pos = latLngToECEF(lngLat.lat, lngLat.lng);
const up = vec3.normalize([], pos);
const elevation = altitude ?
tr._centerAltitude + altitude :
tr.elevation ?
tr.elevation.getAtPointOrZero(tr.locationCoordinate(lngLat), tr._centerAltitude) :
tr._centerAltitude;
const upScale = mercatorZfromAltitude(1, 0) * EXTENT * elevation;
vec3.scaleAndAdd(pos, pos, up, upScale);
const matrix = mat4.identity(new Float64Array(16));
mat4.multiply(matrix, tr.pixelMatrix, tr.globeMatrix);
vec3.transformMat4(pos, pos, matrix);
return new Point(pos[0], pos[1]);
}

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

mapbox-before.mp4

After

mapbox-after.mp4

Launch Checklist

  • Make sure the PR title is descriptive and preferably reflects the change from the user's perspective.
  • Add additional detail and context in the PR description (with screenshots/videos if there are visual changes).
  • Manually test the debug page.
  • Write tests for all new functionality and make sure the CI checks pass.
  • Document any changes to public APIs.
  • Post benchmark scores if the change could affect performance.
  • Tag @mapbox/map-design-team @mapbox/static-apis if this PR includes style spec API or visual changes.
  • Tag @mapbox/gl-native if this PR includes shader changes or needs a native port.
  • Tag @mapbox/gl-native if this PR disables any test because it also needs to be disabled on their side.
  • 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 Gerbuuun requested a review from a team as a code owner December 4, 2025 23:58
@CLAassistant
Copy link

CLAassistant commented Dec 4, 2025

CLA assistant check
All committers have signed the CLA.

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.

Markers moves to incorrect positions when using a "globe" projection with a non-integer zoom level

2 participants