"use client"; import { useRef } from 'react'; import MapGL, { Marker, MapRef } from 'react-map-gl/maplibre'; import maplibregl, { type StyleSpecification } from 'maplibre-gl'; import 'maplibre-gl/dist/maplibre-gl.css'; import { Protocol } from 'pmtiles'; import styleDark from '@/public/style-dark.json'; const KARLSRUHE = { longitude: 8.4037, latitude: 49.0069 }; const mapStyle = styleDark as unknown as StyleSpecification; if (typeof window !== 'undefined') { const globalForProtocol = globalThis as typeof globalThis & { __maplibrePmtilesProtocol?: Protocol; }; if (!globalForProtocol.__maplibrePmtilesProtocol) { globalForProtocol.__maplibrePmtilesProtocol = new Protocol({ metadata: true }); maplibregl.addProtocol('pmtiles', globalForProtocol.__maplibrePmtilesProtocol.tile); } } export default function Map() { const mapRef = useRef(null); const onMapLoad = () => { mapRef.current?.flyTo({ center: [KARLSRUHE.longitude, KARLSRUHE.latitude], zoom: 8, speed: 0.8, curve: 1, essential: true }); }; return (
); }