Fix clear() method not actually clearing the markerset. Fixes: #430

This commit is contained in:
Lukas Rieger (Blue) 2023-06-17 13:33:42 +02:00
parent e46efc4c53
commit 55fb955ed7
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
5 changed files with 17 additions and 11 deletions

View File

@ -251,6 +251,9 @@ export class BlueMapApp {
let map = this.mapsMap.get(mapId);
if (!map) return Promise.reject(`There is no map with the id "${mapId}" loaded!`);
if (this.playerMarkerManager) this.playerMarkerManager.dispose();
if (this.markerFileManager) this.markerFileManager.dispose();
await this.mapViewer.switchMap(map)
if (resetCamera) this.resetCamera();
@ -353,10 +356,8 @@ export class BlueMapApp {
}
initPlayerMarkerManager() {
if (this.playerMarkerManager){
this.playerMarkerManager.clear();
if (this.playerMarkerManager)
this.playerMarkerManager.dispose()
}
const map = this.mapViewer.map;
if (!map) return;
@ -369,16 +370,13 @@ export class BlueMapApp {
})
.catch(e => {
alert(this.events, e, "warning");
this.playerMarkerManager.clear();
this.playerMarkerManager.dispose();
});
}
initMarkerFileManager() {
if (this.markerFileManager) {
this.markerFileManager.clear();
if (this.markerFileManager)
this.markerFileManager.dispose();
}
const map = this.mapViewer.map;
if (!map) return;
@ -390,7 +388,6 @@ export class BlueMapApp {
})
.catch(e => {
alert(this.events, e, "warning");
this.markerFileManager.clear();
this.markerFileManager.dispose();
});
}

View File

@ -83,7 +83,8 @@ export class MarkerManager {
*/
update() {
return this.loadMarkerFile()
.then(markerFileData => this.updateFromData(markerFileData));
.then(markerFileData => this.updateFromData(markerFileData))
.catch(() => this.clear());
}
/**

View File

@ -174,8 +174,8 @@ export class MarkerSet extends Scene {
* Removes all markers and marker-sets
*/
clear() {
[...this.data.markerSets].forEach(markerSet => this.remove(markerSet));
[...this.data.markers].forEach(marker => this.remove(marker));
[...this.markerSets.values()].forEach(markerSet => this.remove(markerSet));
[...this.markers.values()].forEach(marker => this.remove(marker));
}
add(...object) {

View File

@ -48,4 +48,8 @@ export class NormalMarkerManager extends MarkerManager {
return true;
}
clear() {
this.root.updateMarkerSetsFromData({}, [PLAYER_MARKER_SET_ID, "bm-popup-set"]);
}
}

View File

@ -78,4 +78,8 @@ export class PlayerMarkerManager extends MarkerManager {
return this.getPlayerMarkerSet().getPlayerMarker(playerUuid)
}
clear() {
this.getPlayerMarkerSet(false).clear();
}
}