import { memo, useState } from 'react'; import { Marker, Popup } from 'react-map-gl/maplibre'; import { ME_FACILITIES, ME_FACILITY_TYPE_META } from '../../data/middleEastFacilities'; import type { MEFacility } from '../../data/middleEastFacilities'; export const MEFacilityLayer = memo(function MEFacilityLayer() { const [selected, setSelected] = useState(null); return ( <> {ME_FACILITIES.map(f => { const meta = ME_FACILITY_TYPE_META[f.type]; return ( { e.originalEvent.stopPropagation(); setSelected(f); }}>
{meta.icon}
{f.nameKo.length > 12 ? f.nameKo.slice(0, 12) + '..' : f.nameKo}
); })} {selected && (() => { const meta = ME_FACILITY_TYPE_META[selected.type]; return ( setSelected(null)} closeOnClick={false} anchor="bottom" maxWidth="320px" className="gl-popup">
{selected.flag} {meta.icon} {selected.nameKo}
{meta.label} {selected.country}
{selected.description}
{selected.name}
{selected.lat.toFixed(4)}°{selected.lat >= 0 ? 'N' : 'S'}, {selected.lng.toFixed(4)}°E
); })()} ); });