fix: prevent ReferenceError and avoid loading local config layers for non-default projects to avoid wrong project startup zoom

This commit is contained in:
Johannes Baumeister 2026-06-25 09:58:56 +02:00
parent a92b054645
commit 330a7a5a0a
1 changed files with 8 additions and 4 deletions

12
app.js
View File

@ -1208,6 +1208,8 @@ document.addEventListener('DOMContentLoaded', async () => {
};
try {
const projId = getProjektId();
// Priority 1: Use globalThis.BAKED_DATA if available (Standalone Mode)
if (globalThis.BAKED_DATA) {
// Support both old format (direct layers) and new format (with mapping/statuses)
@ -1222,14 +1224,16 @@ document.addEventListener('DOMContentLoaded', async () => {
}
// Priority 2: Use globalThis.LAYER_CONFIG (Script-based config) or remote config
const layers = await resolveLayerConfig(isLocalFile, statusEl);
if (layers) {
await loadConfigLayers(layers);
// Only load local config layers if the project is the default (bwsamern-ohne)
if (projId.toLowerCase() === 'bwsamern-ohne') {
const layers = await resolveLayerConfig(isLocalFile, statusEl);
if (layers) {
await loadConfigLayers(layers);
}
}
// ALKIS aus Datenbank IMMER laden
console.log("Lade ALKIS-Layer aus Datenbank...");
const projId = getProjektId();
const alkisResp = await fetch(`/api/layers/alkis?project=${encodeURIComponent(projId)}`).catch(err => {
console.error("Netzwerkfehler beim Laden des ALKIS-Layers:", err);
return null;