From 08bcfbf24d4b52c48f257700e8c9a3ed7894b19c Mon Sep 17 00:00:00 2001 From: "jeonghyo.k" Date: Wed, 1 Apr 2026 19:08:34 +0900 Subject: [PATCH] =?UTF-8?q?fix(map):=20S57=20ENC=20=EC=98=A4=EB=B2=84?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=20=EC=8A=A4=ED=83=80=EC=9D=BC=20=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EC=99=84=EB=A3=8C=20=EB=8C=80=EA=B8=B0=20=ED=9B=84?= =?UTF-8?q?=20=EB=A0=88=EC=9D=B4=EC=96=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- .../src/common/components/map/S57EncOverlay.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/frontend/src/common/components/map/S57EncOverlay.tsx b/frontend/src/common/components/map/S57EncOverlay.tsx index 692f336..0ad2e72 100644 --- a/frontend/src/common/components/map/S57EncOverlay.tsx +++ b/frontend/src/common/components/map/S57EncOverlay.tsx @@ -137,14 +137,21 @@ export function S57EncOverlay({ visible }: S57EncOverlayProps) { if (!map) return; if (visible) { - addEncLayers(map); + const doAdd = () => addEncLayers(map); + + if (map.isStyleLoaded()) { + doAdd(); + } else { + map.once('style.load', doAdd); + } + + return () => { + map.off('style.load', doAdd); + removeEncLayers(map); + }; } else { removeEncLayers(map); } - - return () => { - if (map) removeEncLayers(map); - }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [visible, mapRef]);