From f55f70c0eb1ed6cc142e62c9bdbf67ad44d9339a Mon Sep 17 00:00:00 2001 From: Johannes Baumeister Date: Thu, 30 Apr 2026 09:00:29 +0200 Subject: [PATCH] Fix async map loading race condition and mapping logic --- app.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index 5d76c37..9ab7d1a 100644 --- a/app.js +++ b/app.js @@ -3,18 +3,18 @@ */ document.addEventListener('DOMContentLoaded', async () => { - // Basic App State const state = { map: null, config: null, turbines: [], activeVariant: 'A', bakedData: {}, // Cache for standalone persistence - ownerMapping: null, // { firstName: '', lastName: '' } + ownerMapping: { firstName: 'VNA', lastName: 'GNA' }, // Default for ALKIS ownerStatuses: {}, // { "Name Vorname": "status" } showAuxiliary: true }; + // Removed fetch for config to prevent CORS errors on file:// protocol console.log("Konfiguration geladen."); @@ -959,17 +959,21 @@ document.addEventListener('DOMContentLoaded', async () => { // Owner-Status-Coloring if (layerName.toLowerCase().includes('eigentümer') && state.ownerMapping) { const props = feature.properties; - const firstName = props[state.ownerMapping.firstName] || ''; - const lastName = props[state.ownerMapping.lastName] || ''; + // Fallback lookup case insensitive + const getProp = (key) => props[key] || props[key.toLowerCase()] || props[key.toUpperCase()] || ''; + const firstName = getProp(state.ownerMapping.firstName); + const lastName = getProp(state.ownerMapping.lastName); const ownerName = `${firstName} ${lastName}`.trim().toLowerCase(); - const status = state.ownerStatuses[ownerName]; - if (status === 'gbr') fillColor = '#2ecc71'; - if (status === 'external') fillColor = '#e74c3c'; - if (status === 'declined') fillColor = '#f1c40f'; - if (status === 'positive') fillColor = '#5efd9c'; - if (status === 'undecided') fillColor = '#95a5a6'; + const statusRaw = state.ownerStatuses[ownerName]; + const status = statusRaw ? statusRaw.toLowerCase() : ""; + if (status === 'gbr' || status === 'gesichert') fillColor = '#2ecc71'; + if (status === 'external' || status === 'fremdplanung') fillColor = '#e74c3c'; + if (status === 'declined' || status === 'ablehnend' || status === 'negative') fillColor = '#e74c3c'; + if (status === 'undecided' || status === 'unentschlossen') fillColor = '#95a5a6'; + if (status === 'positive' || status === 'positiv') fillColor = '#5efd9c'; + if (status === 'in verhandlung') fillColor = '#f1c40f'; return { color: '#000', weight: 1, fillOpacity: 0.7, fillColor: fillColor }; }