diff --git a/app.js b/app.js index 398ae4a..e0a7d14 100644 --- a/app.js +++ b/app.js @@ -384,7 +384,7 @@ document.addEventListener('DOMContentLoaded', async () => { ksfAngle, ksfMirrored, totalHeight: geoms.totalHeight, layers: { - marker: L.marker(latlng, { draggable: state.isEditMode, icon: turbineIcon }), + marker: L.marker(latlng, { draggable: true, 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 } }), @@ -394,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: state.isEditMode, + draggable: true, icon: L.divIcon({ className: 'rotation-handle', html: ` @@ -496,6 +496,13 @@ document.addEventListener('DOMContentLoaded', async () => { turbine.layers.rotationHandle.on('dragend', triggerAutoSave); + turbine.layers.marker.on('add', function() { + if (!state.isEditMode && this.dragging) this.dragging.disable(); + }); + turbine.layers.rotationHandle.on('add', function() { + if (!state.isEditMode && this.dragging) this.dragging.disable(); + }); + state.turbines.push(turbine); updateProximityLines(); triggerAutoSave(); @@ -1227,7 +1234,9 @@ document.addEventListener('DOMContentLoaded', async () => { // ---- Erzeuge zusätzlich den Umriss-Layer ---- const outlineLayerName = "Flurstücke & Eigentümer (Umriss)"; - const outlineLayer = L.geoJSON(geojson, { + // Clone the geojson to prevent any Leaflet reference conflicts + const outlineGeojson = JSON.parse(JSON.stringify(geojson)); + const outlineLayer = L.geoJSON(outlineGeojson, { style: () => ({ color: '#000', weight: 1.5, fillOpacity: 0, fillColor: 'transparent' }), onEachFeature: (feature, outLayer) => { if (feature.properties) { @@ -1276,7 +1285,9 @@ document.addEventListener('DOMContentLoaded', async () => { state.map.addLayer(outlineLayer); } layerControl.addOverlay(outlineLayer, outlineLayerName); - outlineLayer.bringToFront(); + if (state.map.hasLayer(outlineLayer)) { + outlineLayer.bringToFront(); + } } // Manual Import & Bundling