diff --git a/app.js b/app.js
index 8520e25..a91ffb3 100644
--- a/app.js
+++ b/app.js
@@ -1241,25 +1241,40 @@ document.addEventListener('DOMContentLoaded', async () => {
}
async function processALKISData(geojson, layerName) {
+ console.log(`Verarbeite ALKIS-Daten für Layer: ${layerName}. Features: ${geojson.features ? geojson.features.length : 0}`);
+
const layer = L.geoJSON(geojson, {
style: (feature) => {
const props = feature.properties;
const firstName = (props.VNA || '').trim();
const lastName = (props.GNA || '').trim();
- const ownerName = `${firstName} ${lastName}`.trim().toLowerCase();
- const stored = state.ownerStatuses[ownerName];
- const status = typeof stored === 'object' ? (stored.status || '') : (stored || props.status || '');
+ // Normalisierung des Namens für den Abgleich
+ const normalize = (s) => (s || '').toString().toLowerCase().replace(/[\s,.-]/g, '').trim();
+ const ownerKey = normalize(firstName + lastName);
+
+ // Suche in den geladenen Status-Einträgen
+ let status = '';
+ let foundInState = false;
+
+ // Wir suchen im state.ownerStatuses (der aus /api/sicherung geladen wurde)
+ for (let key in state.ownerStatuses) {
+ if (normalize(key) === ownerKey) {
+ status = state.ownerStatuses[key].status;
+ foundInState = true;
+ break;
+ }
+ }
+
+ // Fallback auf die Properties im GeoJSON selbst
+ if (!status) status = props.status || '';
let fillColor = 'transparent';
let opacity = 0.1;
- if (STATUS_MAP[status]) {
+ if (status && STATUS_MAP[status]) {
fillColor = STATUS_MAP[status].color;
opacity = 0.7;
- } else if (status === 'none' || status === '') {
- fillColor = 'transparent';
- opacity = 0.1;
}
return {
@@ -1271,16 +1286,31 @@ document.addEventListener('DOMContentLoaded', async () => {
},
onEachFeature: (feature, layer) => {
if (feature.properties) {
- const status = feature.properties.status || 'Kein Status';
- const notiz = feature.properties.notiz || '';
+ const props = feature.properties;
+ const firstName = (props.VNA || '').trim();
+ const lastName = (props.GNA || '').trim();
+ const normalize = (s) => (s || '').toString().toLowerCase().replace(/[\s,.-]/g, '').trim();
+ const ownerKey = normalize(firstName + lastName);
+
+ let status = props.status || 'Kein Status';
+ let notiz = props.notiz || '';
+
+ for (let key in state.ownerStatuses) {
+ if (normalize(key) === ownerKey) {
+ status = state.ownerStatuses[key].status;
+ notiz = state.ownerStatuses[key].notiz;
+ break;
+ }
+ }
+
let popup = `${layerName}