- ENC 전자해도: gcnautical 벡터 타일 연동 (gc-wing-dev 이식) - 상단 위성/ENC 토글 버튼 + ⚙ 드롭다운 설정 패널 - 12개 심볼 토글 + 8개 색상 수정 + 초기화 - mapMode/encSettings localStorage 영속화 - style.load 대기 패턴으로 스타일 전환 시 설정 자동 적용 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 lines
807 B
TypeScript
23 lines
807 B
TypeScript
import type { StyleSpecification } from 'maplibre-gl';
|
|
|
|
const NAUTICAL_STYLE_URL = 'https://tiles.gcnautical.com/styles/nautical.json';
|
|
|
|
const SERVER_FONTS = ['Noto Sans CJK KR Regular', 'Noto Sans Regular'];
|
|
|
|
export async function fetchEncStyle(signal: AbortSignal): Promise<StyleSpecification> {
|
|
const res = await fetch(NAUTICAL_STYLE_URL, { signal });
|
|
if (!res.ok) throw new Error(`ENC style fetch failed: ${res.status}`);
|
|
const style = (await res.json()) as StyleSpecification;
|
|
|
|
for (const layer of style.layers) {
|
|
const layout = (layer as { layout?: Record<string, unknown> }).layout;
|
|
if (!layout) continue;
|
|
const tf = layout['text-font'];
|
|
if (Array.isArray(tf) && tf.every((v) => typeof v === 'string')) {
|
|
layout['text-font'] = SERVER_FONTS;
|
|
}
|
|
}
|
|
|
|
return style;
|
|
}
|