diff --git a/BlueMapCommon/webapp/src/js/BlueMapApp.js b/BlueMapCommon/webapp/src/js/BlueMapApp.js index e4a206fc..75b233d9 100644 --- a/BlueMapCommon/webapp/src/js/BlueMapApp.js +++ b/BlueMapCommon/webapp/src/js/BlueMapApp.js @@ -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(); }); } diff --git a/BlueMapCommon/webapp/src/js/markers/MarkerManager.js b/BlueMapCommon/webapp/src/js/markers/MarkerManager.js index cbdd4ba5..e9dbb12b 100644 --- a/BlueMapCommon/webapp/src/js/markers/MarkerManager.js +++ b/BlueMapCommon/webapp/src/js/markers/MarkerManager.js @@ -83,7 +83,8 @@ export class MarkerManager { */ update() { return this.loadMarkerFile() - .then(markerFileData => this.updateFromData(markerFileData)); + .then(markerFileData => this.updateFromData(markerFileData)) + .catch(() => this.clear()); } /** diff --git a/BlueMapCommon/webapp/src/js/markers/MarkerSet.js b/BlueMapCommon/webapp/src/js/markers/MarkerSet.js index f3aecf8b..064d9e0b 100644 --- a/BlueMapCommon/webapp/src/js/markers/MarkerSet.js +++ b/BlueMapCommon/webapp/src/js/markers/MarkerSet.js @@ -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) { diff --git a/BlueMapCommon/webapp/src/js/markers/NormalMarkerManager.js b/BlueMapCommon/webapp/src/js/markers/NormalMarkerManager.js index d35721ac..a9d82167 100644 --- a/BlueMapCommon/webapp/src/js/markers/NormalMarkerManager.js +++ b/BlueMapCommon/webapp/src/js/markers/NormalMarkerManager.js @@ -48,4 +48,8 @@ export class NormalMarkerManager extends MarkerManager { return true; } + clear() { + this.root.updateMarkerSetsFromData({}, [PLAYER_MARKER_SET_ID, "bm-popup-set"]); + } + } \ No newline at end of file diff --git a/BlueMapCommon/webapp/src/js/markers/PlayerMarkerManager.js b/BlueMapCommon/webapp/src/js/markers/PlayerMarkerManager.js index 84dbcbd1..b114c8a4 100644 --- a/BlueMapCommon/webapp/src/js/markers/PlayerMarkerManager.js +++ b/BlueMapCommon/webapp/src/js/markers/PlayerMarkerManager.js @@ -78,4 +78,8 @@ export class PlayerMarkerManager extends MarkerManager { return this.getPlayerMarkerSet().getPlayerMarker(playerUuid) } + clear() { + this.getPlayerMarkerSet(false).clear(); + } + } \ No newline at end of file