From 552b289bb9d472fe75f1fa3419a8a78a7b84c37a Mon Sep 17 00:00:00 2001 From: James Lyne Date: Mon, 16 Aug 2021 03:33:28 +0100 Subject: [PATCH] Avoid recreating tiles from scratch when refreshing Pl3xmap --- src/components/map/layer/MapLayer.vue | 14 +++++++------- src/leaflet/tileLayer/LiveAtlasTileLayer.ts | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/components/map/layer/MapLayer.vue b/src/components/map/layer/MapLayer.vue index 2a70ae3..98d1266 100644 --- a/src/components/map/layer/MapLayer.vue +++ b/src/components/map/layer/MapLayer.vue @@ -43,15 +43,15 @@ export default defineComponent({ const store = useStore(), active = computed(() => props.map === store.state.currentMap); - let redrawTimeout = 0, + let refreshTimeout = 0, layer: LiveAtlasTileLayer; - const redraw = () => { + const refresh = () => { if(active.value) { - layer._update(); + layer.refresh(); } - redrawTimeout = setTimeout(redraw, props.map.tileUpdateInterval); + refreshTimeout = setTimeout(refresh, props.map.tileUpdateInterval); }; if(store.state.currentServer?.type === 'dynmap') { @@ -81,14 +81,14 @@ export default defineComponent({ } if(props.map.tileUpdateInterval) { - redrawTimeout = setTimeout(redraw, props.map.tileUpdateInterval); + refreshTimeout = setTimeout(refresh, props.map.tileUpdateInterval); } onUnmounted(() => { disableLayer(); - if(redrawTimeout) { - clearTimeout(redrawTimeout); + if(refreshTimeout) { + clearTimeout(refreshTimeout); } }); }, diff --git a/src/leaflet/tileLayer/LiveAtlasTileLayer.ts b/src/leaflet/tileLayer/LiveAtlasTileLayer.ts index 6a48b61..6e6caa7 100644 --- a/src/leaflet/tileLayer/LiveAtlasTileLayer.ts +++ b/src/leaflet/tileLayer/LiveAtlasTileLayer.ts @@ -144,6 +144,22 @@ export abstract class LiveAtlasTileLayer extends TileLayer { this.fetchTile(tile); } + refresh() { + for (const i in this._tiles) { + if (!Object.prototype.hasOwnProperty.call(this._tiles, i)) { + continue; + } + + const tile = this._tiles[i] as LiveAtlasTile; + + if(tile.loaded) { + this.loadQueue.push(tile.el); + } + } + + this.tickLoadQueue(); + } + _abortLoading() { let tile;