feat: resolve project ID from URL parameters and auto-zoom to project parcels
Deploy Standortplaner / deploy (push) Successful in 17s
Details
Deploy Standortplaner / deploy (push) Successful in 17s
Details
This commit is contained in:
parent
e3f51f59e0
commit
261b7a1bf3
33
app.js
33
app.js
|
|
@ -17,6 +17,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
hasLoadedFromDB: false
|
||||
};
|
||||
|
||||
const getProjektId = () => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
return urlParams.get('project') || urlParams.get('projekt') || urlParams.get('projekt_id') || "BWSamern-Ohne";
|
||||
};
|
||||
|
||||
const STATUS_MAP = {
|
||||
'Ablehnung': { color: '#ff0000', desc: 'Der Eigentümer lehnt das Vorhaben strikt ab.' },
|
||||
'Erwartet Negativ': { color: '#ffa500', desc: 'Erste Signale oder Tendenzen deuten auf eine Ablehnung hin.' },
|
||||
|
|
@ -1865,7 +1870,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
setTimeout(() => element.style.borderColor = '', 1500);
|
||||
}
|
||||
|
||||
const projekt_id = "BWSamern-Ohne";
|
||||
const projekt_id = getProjektId();
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/sicherung', {
|
||||
|
|
@ -1941,7 +1946,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
});
|
||||
|
||||
async function loadOwnerStatusesFromDB() {
|
||||
const projekt_id = "BWSamern-Ohne";
|
||||
const projekt_id = getProjektId();
|
||||
console.log("Lade Eigentümer-Status aus Datenbank...");
|
||||
try {
|
||||
const response = await fetch(`/api/sicherung/${projekt_id}`);
|
||||
|
|
@ -2009,6 +2014,26 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-zoom to project parcels
|
||||
if (ownerLayerName && overlays[ownerLayerName]) {
|
||||
const layer = overlays[ownerLayerName];
|
||||
const layers = layer.getLayers();
|
||||
const matchedLayers = layers.filter(l => {
|
||||
if (!l.feature?.properties) return false;
|
||||
const props = l.feature.properties;
|
||||
const firstName = (props.vorname || props.VNA || '').trim();
|
||||
const lastName = (props.nachname || props.GNA || '').trim();
|
||||
const matched = getAlkisOwnerStatus(firstName, lastName, state);
|
||||
return matched && matched.status && matched.status.toLowerCase() !== 'none';
|
||||
});
|
||||
|
||||
if (matchedLayers.length > 0) {
|
||||
const group = L.featureGroup(matchedLayers);
|
||||
state.map.fitBounds(group.getBounds());
|
||||
console.log(`Auto-Zoom auf ${matchedLayers.length} Flächen des Projekts ausgeführt.`);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Fehler bei der Initialisierung des Planungstools:", e);
|
||||
} finally {
|
||||
|
|
@ -2085,7 +2110,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
const statusEl = document.getElementById('statusInfo');
|
||||
if (statusEl) statusEl.innerText = "Speicherung läuft...";
|
||||
|
||||
const projekt_id = "BWSamern-Ohne";
|
||||
const projekt_id = getProjektId();
|
||||
const turbineData = state.turbines.map(t => ({
|
||||
nr: t.nr,
|
||||
variant: t.variant,
|
||||
|
|
@ -2122,7 +2147,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
|
||||
async function loadTurbinesFromDB() {
|
||||
const projekt_id = "BWSamern-Ohne";
|
||||
const projekt_id = getProjektId();
|
||||
const statusEl = document.getElementById('statusInfo');
|
||||
console.log(`Lade WEAs aus Datenbank für Projekt: ${projekt_id}...`);
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue