fix: improve RF path line cleanup to prevent persistent lines
- Add clearRfPathLines() method for centralized cleanup logic - Clear RF paths when clearing all markers - Clear RF paths in destroyed() lifecycle hook - Add error handling to prevent failures during cleanup - Fix issue where path lines could persist after hover ends
This commit is contained in:
parent
db456f84a6
commit
537ddec4d6
1 changed files with 23 additions and 8 deletions
|
|
@ -1214,14 +1214,7 @@ let MapAPRSMap = {
|
||||||
|
|
||||||
// Handle clearing RF path lines
|
// Handle clearing RF path lines
|
||||||
self.handleEvent("clear_rf_path", () => {
|
self.handleEvent("clear_rf_path", () => {
|
||||||
if (self.rfPathLines) {
|
self.clearRfPathLines();
|
||||||
self.rfPathLines.forEach((line) => {
|
|
||||||
if (self.map && self.map.hasLayer(line)) {
|
|
||||||
self.map.removeLayer(line);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
self.rfPathLines = [];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle bounds-based marker filtering
|
// Handle bounds-based marker filtering
|
||||||
|
|
@ -1651,6 +1644,9 @@ let MapAPRSMap = {
|
||||||
|
|
||||||
clearAllMarkers() {
|
clearAllMarkers() {
|
||||||
const self = this as unknown as LiveViewHookContext;
|
const self = this as unknown as LiveViewHookContext;
|
||||||
|
|
||||||
|
// Clear any RF path lines first
|
||||||
|
self.clearRfPathLines();
|
||||||
|
|
||||||
// Instead of clearing all markers, only remove non-historical and non-current markers
|
// Instead of clearing all markers, only remove non-historical and non-current markers
|
||||||
const markersToPreserve = new Map();
|
const markersToPreserve = new Map();
|
||||||
|
|
@ -1743,6 +1739,22 @@ let MapAPRSMap = {
|
||||||
markersToRemove.forEach((id) => self.removeMarkerWithoutTrail(String(id)));
|
markersToRemove.forEach((id) => self.removeMarkerWithoutTrail(String(id)));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearRfPathLines() {
|
||||||
|
const self = this as unknown as LiveViewHookContext;
|
||||||
|
if (self.rfPathLines && self.rfPathLines.length > 0) {
|
||||||
|
self.rfPathLines.forEach((line) => {
|
||||||
|
try {
|
||||||
|
if (self.map && self.map.hasLayer(line)) {
|
||||||
|
self.map.removeLayer(line);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.debug("Error removing RF path line:", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
self.rfPathLines = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
removeMarkerWithoutTrail(id: string) {
|
removeMarkerWithoutTrail(id: string) {
|
||||||
const self = this as unknown as LiveViewHookContext;
|
const self = this as unknown as LiveViewHookContext;
|
||||||
// Ensure id is a string
|
// Ensure id is a string
|
||||||
|
|
@ -1935,6 +1947,9 @@ let MapAPRSMap = {
|
||||||
self.mapEventHandlers.clear();
|
self.mapEventHandlers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear any RF path lines
|
||||||
|
self.clearRfPathLines();
|
||||||
|
|
||||||
// Remove all event listeners from markers before clearing layers
|
// Remove all event listeners from markers before clearing layers
|
||||||
if (self.markers !== undefined) {
|
if (self.markers !== undefined) {
|
||||||
self.markers.forEach((marker: APRSMarker) => {
|
self.markers.forEach((marker: APRSMarker) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue