import { useEffect, useRef } from "react"; import { MapContainer, TileLayer, GeoJSON, useMap } from "react-leaflet"; import L from "leaflet"; import type { GeoJsonObject } from "geojson"; import "leaflet/dist/leaflet.css"; function FitBounds({ data }: { data: GeoJsonObject }) { const map = useMap(); const fitted = useRef(false); useEffect(() => { if (fitted.current) return; const layer = L.geoJSON(data); const bounds = layer.getBounds(); if (bounds.isValid()) { map.fitBounds(bounds, { padding: [20, 20] }); fitted.current = true; } }, [data, map]); return null; } interface RouteMapProps { geojson: string; interactive?: boolean; className?: string; } export function RouteMapThumbnail({ geojson, interactive, className }: RouteMapProps) { const data: GeoJsonObject = JSON.parse(geojson); return ( OpenStreetMap' : undefined} /> ); }