Skip to content

Add globe projection support and 3D features toggle#975

Open
chriswhong wants to merge 3 commits into
mainfrom
cw/add-globe-projection
Open

Add globe projection support and 3D features toggle#975
chriswhong wants to merge 3 commits into
mainfrom
cw/add-globe-projection

Conversation

@chriswhong
Copy link
Copy Markdown
Contributor

@chriswhong chriswhong commented May 20, 2026

Summary

  • Adds Globe and Mercator projection selector to the layers/basemap popover, persisted in sessionStorage
  • Adds Show 3D Features toggle (buildings, trees, landmarks, facades) for Mapbox Standard-based styles, grayed out for Outdoors/OSM
  • Fixes vertex handle overlay alignment in globe mode: uses a round-trip through map.project()viewport.unproject() to correct the per-frame position offset between Mapbox's globe math and deck.gl's GlobeViewport
  • Fixes initial style loading race condition where globe projection caused Mapbox to internally load Standard style before the explicit setStyle() call; projection is now applied in onMapStyleLoad after each style load
  • Adds async setStyle sequence counter to prevent stale fetches from overwriting newer style loads
  • Skips globe vertex correction in Mercator mode
  • Default initial camera: zoom 2, center [0, 20]
geojson_io___Powered_by_Mapbox_🔊_and_CHANGELOG_md_—_geojson_io_and_index_html_—_tmp-esm-mapbox

🤖 Generated with Claude Code

chriswhong and others added 3 commits May 19, 2026 13:57
Adds a checkbox to the styles popover that controls 3D buildings, trees,
landmarks, and facades for Mapbox Standard-based styles. Grayed out for
Outdoors and OSM. Persisted in sessionStorage alongside other style options.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add Projection section to the layers popover with Globe and Mercator
  buttons, persisted in sessionStorage
- Fix initial style loading: remove projection from Map constructor to
  prevent Mapbox from racing with an internal Standard style load; apply
  projection in onMapStyleLoad instead
- Fix stale async setStyle race condition with a sequence counter
- Skip globe vertex correction in Mercator mode
- Default initial camera to zoom 2, center [0, 20]
- Add show3dFeatures and mapProjection to StyleOptions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chriswhong chriswhong requested a review from a team as a code owner May 20, 2026 15:48
@chriswhong chriswhong changed the title Add globe projection support Add globe projection support and 3D features toggle May 20, 2026
Copy link
Copy Markdown
Contributor

@AndrewSepic AndrewSepic left a comment

Choose a reason for hiding this comment

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

Overall this is working pretty well. Glad we could find a solution to the problem. Also, happy to learn that Deck.GL has an experimental GlobeView which helps bridge the gap. I made a few comments/suggestions to remove comments I feel are not needed. There may be more self explanatory comments which could be removed.

Two issues I want to flag:

Dancing points in Globe view

When you are in glob view and are moving the map around we see this drift and wiggle on points as this _buildScatterplotLayer is processing the math for the points. I'm not sure if this is a blocker, but it does feel a like a not complete solution. Or something that isn't ideal. (See video in slack)

Can't change projection with classic styles

If the app is currently running a classic style (OSM or Outdoors) you cannot change the projection of the map. The UI state will update, but the map does not update with the new projection.

const map = event.target as mapboxgl.Map;
// disable terrain. If enabled in the style (as in Mapbox Standard style), it causes an alignment bug in the deck.gl overlay
map.setTerrain(null);
// Apply the desired projection after each style load. Setting projection before
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure we need this comment here. Glad the race condition was removed, but don't think we need to call this out.

]) {
this.map.setConfigProperty('basemap', property, show3d);
}
// Projection can change without a full style reload
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should Probably remove this comment.

@bijanps
Copy link
Copy Markdown

bijanps commented May 26, 2026

perfect

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.

3 participants