From 16d4edc7bfccb1203a0736c3777c3ff7327190e2 Mon Sep 17 00:00:00 2001 From: Claude Dev Date: Tue, 24 Mar 2026 13:32:47 +0100 Subject: [PATCH] Fix: Katastrophen-Summary nur aus ausgewaehlter Lage _findMonitorSummary prueft jetzt Globe._currentLageId. Ohne Lage-Auswahl: keine Monitor-Summary im Popup. _fetchMonitorContext nutzt die gewaehlte Lage-ID statt alle. --- static/js/layers/disasters.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/static/js/layers/disasters.js b/static/js/layers/disasters.js index f7e5c57..7286ffa 100644 --- a/static/js/layers/disasters.js +++ b/static/js/layers/disasters.js @@ -28,7 +28,8 @@ const DisastersLayer = { _fetchMonitorContext() { var self = this; - fetch('/api/monitor-feed') + var lageId = (typeof Globe !== 'undefined' && Globe._currentLageId) ? Globe._currentLageId : ''; + fetch('/api/monitor-feed' + (lageId ? '?incident_id=' + lageId : '')) .then(function(r) { return r.json(); }) .then(function(data) { self._monitorData = data; }) .catch(function() {}); @@ -36,21 +37,15 @@ const DisastersLayer = { _findMonitorSummary(lat, lon) { if (!this._monitorData || !this._monitorData.incidents) return null; - // Finde naechsten Monitor-Punkt und dessen Lage-Summary - var features = this._monitorData.features || []; - var best = null, bestDist = 999; - for (var i = 0; i < features.length; i++) { - var c = features[i].geometry.coordinates; - var d = Math.abs(c[1] - lat) + Math.abs(c[0] - lon); - if (d < bestDist) { bestDist = d; best = features[i]; } - } - if (!best || bestDist > 5) return null; - var incId = best.properties.incident_id; + // Nur die aktuell ausgewaehlte Lage verwenden + var selectedId = (typeof Globe !== 'undefined') ? Globe._currentLageId : null; + if (!selectedId) return null; var incidents = this._monitorData.incidents || []; + var incident = null; for (var j = 0; j < incidents.length; j++) { - if (incidents[j].id === incId && incidents[j].summary) return incidents[j]; + if (incidents[j].id === selectedId && incidents[j].summary) { incident = incidents[j]; break; } } - return null; + return incident; }, _buildMonitorHtml(incident) {