diff --git a/app.js b/app.js index df0b62a..398ae4a 100644 --- a/app.js +++ b/app.js @@ -11,7 +11,8 @@ document.addEventListener('DOMContentLoaded', async () => { bakedData: {}, // Cache for standalone persistence ownerMapping: { firstName: 'vorname', lastName: 'nachname' }, // Default for ALKIS and modern Shapefiles ownerStatuses: {}, // { "name vorname": { status: "...", notiz: "..." } } - showAuxiliary: true + showAuxiliary: true, + isEditMode: false }; const STATUS_MAP = { @@ -383,7 +384,7 @@ document.addEventListener('DOMContentLoaded', async () => { ksfAngle, ksfMirrored, totalHeight: geoms.totalHeight, layers: { - marker: L.marker(latlng, { draggable: true, icon: turbineIcon }), + marker: L.marker(latlng, { draggable: state.isEditMode, icon: turbineIcon }), sweptArea: L.geoJSON(geoms.sweptArea, { style: { color: '#00c8ff', weight: 1, dashArray: '4, 4', fillOpacity: 0.1 } }), techDist: L.geoJSON(geoms.techDist, { style: { color: '#ffcc00', weight: 2, dashArray: '5, 5', fillOpacity: 0 } }), techDistSmall: L.geoJSON(geoms.techDistSmall, { style: { color: '#ffcc00', weight: 1.5, dashArray: '2, 4', fillOpacity: 0 } }), @@ -393,7 +394,7 @@ document.addEventListener('DOMContentLoaded', async () => { blf: L.geoJSON(geoms.blf, { style: { color: '#9b59b6', weight: 1, dashArray: '3, 3', fillOpacity: 0.2 } }), mf: L.geoJSON(geoms.mf, { style: { color: '#95a5a6', weight: 1, dashArray: '2, 2', fillOpacity: 0.15 } }), rotationHandle: L.marker(latlng, { - draggable: true, + draggable: state.isEditMode, icon: L.divIcon({ className: 'rotation-handle', html: ` @@ -437,7 +438,9 @@ document.addEventListener('DOMContentLoaded', async () => { updateLabel(turbine, geoms); // Click to Edit - turbine.layers.marker.on('click', () => openEditPanel(turbine)); + turbine.layers.marker.on('click', () => { + if (state.isEditMode) openEditPanel(turbine); + }); // Drag Update turbine.layers.marker.on('drag', (e) => { @@ -633,6 +636,20 @@ document.addEventListener('DOMContentLoaded', async () => { }; } + const checkShowOwnersOutline = document.getElementById('checkShowOwnersOutline'); + if (checkShowOwnersOutline) { + checkShowOwnersOutline.onchange = () => { + const outlineLayer = overlays["Flurstücke & Eigentümer (Umriss)"]; + if (outlineLayer) { + if (checkShowOwnersOutline.checked) { + state.map.addLayer(outlineLayer); + } else { + state.map.removeLayer(outlineLayer); + } + } + }; + } + // UTM Creation Logic const btnCreateAtUTM = document.getElementById('btnCreateAtUTM'); const inputUtmE = document.getElementById('utm-e'); @@ -1207,6 +1224,59 @@ document.addEventListener('DOMContentLoaded', async () => { layerControl.addOverlay(layer, layerName); layer.bringToFront(); // Ensure it's on top of local shapefiles + + // ---- Erzeuge zusätzlich den Umriss-Layer ---- + const outlineLayerName = "Flurstücke & Eigentümer (Umriss)"; + const outlineLayer = L.geoJSON(geojson, { + style: () => ({ color: '#000', weight: 1.5, fillOpacity: 0, fillColor: 'transparent' }), + onEachFeature: (feature, outLayer) => { + if (feature.properties) { + const props = feature.properties; + const firstName = (props.vorname || props.VNA || '').trim(); + const lastName = (props.nachname || props.GNA || '').trim(); + + let rawStatus = props.status || 'Kein Status'; + let notiz = props.notiz || ''; + + const matched = getAlkisOwnerStatus(firstName, lastName, state); + if (matched) { + rawStatus = matched.status; + notiz = matched.notiz; + } + + const status = (rawStatus && LEGACY_STATUS_MAP[rawStatus.toLowerCase()]) ? LEGACY_STATUS_MAP[rawStatus.toLowerCase()] : (rawStatus || 'Kein Status'); + + const popup = generateAlkisPopup(props, firstName, lastName, status, notiz, outlineLayerName); + outLayer.bindPopup(popup); + + const flur = props.FLN || '-'; + let fst = '-'; + if (props.ZAE) { + fst = props.NEN ? `${props.ZAE}/${props.NEN}` : props.ZAE; + } + const labelContent = ` +
Bitte ordnen Sie die Spalten für Namen aus dem Layer "Eigentümer" zu: