import { useState } from 'react'; import { Marker, Popup } from 'react-map-gl/maplibre'; import { NAV_WARNINGS, NW_LEVEL_LABEL, NW_ORG_LABEL } from '../services/navWarning'; import type { NavWarning, NavWarningLevel, TrainingOrg } from '../services/navWarning'; const LEVEL_COLOR: Record = { danger: '#ef4444', caution: '#eab308', info: '#3b82f6', }; const ORG_COLOR: Record = { '해군': '#8b5cf6', '해병대': '#22c55e', '공군': '#f97316', '육군': '#ef4444', '해경': '#3b82f6', '국과연': '#eab308', }; function WarningIcon({ level, org, size }: { level: NavWarningLevel; org: TrainingOrg; size: number }) { const color = ORG_COLOR[org]; if (level === 'danger') { return ( ); } // caution (해경 등) return ( ); } export function NavWarningLayer() { const [selected, setSelected] = useState(null); return ( <> {NAV_WARNINGS.map(w => { const color = ORG_COLOR[w.org]; const size = w.level === 'danger' ? 16 : 14; return ( { e.originalEvent.stopPropagation(); setSelected(w); }}>
{w.id}
); })} {selected && ( setSelected(null)} closeOnClick={false} anchor="bottom" maxWidth="320px" className="gl-popup">
{selected.title}
{NW_LEVEL_LABEL[selected.level]} {NW_ORG_LABEL[selected.org]} {selected.area}
{selected.description}
사용고도: {selected.altitude}
{selected.lat.toFixed(4)}°N, {selected.lng.toFixed(4)}°E
출처: {selected.source}
KHOA 항행경보 상황판 바로가기
)} ); }