Add callsign label clearing to map updates
Introduced clearCallsignLabels() to remove callsign labels when map data is refreshed or markers are removed. Ensures label state is reset and UI button appearance is updated, preventing stale labels from persisting after data changes.
这个提交包含在:
父节点
7fe4e7e663
当前提交
32259770a1
共有 2 个文件被更改,包括 34 次插入 和 4 次删除
|
|
@ -433,6 +433,28 @@ function toggleFullscreen() {
|
|||
let callsignLabelsVisible = false;
|
||||
let callsignLabels = [];
|
||||
|
||||
function clearCallsignLabels() {
|
||||
// Remove all existing callsign labels from the map
|
||||
callsignLabels.forEach(function(labelMarker) {
|
||||
if (map.hasLayer(labelMarker)) {
|
||||
map.removeLayer(labelMarker);
|
||||
}
|
||||
});
|
||||
|
||||
// Clear the labels array
|
||||
callsignLabels = [];
|
||||
|
||||
// Reset the visibility state
|
||||
callsignLabelsVisible = false;
|
||||
|
||||
// Reset button appearance
|
||||
const button = document.getElementById('callsign-labels-btn');
|
||||
if (button) {
|
||||
button.classList.remove('btn-success');
|
||||
button.classList.add('btn-outline-success');
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCallsignLabels() {
|
||||
const button = document.getElementById('callsign-labels-btn');
|
||||
|
||||
|
|
@ -518,11 +540,14 @@ function updateMapStatistics(plotjson) {
|
|||
}, 3000);
|
||||
}
|
||||
|
||||
// Handle callsign labels when new data is loaded
|
||||
const labelsWereVisible = callsignLabelsVisible;
|
||||
|
||||
// Clear any existing callsign labels before processing new data
|
||||
clearCallsignLabels();
|
||||
|
||||
// Reapply callsign labels if they were previously enabled
|
||||
if (callsignLabelsVisible) {
|
||||
// Reset state and toggle to reapply labels to new markers
|
||||
callsignLabelsVisible = false;
|
||||
callsignLabels = [];
|
||||
if (labelsWereVisible) {
|
||||
setTimeout(() => {
|
||||
toggleCallsignLabels();
|
||||
}, 100); // Small delay to ensure markers are fully rendered
|
||||
|
|
|
|||
|
|
@ -124,4 +124,9 @@ function removeMarkers() {
|
|||
map.removeLayer(plotlayers[i]);
|
||||
}
|
||||
plotlayers=[];
|
||||
|
||||
// Clear callsign labels if the function exists (for custom map page)
|
||||
if (typeof clearCallsignLabels === 'function') {
|
||||
clearCallsignLabels();
|
||||
}
|
||||
}
|
||||
正在加载…
在新工单中引用