Initial commit: Laadpalenviewer
Static-generation EV charging map for the Netherlands with two layers (passenger / logistics-freight), per-municipality crop-outs, and gemeente + province boundaries from PDOK/CBS. - data-pipeline/ (Node/TS): NDW OCPI download + classify (freight >=350kW / MCS / megawatt / Milence,WattHub) + external sources (curated, OCM, EAFO) + PDOK CBS boundaries -> static GeoJSON/JSON. - webapp/ (Next.js 16 + React 19 + deck.gl + MapLibre): national view loads all points without details; selecting a gemeente eagerly loads its detail bundle (OCPI EVSE/connector/tariff + status) for instant marker clicks. Passenger colored by OCPI status (fleetsim-style), freight amber/megawatt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,255 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
/**
|
||||
* Geocoding API proxy for PDOK Locatieserver
|
||||
*
|
||||
* This endpoint proxies requests to the PDOK (Publieke Dienstverlening Op de Kaart)
|
||||
* Locatieserver API, which provides geocoding and address lookup services for
|
||||
* the Netherlands.
|
||||
*
|
||||
* Benefits of using a proxy:
|
||||
* - Hides API details from client
|
||||
* - Bypasses CSP restrictions
|
||||
* - Allows server-side rate limiting
|
||||
* - Can add caching if needed
|
||||
*/
|
||||
|
||||
// Simple in-memory rate limiting
|
||||
const rateLimitStore = new Map<string, { count: number; resetTime: number }>();
|
||||
const RATE_LIMIT = 30; // requests per minute
|
||||
const RATE_LIMIT_WINDOW = 60 * 1000; // 1 minute
|
||||
|
||||
interface PDOKSuggestion {
|
||||
weergavenaam: string; // Display name (e.g., "Kalverstraat 1, Amsterdam")
|
||||
id: string;
|
||||
type: string; // Type (e.g., "adres", "weg", "plaats")
|
||||
score: number;
|
||||
centroide_ll?: string; // "POINT(lon lat)"
|
||||
gemeentenaam?: string; // Municipality name
|
||||
}
|
||||
|
||||
interface PDOKLookupResult {
|
||||
weergavenaam: string;
|
||||
centroide_ll: string;
|
||||
gemeentenaam: string;
|
||||
straatnaam?: string;
|
||||
huisnummer?: string;
|
||||
postcode?: string;
|
||||
woonplaatsnaam?: string;
|
||||
}
|
||||
|
||||
function checkRateLimit(ip: string): boolean {
|
||||
const now = Date.now();
|
||||
const record = rateLimitStore.get(ip);
|
||||
|
||||
if (!record || now > record.resetTime) {
|
||||
rateLimitStore.set(ip, {
|
||||
count: 1,
|
||||
resetTime: now + RATE_LIMIT_WINDOW,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (record.count >= RATE_LIMIT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
record.count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
// Get client IP for rate limiting
|
||||
const ip =
|
||||
request.headers.get('x-forwarded-for') ||
|
||||
request.headers.get('x-real-ip') ||
|
||||
'unknown';
|
||||
|
||||
// Check rate limit
|
||||
if (!checkRateLimit(ip)) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
error: 'Rate limit exceeded',
|
||||
message: `Maximum ${RATE_LIMIT} requests per minute`,
|
||||
}),
|
||||
{
|
||||
status: 429,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Retry-After': String(RATE_LIMIT_WINDOW / 1000),
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Get query parameters
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
const query = searchParams.get('q');
|
||||
const id = searchParams.get('id'); // For lookup after selection
|
||||
const lat = searchParams.get('lat'); // For reverse geocoding
|
||||
const lon = searchParams.get('lon');
|
||||
|
||||
if (!query && !id && !(lat && lon)) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
error: 'Missing parameter',
|
||||
message: 'Provide "q" (query), "id" (lookup), or "lat"+"lon" (reverse)',
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Reverse geocoding: nearest address for a coordinate
|
||||
if (lat && lon) {
|
||||
const latNum = parseFloat(lat);
|
||||
const lonNum = parseFloat(lon);
|
||||
if (!Number.isFinite(latNum) || !Number.isFinite(lonNum)) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({ error: 'Invalid coordinates' }),
|
||||
{ status: 400, headers: { 'Content-Type': 'application/json' } }
|
||||
);
|
||||
}
|
||||
|
||||
const reverseUrl = `https://api.pdok.nl/bzk/locatieserver/search/v3_1/reverse?lat=${latNum}&lon=${lonNum}&rows=1&type=adres&fl=*`;
|
||||
const response = await fetch(reverseUrl, { headers: { Accept: 'application/json' } });
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`PDOK reverse API error: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const doc = data.response?.docs?.[0];
|
||||
|
||||
if (!doc) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({ error: 'Not found', message: 'No address near this location' }),
|
||||
{ status: 404, headers: { 'Content-Type': 'application/json' } }
|
||||
);
|
||||
}
|
||||
|
||||
const centroidMatch = doc.centroide_ll?.match(/POINT\(([\d.]+) ([\d.]+)\)/);
|
||||
const coordinates = centroidMatch
|
||||
? {
|
||||
longitude: parseFloat(centroidMatch[1]),
|
||||
latitude: parseFloat(centroidMatch[2]),
|
||||
}
|
||||
: { longitude: lonNum, latitude: latNum };
|
||||
|
||||
return NextResponse.json({
|
||||
id: doc.id,
|
||||
displayName: doc.weergavenaam,
|
||||
municipality: doc.gemeentenaam,
|
||||
street: doc.straatnaam,
|
||||
houseNumber: doc.huisnummer,
|
||||
postalCode: doc.postcode,
|
||||
city: doc.woonplaatsnaam,
|
||||
coordinates,
|
||||
});
|
||||
}
|
||||
|
||||
// If ID provided, do a lookup (get full details for selected suggestion)
|
||||
if (id) {
|
||||
const lookupUrl = `https://api.pdok.nl/bzk/locatieserver/search/v3_1/lookup?id=${encodeURIComponent(id)}&fl=*`;
|
||||
|
||||
const response = await fetch(lookupUrl, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`PDOK API error: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const doc = data.response?.docs?.[0];
|
||||
|
||||
if (!doc) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
error: 'Not found',
|
||||
message: 'Address not found',
|
||||
}),
|
||||
{
|
||||
status: 404,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Parse centroid coordinates
|
||||
const centroidMatch = doc.centroide_ll?.match(/POINT\(([\d.]+) ([\d.]+)\)/);
|
||||
const coordinates = centroidMatch
|
||||
? {
|
||||
longitude: parseFloat(centroidMatch[1]),
|
||||
latitude: parseFloat(centroidMatch[2]),
|
||||
}
|
||||
: null;
|
||||
|
||||
return NextResponse.json({
|
||||
id: doc.id,
|
||||
displayName: doc.weergavenaam,
|
||||
municipality: doc.gemeentenaam,
|
||||
street: doc.straatnaam,
|
||||
houseNumber: doc.huisnummer,
|
||||
postalCode: doc.postcode,
|
||||
city: doc.woonplaatsnaam,
|
||||
coordinates,
|
||||
});
|
||||
}
|
||||
|
||||
// Otherwise, do a suggest (autocomplete search)
|
||||
const suggestUrl = `https://api.pdok.nl/bzk/locatieserver/search/v3_1/suggest?q=${encodeURIComponent(
|
||||
query!
|
||||
)}&rows=10`;
|
||||
|
||||
const response = await fetch(suggestUrl, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`PDOK API error: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const suggestions = data.response?.docs || [];
|
||||
|
||||
// Transform PDOK response to simpler format
|
||||
const results = suggestions.map((doc: PDOKSuggestion) => ({
|
||||
id: doc.id,
|
||||
displayName: doc.weergavenaam,
|
||||
type: doc.type,
|
||||
municipality: doc.gemeentenaam,
|
||||
score: doc.score,
|
||||
}));
|
||||
|
||||
return NextResponse.json({
|
||||
query: query,
|
||||
results,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Geocoding error:', error);
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
error: 'Internal server error',
|
||||
message: 'Failed to fetch geocoding results',
|
||||
}),
|
||||
{
|
||||
status: 500,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState, Suspense } from "react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import dynamic from "next/dynamic";
|
||||
import {
|
||||
CropoutData,
|
||||
ChargeFeature,
|
||||
BoundaryFeature,
|
||||
DEFAULT_FILTERS,
|
||||
} from "@/types/charging";
|
||||
|
||||
const MapDeck = dynamic(() => import("@/components/MapDeck"), { ssr: false });
|
||||
|
||||
const NL_BOUNDS: [number, number, number, number] = [3.31, 50.75, 7.21, 53.47];
|
||||
|
||||
function EmbedInner() {
|
||||
const params = useSearchParams();
|
||||
const raw = params.get("gemeente");
|
||||
const slug = raw === "alle-gemeenten" ? "nederland" : raw || "utrecht";
|
||||
|
||||
const [chargeFeatures, setChargeFeatures] = useState<ChargeFeature[]>([]);
|
||||
const [boundaryFeatures, setBoundaryFeatures] = useState<BoundaryFeature[]>([]);
|
||||
const [bounds, setBounds] = useState<[number, number, number, number] | null>(null);
|
||||
const [selected, setSelected] = useState<ChargeFeature | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
const load = async () => {
|
||||
if (slug === "nederland") {
|
||||
const [p, f] = (await Promise.all([
|
||||
fetch("/data/nederland-passenger.geojson").then((r) => r.json()),
|
||||
fetch("/data/nederland-freight.geojson").then((r) => r.json()),
|
||||
])) as CropoutData[];
|
||||
if (cancelled) return;
|
||||
setChargeFeatures([...(p.features as ChargeFeature[]), ...(f.features as ChargeFeature[])]);
|
||||
setBounds(NL_BOUNDS);
|
||||
} else {
|
||||
const crop = (await fetch(`/data/gemeenten/${slug}.geojson`).then((r) => r.json())) as CropoutData;
|
||||
if (cancelled) return;
|
||||
setChargeFeatures(crop.features.filter((f) => f.properties.type === "charge") as ChargeFeature[]);
|
||||
setBoundaryFeatures(crop.features.filter((f) => f.properties.type === "boundary") as BoundaryFeature[]);
|
||||
setBounds(crop.metadata.bounds ?? null);
|
||||
}
|
||||
};
|
||||
load().catch((e) => console.error(e));
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [slug]);
|
||||
|
||||
return (
|
||||
<div className="h-screen w-screen">
|
||||
<MapDeck
|
||||
chargeFeatures={chargeFeatures}
|
||||
boundaryFeatures={boundaryFeatures}
|
||||
bounds={bounds}
|
||||
filters={DEFAULT_FILTERS}
|
||||
selectedLocationId={selected?.properties.locationId ?? null}
|
||||
onSelect={setSelected}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function EmbedPage() {
|
||||
return (
|
||||
<Suspense fallback={<div className="h-screen w-screen flex items-center justify-center text-gray-500">Kaart laden…</div>}>
|
||||
<EmbedInner />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
:root {
|
||||
--background: #ffffff;
|
||||
--foreground: #171717;
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--font-sans: var(--font-geist-sans);
|
||||
--font-mono: var(--font-geist-mono);
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
/* MapLibre popup tweaks */
|
||||
.maplibregl-popup-content {
|
||||
padding: 0;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.scrollbar-hide {
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.scrollbar-hide::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { Metadata, Viewport } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import { Analytics } from "@vercel/analytics/react";
|
||||
import "./globals.css";
|
||||
|
||||
const geistSans = Geist({ variable: "--font-geist-sans", subsets: ["latin"] });
|
||||
const geistMono = Geist_Mono({ variable: "--font-geist-mono", subsets: ["latin"] });
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Laadpalenviewer - Laadpunten voor personenauto's en logistiek in Nederland",
|
||||
description:
|
||||
"Interactieve kaart van laadpunten in Nederland: personenauto-laadpunten (NDW OCPI) en logistieke/vracht-laadpunten (Milence, WattHub, megawatt charging) per gemeente, met gemeente- en provinciegrenzen van PDOK/CBS.",
|
||||
openGraph: {
|
||||
title: "Laadpalenviewer",
|
||||
description:
|
||||
"Laadpunten voor personenauto's en logistiek/vracht in Nederland op een interactieve kaart per gemeente.",
|
||||
type: "website",
|
||||
locale: "nl_NL",
|
||||
},
|
||||
};
|
||||
|
||||
export const viewport: Viewport = {
|
||||
width: "device-width",
|
||||
initialScale: 1,
|
||||
viewportFit: "cover",
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
return (
|
||||
<html lang="nl">
|
||||
<body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
|
||||
{children}
|
||||
<Analytics />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect, useMemo } from "react";
|
||||
import dynamic from "next/dynamic";
|
||||
import MunicipalitySelector from "@/components/MunicipalitySelector";
|
||||
import AddressSearchInput from "@/components/AddressSearchInput";
|
||||
import FilterPanel from "@/components/FilterPanel";
|
||||
import StatsPanel from "@/components/StatsPanel";
|
||||
import LocationDetailPanel from "@/components/LocationDetailPanel";
|
||||
import AboutModal from "@/components/AboutModal";
|
||||
import ShareModal from "@/components/ShareModal";
|
||||
import {
|
||||
Municipality,
|
||||
CropoutData,
|
||||
DetailBundle,
|
||||
ChargeFeature,
|
||||
BoundaryFeature,
|
||||
Filters,
|
||||
DEFAULT_FILTERS,
|
||||
} from "@/types/charging";
|
||||
|
||||
const MapDeck = dynamic(() => import("@/components/MapDeck"), {
|
||||
ssr: false,
|
||||
loading: () => (
|
||||
<div className="w-full h-full flex items-center justify-center bg-gray-100">
|
||||
<p className="text-gray-500">Kaart laden…</p>
|
||||
</div>
|
||||
),
|
||||
});
|
||||
|
||||
const NL_BOUNDS: [number, number, number, number] = [3.31, 50.75, 7.21, 53.47];
|
||||
const DEFAULT_SLUG = "utrecht";
|
||||
|
||||
export default function Home() {
|
||||
const [municipalities, setMunicipalities] = useState<Municipality[]>([]);
|
||||
const [selectedMunicipality, setSelectedMunicipality] = useState<string>("");
|
||||
const [chargeFeatures, setChargeFeatures] = useState<ChargeFeature[]>([]);
|
||||
const [boundaryFeatures, setBoundaryFeatures] = useState<BoundaryFeature[]>([]);
|
||||
const [bounds, setBounds] = useState<[number, number, number, number] | null>(null);
|
||||
const [details, setDetails] = useState<DetailBundle>({});
|
||||
const [gemeenteName, setGemeenteName] = useState<string>("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [filters, setFilters] = useState<Filters>(DEFAULT_FILTERS);
|
||||
const [selected, setSelected] = useState<ChargeFeature | null>(null);
|
||||
const [showAbout, setShowAbout] = useState(false);
|
||||
const [showShare, setShowShare] = useState(false);
|
||||
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
|
||||
|
||||
const isNational = selectedMunicipality === "nederland";
|
||||
|
||||
// Load municipalities once.
|
||||
useEffect(() => {
|
||||
fetch("/municipalities.json")
|
||||
.then((r) => r.json())
|
||||
.then((data: Municipality[]) => {
|
||||
const sorted = data.sort((a, b) => {
|
||||
if (a.slug === "nederland") return 1;
|
||||
if (b.slug === "nederland") return -1;
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
setMunicipalities(sorted);
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const raw = params.get("gemeente");
|
||||
const param = raw === "alle-gemeenten" ? "nederland" : raw;
|
||||
const last = localStorage.getItem("lastSelectedMunicipality");
|
||||
if (param && sorted.find((m) => m.slug === param)) setSelectedMunicipality(param);
|
||||
else if (last && sorted.find((m) => m.slug === last)) setSelectedMunicipality(last);
|
||||
else setSelectedMunicipality(sorted.find((m) => m.slug === DEFAULT_SLUG) ? DEFAULT_SLUG : sorted[0].slug);
|
||||
})
|
||||
.catch((e) => console.error("municipalities load failed", e));
|
||||
}, []);
|
||||
|
||||
// Persist selection to URL + localStorage.
|
||||
useEffect(() => {
|
||||
if (!selectedMunicipality || municipalities.length === 0) return;
|
||||
localStorage.setItem("lastSelectedMunicipality", selectedMunicipality);
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set("gemeente", isNational ? "alle-gemeenten" : selectedMunicipality);
|
||||
window.history.replaceState({}, "", url.toString());
|
||||
}, [selectedMunicipality, municipalities, isNational]);
|
||||
|
||||
// Load data when municipality changes.
|
||||
useEffect(() => {
|
||||
if (!selectedMunicipality) return;
|
||||
let cancelled = false;
|
||||
setLoading(true);
|
||||
setSelected(null);
|
||||
|
||||
const load = async () => {
|
||||
if (selectedMunicipality === "nederland") {
|
||||
const [pRes, fRes, provRes] = await Promise.all([
|
||||
fetch("/data/nederland-passenger.geojson"),
|
||||
fetch("/data/nederland-freight.geojson"),
|
||||
fetch("/data/provinces.geojson"),
|
||||
]);
|
||||
const [p, f, prov] = (await Promise.all([pRes.json(), fRes.json(), provRes.json()])) as CropoutData[];
|
||||
if (cancelled) return;
|
||||
setChargeFeatures([
|
||||
...(p.features as ChargeFeature[]),
|
||||
...(f.features as ChargeFeature[]),
|
||||
]);
|
||||
setBoundaryFeatures(prov.features as BoundaryFeature[]);
|
||||
setBounds(NL_BOUNDS);
|
||||
setDetails({});
|
||||
setGemeenteName("Nederland");
|
||||
} else {
|
||||
const [cropRes, detRes] = await Promise.all([
|
||||
fetch(`/data/gemeenten/${selectedMunicipality}.geojson`),
|
||||
fetch(`/data/gemeenten/${selectedMunicipality}.details.json`),
|
||||
]);
|
||||
const crop = (await cropRes.json()) as CropoutData;
|
||||
const bundle = (await detRes.json()) as DetailBundle;
|
||||
if (cancelled) return;
|
||||
const charges = crop.features.filter((f) => f.properties.type === "charge") as ChargeFeature[];
|
||||
const boundaries = crop.features.filter((f) => f.properties.type === "boundary") as BoundaryFeature[];
|
||||
setChargeFeatures(charges);
|
||||
setBoundaryFeatures(boundaries);
|
||||
setBounds(crop.metadata.bounds ?? null);
|
||||
setDetails(bundle);
|
||||
setGemeenteName(crop.metadata.gemeente ?? selectedMunicipality);
|
||||
}
|
||||
};
|
||||
|
||||
load()
|
||||
.catch((e) => console.error("data load failed", e))
|
||||
.finally(() => !cancelled && setLoading(false));
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [selectedMunicipality]);
|
||||
|
||||
const { passengerCount, freightCount } = useMemo(() => {
|
||||
let p = 0;
|
||||
let f = 0;
|
||||
for (const feat of chargeFeatures) {
|
||||
if (feat.properties.layer === "freight") f++;
|
||||
else p++;
|
||||
}
|
||||
return { passengerCount: p, freightCount: f };
|
||||
}, [chargeFeatures]);
|
||||
|
||||
const selectedDetail = selected ? details[selected.properties.locationId] ?? null : null;
|
||||
|
||||
const handleAddressSelected = (slug: string) => {
|
||||
setSelectedMunicipality(slug);
|
||||
setMobileSidebarOpen(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-screen flex flex-col">
|
||||
{/* Header */}
|
||||
<header className="bg-white shadow-sm z-20">
|
||||
<div className="px-3 py-2 md:px-4 md:py-3 flex items-center gap-2 md:gap-4">
|
||||
<h1 className="text-lg md:text-xl font-bold text-gray-900 flex-shrink-0">
|
||||
🔌 <span className="hidden sm:inline">Laadpalenviewer</span>
|
||||
</h1>
|
||||
<div className="flex-1 min-w-0 max-w-[200px] sm:max-w-xs md:max-w-md">
|
||||
<MunicipalitySelector
|
||||
municipalities={municipalities}
|
||||
selected={selectedMunicipality}
|
||||
onChange={(slug) => {
|
||||
setSelectedMunicipality(slug);
|
||||
setMobileSidebarOpen(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="hidden md:block flex-1 max-w-md">
|
||||
<AddressSearchInput municipalities={municipalities} onAddressSelected={handleAddressSelected} />
|
||||
</div>
|
||||
{loading && (
|
||||
<div className="flex items-center gap-2 text-xs md:text-sm text-gray-500">
|
||||
<svg className="animate-spin h-4 w-4" fill="none" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
|
||||
</svg>
|
||||
<span className="hidden sm:inline">Laden…</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="hidden lg:flex gap-2 ml-auto">
|
||||
<button
|
||||
onClick={() => setShowShare(true)}
|
||||
className="px-3 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition"
|
||||
>
|
||||
Delen
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setShowAbout(true)}
|
||||
className="px-3 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition"
|
||||
>
|
||||
Over
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* Main */}
|
||||
<div className="flex-1 flex overflow-hidden relative">
|
||||
{mobileSidebarOpen && (
|
||||
<div className="md:hidden fixed inset-0 bg-black/50 z-30" onClick={() => setMobileSidebarOpen(false)} />
|
||||
)}
|
||||
<aside
|
||||
className={`fixed md:relative inset-y-0 left-0 z-40 md:z-auto w-[85vw] max-w-[320px] md:w-80
|
||||
bg-gray-50 p-3 md:p-4 overflow-y-auto space-y-3 md:space-y-4
|
||||
transform transition-transform duration-300 ease-in-out
|
||||
${mobileSidebarOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"} shadow-xl md:shadow-none`}
|
||||
>
|
||||
<StatsPanel gemeente={gemeenteName} chargeFeatures={chargeFeatures} />
|
||||
<FilterPanel
|
||||
filters={filters}
|
||||
onChange={setFilters}
|
||||
passengerCount={passengerCount}
|
||||
freightCount={freightCount}
|
||||
/>
|
||||
{isNational && (
|
||||
<p className="text-xs text-gray-500 px-1">
|
||||
Landelijk overzicht: alle laadpunten worden getoond zonder details. Kies een gemeente om
|
||||
details (laadpunten, connectoren, tarieven) te laden.
|
||||
</p>
|
||||
)}
|
||||
</aside>
|
||||
|
||||
<main className="flex-1 relative">
|
||||
<MapDeck
|
||||
chargeFeatures={chargeFeatures}
|
||||
boundaryFeatures={boundaryFeatures}
|
||||
bounds={bounds}
|
||||
filters={filters}
|
||||
selectedLocationId={selected?.properties.locationId ?? null}
|
||||
onSelect={setSelected}
|
||||
/>
|
||||
|
||||
<LocationDetailPanel
|
||||
selected={selected}
|
||||
detail={selectedDetail}
|
||||
loading={false}
|
||||
onClose={() => setSelected(null)}
|
||||
/>
|
||||
|
||||
{/* Mobile filter button */}
|
||||
<button
|
||||
onClick={() => setMobileSidebarOpen(true)}
|
||||
className="md:hidden fixed bottom-6 left-4 z-20 bg-blue-600 text-white px-4 py-3 rounded-full shadow-lg hover:bg-blue-700 transition text-sm font-medium"
|
||||
>
|
||||
Filters & stats
|
||||
</button>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="bg-white border-t border-gray-200 px-3 md:px-4 py-2">
|
||||
<div className="max-w-7xl mx-auto flex justify-between items-center text-xs text-gray-500">
|
||||
<button onClick={() => setShowAbout(true)} className="text-blue-600 hover:underline">
|
||||
Info over databronnen
|
||||
</button>
|
||||
<span>Bronnen: NDW OCPI · PDOK/CBS · Open Charge Map</span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<AboutModal isOpen={showAbout} onClose={() => setShowAbout(false)} />
|
||||
<ShareModal
|
||||
isOpen={showShare}
|
||||
onClose={() => setShowShare(false)}
|
||||
municipality={selectedMunicipality}
|
||||
municipalityName={municipalities.find((m) => m.slug === selectedMunicipality)?.name || selectedMunicipality}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user