From ceb2486f35b863763cdacfae83b0bda7c36d46fc Mon Sep 17 00:00:00 2001 From: EiSiMo Date: Tue, 21 Apr 2026 13:48:46 +0200 Subject: [PATCH] map: fixed Berlin view, CartoDB Voyager tiles, OpenRailwayMap transit overlay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Drop the fitBounds-to-markers logic so the map always opens at the same Berlin-wide view (center 52.52/13.405, zoom 11), regardless of pin count - Swap OSM standard tiles for CartoDB Voyager — cleaner, more Google-Maps-like base style - Add OpenRailwayMap overlay (opacity .75) so S-/U-Bahn/Tram lines are highlighted on top of the base - CSP img-src widened to cover the new tile hosts Co-Authored-By: Claude Opus 4.7 (1M context) --- web/app.py | 6 +++++- web/static/map.js | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/web/app.py b/web/app.py index 4d4fc9e..495862a 100644 --- a/web/app.py +++ b/web/app.py @@ -134,7 +134,11 @@ async def security_headers(request: Request, call_next): "default-src 'self'; " "script-src 'self' https://cdn.tailwindcss.com https://unpkg.com; " "style-src 'self' https://cdn.tailwindcss.com https://unpkg.com 'unsafe-inline'; " - "img-src 'self' data: https://*.tile.openstreetmap.org https://tile.openstreetmap.org https://unpkg.com; " + "img-src 'self' data: " + "https://*.tile.openstreetmap.org https://tile.openstreetmap.org " + "https://*.basemaps.cartocdn.com https://basemaps.cartocdn.com " + "https://*.tiles.openrailwaymap.org https://tiles.openrailwaymap.org " + "https://unpkg.com; " "connect-src 'self'; frame-ancestors 'none';" ) return resp diff --git a/web/static/map.js b/web/static/map.js index 9f6ec13..4f7e85d 100644 --- a/web/static/map.js +++ b/web/static/map.js @@ -48,7 +48,6 @@ function renderMarkers(data) { markerLayer = L.layerGroup().addTo(mapInstance); } - const bounds = []; data.forEach((f) => { if (typeof f.lat !== "number" || typeof f.lng !== "number") return; const rent = f.rent ? Math.round(f.rent) + " €" : ""; @@ -61,14 +60,7 @@ function renderMarkers(data) { `${safeAddr}` + (meta ? `
${meta}` : "") + `
Zur Anzeige →`, ); - bounds.push([f.lat, f.lng]); }); - - if (bounds.length === 1) { - mapInstance.setView(bounds[0], 14); - } else if (bounds.length > 1) { - mapInstance.fitBounds(bounds, { padding: [30, 30] }); - } } function buildMap(el) { @@ -81,10 +73,18 @@ function buildMap(el) { touchZoom: false, keyboard: false, }).setView(BERLIN_CENTER, BERLIN_ZOOM); - L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { - attribution: "© OpenStreetMap", - maxZoom: 18, + // CartoDB Voyager — clean, Google-Maps-ish base style. + L.tileLayer("https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png", { + attribution: "© OpenStreetMap · © CARTO", + subdomains: "abcd", + maxZoom: 19, + }).addTo(mapInstance); + // Transit overlay — OpenRailwayMap highlights S-/U-/Tram-Linien. + L.tileLayer("https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png", { + attribution: "© OpenRailwayMap", subdomains: "abc", + maxZoom: 19, + opacity: 0.75, }).addTo(mapInstance); markerLayer = L.layerGroup().addTo(mapInstance); }