trails/apps/planner/app/components/NearbyPoiMarkers.tsx
Ullrich Schäfer b45e69885d
poi-index: map-core selectors, planner.pois schema, /api/pois route + client, metrics
Replace the planner's Overpass proxy with a self-hosted POI index:
- map-core POI categories become structured tag selectors (single source of
  truth) + osmium filter / classification helpers
- planner.pois PostGIS table (centroid points, GiST + category indexes)
- /api/pois serving route (session + same-origin + rate limit, 100 cap)
- lib/pois.ts client (renamed from overpass.ts; GET, quantized bbox)
- metrics: poi_api_requests_total + DB-collected index rows/age gauges;
  drop overpass_* metrics
- remove /api/overpass proxy + dead OVERPASS_URLS on the planner service
  (Journal surface backfill still uses it via code default)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 22:38:03 +02:00

49 lines
1.4 KiB
TypeScript

import L from "leaflet";
import { Marker, Tooltip } from "react-leaflet";
import type { Poi } from "~/lib/pois";
import type { PoiCategory } from "@trails-cool/map-core";
interface NearbyPoiMarkersProps {
pois: Poi[];
categories: PoiCategory[];
onSnap: (poi: Poi) => void;
}
function nearbyPoiIcon(color: string, icon: string): L.DivIcon {
return L.divIcon({
className: "",
html: `<div style="
width:18px;height:18px;border-radius:50%;
background:${color};color:white;
display:flex;align-items:center;justify-content:center;
font-size:10px;
border:1.5px solid white;box-shadow:0 1px 3px rgba(0,0,0,0.25);
transform:translate(-9px,-9px);
">${icon}</div>`,
iconSize: [0, 0],
});
}
export function NearbyPoiMarkers({ pois, categories, onSnap }: NearbyPoiMarkersProps) {
return (
<>
{pois.map((poi) => {
const cat = categories.find((c) => c.id === poi.category);
if (!cat) return null;
return (
<Marker
key={poi.id}
position={[poi.lat, poi.lon]}
icon={nearbyPoiIcon(cat.color, cat.icon)}
eventHandlers={{ click: () => onSnap(poi) }}
zIndexOffset={900}
>
<Tooltip direction="top" offset={[0, -10]} opacity={0.95}>
<span>{poi.name ?? cat.icon} {cat.icon !== poi.name ? cat.icon : ""}</span>
</Tooltip>
</Marker>
);
})}
</>
);
}