fix(map): stop hiding raster base and reset decks on projection switch

This commit is contained in:
htlee 2026-02-15 14:29:19 +09:00
부모 0ffadb2e66
커밋 6f7a82af4c

파일 보기

@ -737,6 +737,11 @@ export function Map3D({
const disposeMercatorOverlay = () => { const disposeMercatorOverlay = () => {
const current = overlayRef.current; const current = overlayRef.current;
if (!current) return; if (!current) return;
try {
current.setProps({ layers: [] } as never);
} catch {
// ignore
}
try { try {
map.removeControl(current as never); map.removeControl(current as never);
} catch { } catch {
@ -783,17 +788,21 @@ export function Map3D({
const currentProjection = extractProjectionType(map); const currentProjection = extractProjectionType(map);
const shouldSwitchProjection = currentProjection !== next; const shouldSwitchProjection = currentProjection !== next;
if (projection === "globe") {
disposeMercatorOverlay();
} else {
disposeGlobeDeckLayer();
}
try { try {
if (shouldSwitchProjection) { if (shouldSwitchProjection) {
map.setProjection({ type: next }); map.setProjection({ type: next });
} }
map.setRenderWorldCopies(next !== "globe"); map.setRenderWorldCopies(next !== "globe");
if (shouldSwitchProjection) { if (shouldSwitchProjection && currentProjection !== next && !cancelled && retries < maxRetries) {
if (!cancelled && retries < maxRetries) { retries += 1;
retries += 1; window.requestAnimationFrame(() => syncProjectionAndDeck());
window.requestAnimationFrame(() => syncProjectionAndDeck()); return;
return;
}
} }
} catch (e) { } catch (e) {
if (!cancelled && retries < maxRetries) { if (!cancelled && retries < maxRetries) {
@ -804,12 +813,6 @@ export function Map3D({
console.warn("Projection switch failed:", e); console.warn("Projection switch failed:", e);
} }
const oldOverlay = overlayRef.current;
if (projection === "globe" && oldOverlay) {
// Globe mode uses custom MapLibre deck layers and should fully replace Mercator overlays.
disposeMercatorOverlay();
}
if (projection === "globe") { if (projection === "globe") {
// Start with a clean globe Deck layer state to avoid partially torn-down renders. // Start with a clean globe Deck layer state to avoid partially torn-down renders.
disposeGlobeDeckLayer(); disposeGlobeDeckLayer();
@ -919,8 +922,7 @@ export function Map3D({
if (!map.isStyleLoaded()) return; if (!map.isStyleLoaded()) return;
const disableBathyHeavy = projection === "globe" && baseMap === "enhanced"; const disableBathyHeavy = projection === "globe" && baseMap === "enhanced";
const visHeavy = disableBathyHeavy ? "none" : "visible"; const visHeavy = disableBathyHeavy ? "none" : "visible";
const disableBaseMapSea = projection === "globe"; const seaVisibility = "visible" as const;
const seaVisibility = disableBaseMapSea ? "none" : "visible";
const seaRegex = /(water|sea|ocean|river|lake|coast|bay)/i; const seaRegex = /(water|sea|ocean|river|lake|coast|bay)/i;
// Globe + our injected bathymetry fill polygons can exceed MapLibre's per-segment vertex limit // Globe + our injected bathymetry fill polygons can exceed MapLibre's per-segment vertex limit
@ -940,8 +942,8 @@ export function Map3D({
} }
} }
// Vector basemap water/raster layers can flicker on globe with dense symbols/fills in this stack. // Vector basemap water layers can be tuned per-style. Keep visible by default,
// Hide them only in globe mode and restore on return. // only toggling layers that match an explicit water/sea signature.
try { try {
for (const layer of map.getStyle().layers || []) { for (const layer of map.getStyle().layers || []) {
const id = String(layer.id ?? ""); const id = String(layer.id ?? "");
@ -951,7 +953,7 @@ export function Map3D({
const type = String((layer as { type?: unknown }).type ?? "").toLowerCase(); const type = String((layer as { type?: unknown }).type ?? "").toLowerCase();
const isSea = seaRegex.test(id) || seaRegex.test(sourceLayer) || seaRegex.test(source); const isSea = seaRegex.test(id) || seaRegex.test(sourceLayer) || seaRegex.test(source);
const isRaster = type === "raster"; const isRaster = type === "raster";
if (!isSea && !isRaster) continue; if (!isSea) continue;
if (!map.getLayer(id)) continue; if (!map.getLayer(id)) continue;
if (isRaster && id === "seamark") continue; if (isRaster && id === "seamark") continue;
try { try {