import { useState } from 'react'; import { Marker, Popup } from 'react-map-gl/maplibre'; import { MILITARY_BASES } from '../../data/militaryBases'; import type { MilitaryBase } from '../../data/militaryBases'; const COUNTRY_STYLE: Record = { CN: { color: '#ef4444', flag: '🇨🇳', label: '중국' }, JP: { color: '#f472b6', flag: '🇯🇵', label: '일본' }, KP: { color: '#f97316', flag: '🇰🇵', label: '북한' }, TW: { color: '#10b981', flag: '🇹🇼', label: '대만' }, }; const TYPE_STYLE: Record = { naval: { icon: '⚓', label: '해군기지', color: '#3b82f6' }, airforce: { icon: '✈️', label: '공군기지', color: '#f59e0b' }, army: { icon: '🪖', label: '육군기지', color: '#22c55e' }, missile: { icon: '🚀', label: '미사일기지', color: '#ef4444' }, joint: { icon: '⭐', label: '합동기지', color: '#a78bfa' }, }; function _MilIcon({ type, size = 16 }: { type: string; size?: number }) { const ts = TYPE_STYLE[type] || TYPE_STYLE.army; return ( {ts.icon} ); } export function MilitaryBaseLayer() { const [selected, setSelected] = useState(null); return ( <> {MILITARY_BASES.map(base => { const _cs = COUNTRY_STYLE[base.country] || COUNTRY_STYLE.CN; const ts = TYPE_STYLE[base.type] || TYPE_STYLE.army; return ( { e.originalEvent.stopPropagation(); setSelected(base); }}>
{ts.icon}
{base.nameKo.length > 12 ? base.nameKo.slice(0, 12) + '..' : base.nameKo}
); })} {selected && (() => { const cs = COUNTRY_STYLE[selected.country] || COUNTRY_STYLE.CN; const ts = TYPE_STYLE[selected.type] || TYPE_STYLE.army; return ( setSelected(null)} closeOnClick={false} anchor="bottom" maxWidth="300px" className="gl-popup">
{cs.flag} {ts.icon} {selected.nameKo}
{ts.label} {cs.label}
{selected.description}
시설명 : {selected.name}
유형 : {ts.label}
{selected.lat.toFixed(4)}°N, {selected.lng.toFixed(4)}°E
); })()} ); }