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:
parent
0c58242ce7
commit
ceb2486f35
2 changed files with 16 additions and 12 deletions
|
|
@ -134,7 +134,11 @@ async def security_headers(request: Request, call_next):
|
||||||
"default-src 'self'; "
|
"default-src 'self'; "
|
||||||
"script-src 'self' https://cdn.tailwindcss.com https://unpkg.com; "
|
"script-src 'self' https://cdn.tailwindcss.com https://unpkg.com; "
|
||||||
"style-src 'self' https://cdn.tailwindcss.com https://unpkg.com 'unsafe-inline'; "
|
"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';"
|
"connect-src 'self'; frame-ancestors 'none';"
|
||||||
)
|
)
|
||||||
return resp
|
return resp
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ function renderMarkers(data) {
|
||||||
markerLayer = L.layerGroup().addTo(mapInstance);
|
markerLayer = L.layerGroup().addTo(mapInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bounds = [];
|
|
||||||
data.forEach((f) => {
|
data.forEach((f) => {
|
||||||
if (typeof f.lat !== "number" || typeof f.lng !== "number") return;
|
if (typeof f.lat !== "number" || typeof f.lng !== "number") return;
|
||||||
const rent = f.rent ? Math.round(f.rent) + " €" : "";
|
const rent = f.rent ? Math.round(f.rent) + " €" : "";
|
||||||
|
|
@ -61,14 +60,7 @@ function renderMarkers(data) {
|
||||||
`<b>${safeAddr}</b>` + (meta ? `<br>${meta}` : "") +
|
`<b>${safeAddr}</b>` + (meta ? `<br>${meta}` : "") +
|
||||||
`<br><a href="${safeLink}" target="_blank" rel="noopener">Zur Anzeige →</a>`,
|
`<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) {
|
function buildMap(el) {
|
||||||
|
|
@ -81,10 +73,18 @@ function buildMap(el) {
|
||||||
touchZoom: false,
|
touchZoom: false,
|
||||||
keyboard: false,
|
keyboard: false,
|
||||||
}).setView(BERLIN_CENTER, BERLIN_ZOOM);
|
}).setView(BERLIN_CENTER, BERLIN_ZOOM);
|
||||||
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
// CartoDB Voyager — clean, Google-Maps-ish base style.
|
||||||
attribution: "© OpenStreetMap",
|
L.tileLayer("https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png", {
|
||||||
maxZoom: 18,
|
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",
|
subdomains: "abc",
|
||||||
|
maxZoom: 19,
|
||||||
|
opacity: 0.75,
|
||||||
}).addTo(mapInstance);
|
}).addTo(mapInstance);
|
||||||
markerLayer = L.layerGroup().addTo(mapInstance);
|
markerLayer = L.layerGroup().addTo(mapInstance);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue