mirror of
https://github.com/BlueMap-Minecraft/BlueMapWeb.git
synced 2024-11-16 07:05:12 +01:00
Improve marker updating and fix an error when loading empty tiles
This commit is contained in:
parent
89694564e0
commit
4e81bb4abd
@ -61,7 +61,10 @@ export class TileLoader {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.fileLoader.load(tileUrl + '?' + this.tileCacheHash,
|
||||
geometryJson => {
|
||||
if (!geometryJson.type || geometryJson.type !== 'BufferGeometry') reject({status: "empty"});
|
||||
if (!geometryJson.type || geometryJson.type !== 'BufferGeometry'){
|
||||
reject({status: "empty"});
|
||||
return;
|
||||
}
|
||||
|
||||
let geometry = this.bufferGeometryLoader.parse(geometryJson);
|
||||
|
||||
|
@ -52,7 +52,7 @@ export class MarkerFileManager extends MarkerManager {
|
||||
}
|
||||
|
||||
updateFromData(markerData) {
|
||||
if (!Array.isArray(markerData.markerSets)) return;
|
||||
if (!Array.isArray(markerData.markerSets)) return false;
|
||||
let updatedMarkerSets = new Set();
|
||||
|
||||
// add & update
|
||||
@ -71,6 +71,8 @@ export class MarkerFileManager extends MarkerManager {
|
||||
this.removeMarkerSet(setId);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,8 +63,12 @@ export class MarkerManager {
|
||||
if (ms > 0) {
|
||||
let autoUpdate = () => {
|
||||
this.update()
|
||||
.then(() => {
|
||||
this._updateInterval = setTimeout(autoUpdate, ms);
|
||||
.then(success => {
|
||||
if (success) {
|
||||
this._updateInterval = setTimeout(autoUpdate, ms);
|
||||
} else {
|
||||
this._updateInterval = setTimeout(autoUpdate, Math.max(ms, 1000 * 15));
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
alert(this.events, e, "warning");
|
||||
@ -158,8 +162,11 @@ export class MarkerManager {
|
||||
/**
|
||||
* Updates all managed markers using the provided data.
|
||||
* @param markerData {object} - The data object, usually parsed json from a markers.json
|
||||
* @returns {boolean} - If the update was successful
|
||||
*/
|
||||
updateFromData(markerData) {}
|
||||
updateFromData(markerData) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
@ -50,20 +50,23 @@ export class PlayerMarkerManager extends MarkerManager {
|
||||
*/
|
||||
updateFromData(markerData) {
|
||||
|
||||
if (!Array.isArray(markerData.players)) {
|
||||
this.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @type Set<Marker> */
|
||||
let updatedPlayerMarkers = new Set();
|
||||
|
||||
// update
|
||||
if (Array.isArray(markerData.players)) {
|
||||
markerData.players.forEach(playerData => {
|
||||
try {
|
||||
let playerMarker = this.updatePlayerMarkerFromData(playerData);
|
||||
updatedPlayerMarkers.add(playerMarker);
|
||||
} catch (err) {
|
||||
alert(this.events, err, "fine");
|
||||
}
|
||||
});
|
||||
}
|
||||
markerData.players.forEach(playerData => {
|
||||
try {
|
||||
let playerMarker = this.updatePlayerMarkerFromData(playerData);
|
||||
updatedPlayerMarkers.add(playerMarker);
|
||||
} catch (err) {
|
||||
alert(this.events, err, "fine");
|
||||
}
|
||||
});
|
||||
|
||||
// remove
|
||||
this.markers.forEach((playerMarker, markerId) => {
|
||||
@ -72,6 +75,7 @@ export class PlayerMarkerManager extends MarkerManager {
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user