- @trails-cool/types: Route, Activity, Waypoint, RouteVersion, RouteMetadata - @trails-cool/gpx: GPX parser (XML→waypoints/tracks/elevation) and generator with round-trip test, haversine distance, elevation gain/loss computation - @trails-cool/map: MapView (Leaflet + OSM/OpenTopoMap/CyclOSM layer switcher), RouteLayer (GeoJSON polyline rendering) - @trails-cool/ui: Button (primary/secondary/ghost), Input (with label/error), Card components with Tailwind styling - @trails-cool/i18n: react-i18next config with English + German translations, browser language detection, fallback to English All 13 unit tests pass. Both apps build successfully. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
34 lines
924 B
TypeScript
34 lines
924 B
TypeScript
import { MapContainer, TileLayer, LayersControl } from "react-leaflet";
|
|
import { baseLayers } from "./layers";
|
|
import "leaflet/dist/leaflet.css";
|
|
|
|
export interface MapViewProps {
|
|
center?: [number, number];
|
|
zoom?: number;
|
|
className?: string;
|
|
children?: React.ReactNode;
|
|
}
|
|
|
|
export function MapView({
|
|
center = [50.1, 10.0],
|
|
zoom = 6,
|
|
className = "h-full w-full",
|
|
children,
|
|
}: MapViewProps) {
|
|
return (
|
|
<MapContainer center={center} zoom={zoom} className={className}>
|
|
<LayersControl position="topright">
|
|
{baseLayers.map((layer, i) => (
|
|
<LayersControl.BaseLayer key={layer.name} checked={i === 0} name={layer.name}>
|
|
<TileLayer
|
|
url={layer.url}
|
|
attribution={layer.attribution}
|
|
maxZoom={layer.maxZoom}
|
|
/>
|
|
</LayersControl.BaseLayer>
|
|
))}
|
|
</LayersControl>
|
|
{children}
|
|
</MapContainer>
|
|
);
|
|
}
|