Skip to content

fix(maplibre): Update default view once projection is known - #9794

Merged
felixpalmer merged 5 commits into
masterfrom
felix/maplibre-globe-fix
Sep 25, 2025
Merged

felixpalmer merged 5 commits into
masterfrom
felix/maplibre-globe-fix

Conversation

@felixpalmer

Copy link
Copy Markdown
Collaborator

Fixes regression introduced by #9688

Background

This change means that getDefaultView is called too early, and getProjection returns undefined. We have to wait until the style is loaded before the projection can be retrieved.

The bug only happens with React, in interleaved mode, a common use case, including on deck.gl website: https://felixpalmer.github.io/deck.gl/examples/maplibre

Repro
diff --git a/examples/get-started/react/maplibre/app.jsx b/examples/get-started/react/maplibre/app.jsx
index 238df7a16..19d3e398d 100644
--- a/examples/get-started/react/maplibre/app.jsx
+++ b/examples/get-started/react/maplibre/app.jsx
@@ -61,7 +61,13 @@ function Root() {
   ];
 
   return (
-    <Map initialViewState={INITIAL_VIEW_STATE} mapStyle={MAP_STYLE}>
+    <Map 
+      initialViewState={INITIAL_VIEW_STATE}
+      mapStyle={MAP_STYLE}
+      projection="globe"
+      dragRotate={false}
+      maxPitch={0}
+      >
       {selected && (
         <Popup
           key={selected.properties.name}
@@ -73,7 +79,7 @@ function Root() {
           {selected.properties.name} ({selected.properties.abbrev})
         </Popup>
       )}
-      <DeckGLOverlay layers={layers} /* interleaved*/ />
+      <DeckGLOverlay layers={layers} interleaved />
       <NavigationControl position="top-left" />
     </Map>
   );

Without fix
Screenshot 2025-09-25 at 15 01 46
With fix
Screenshot 2025-09-25 at 15 01 57

Change List

  • Update default view when projection is known
  • Test

@coveralls

coveralls commented Sep 25, 2025 •

Copy link
Copy Markdown

Coverage Status

coverage: 91.129% (+0.02%) from 91.113%
when pulling 480c49c on felix/maplibre-globe-fix
into d4804c6 on master.

@chrisgervang chrisgervang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah! Great catch. Thank you.

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