import { useState } from 'react'; import { useTranslation } from 'react-i18next'; 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 ( ); } return ( ); } export function NavWarningLayer() { const [selected, setSelected] = useState(null); const { t } = useTranslation(); 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}
{t('navWarning.altitude')}: {selected.altitude}
{selected.lat.toFixed(4)}°N, {selected.lng.toFixed(4)}°E
{t('navWarning.source')}: {selected.source}
{t('navWarning.khoaLink')}
)} ); }