map: fixed Berlin view, CartoDB Voyager tiles, OpenRailwayMap transit overlay

- 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) <noreply@anthropic.com>
This commit is contained in:
EiSiMo 2026-04-21 13:48:46 +02:00
parent 0c58242ce7
commit ceb2486f35
2 changed files with 16 additions and 12 deletions

View file

@ -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) {
`<b>${safeAddr}</b>` + (meta ? `<br>${meta}` : "") +
`<br><a href="${safeLink}" target="_blank" rel="noopener">Zur Anzeige →</a>`,
);
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);
}