Add globe projection support and 3D features toggle#975
Conversation
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>
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Should Probably remove this comment.
|
perfect |
Summary
map.project()→viewport.unproject()to correct the per-frame position offset between Mapbox's globe math and deck.gl's GlobeViewportsetStyle()call; projection is now applied inonMapStyleLoadafter each style loadsetStylesequence counter to prevent stale fetches from overwriting newer style loads🤖 Generated with Claude Code