Fix async map loading race condition and mapping logic
Deploy Bürgerwind / deploy (push) Successful in 16s Details

This commit is contained in:
Johannes Baumeister 2026-04-30 09:00:29 +02:00
parent 74f2af9b21
commit f55f70c0eb
1 changed files with 14 additions and 10 deletions

24
app.js
View File

@ -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 };
}