fix(map): S57 ENC 오버레이 스타일 로드 완료 대기 후 레이어 추가

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jeonghyo.k 2026-04-01 19:08:34 +09:00
부모 38d11df363
커밋 08bcfbf24d

파일 보기

@ -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]);