Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion modules/mapbox/src/deck-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,17 @@ export function drawLayerGroup(
}

export function getProjection(map: Map): 'mercator' | 'globe' {
const projection = map.getProjection?.();
let projection;
try {
projection = map.getProjection?.();
} catch {
// map.getProjection() can throw if the map's style is not yet assigned
// (e.g. maplibre-gl's Map.prototype.getProjection() calls
// this.style.getProjection() without a guard on this.style).
// Return 'mercator' as the safe default — callers expect this when
// the map is not ready yet.
return 'mercator';
}
const type =
// maplibre projection spec
projection?.type ||
Expand Down