Skip to content

Commit 71960a3

Browse files
chrisgervangclaude
andcommitted
fix(mapbox): automatically inject 'mapbox' view in overlaid mode for multi-view consistency
When custom views are provided without a view with id 'mapbox', MapboxOverlay now automatically injects the default 'mapbox' view in overlaid mode, matching the behavior in interleaved mode (where getViewport() already does this fallback). This ensures consistent behavior between interleaved and overlaid modes, and allows users to only specify additional views (like minimap, ortho) without having to manually include the base map view. The bug was discovered while implementing multi-view examples in #9946. When interleaved was false (overlaid mode), the multi-view example did not render airports/arcs layers because there was no 'mapbox' view for them to render in. In interleaved mode, the same example worked because getViewport() in deck-utils falls back to creating a 'mapbox' view when not found in custom views. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 83ac412 commit 71960a3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

modules/mapbox/src/mapbox-overlay.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default class MapboxOverlay implements IControl {
117117
...this._props,
118118
parent: container,
119119
parameters: {...getDefaultParameters(map, false), ...this._props.parameters},
120-
views: this._props.views || getDefaultView(map),
120+
views: this._getViews(map),
121121
viewState: getViewState(map)
122122
});
123123

@@ -270,12 +270,26 @@ export default class MapboxOverlay implements IControl {
270270
}
271271
};
272272

273+
private _getViews(map: Map) {
274+
if (!this._props.views) {
275+
return getDefaultView(map);
276+
}
277+
// Check if custom views include a view with id 'mapbox'
278+
const views = Array.isArray(this._props.views) ? this._props.views : [this._props.views];
279+
const hasMapboxView = views.some((v: any) => v.id === 'mapbox');
280+
if (hasMapboxView) {
281+
return this._props.views;
282+
}
283+
// Add default 'mapbox' view to custom views for consistency with interleaved mode
284+
return [getDefaultView(map), ...views];
285+
}
286+
273287
private _updateViewState = () => {
274288
const deck = this._deck;
275289
const map = this._map;
276290
if (deck && map) {
277291
deck.setProps({
278-
views: this._props.views || getDefaultView(map),
292+
views: this._getViews(map),
279293
viewState: getViewState(map)
280294
});
281295
// Redraw immediately if view state has changed

0 commit comments

Comments
 (0)