diff --git a/src/components/map/layer/MapLayer.vue b/src/components/map/layer/MapLayer.vue index d1e227d..2a70ae3 100644 --- a/src/components/map/layer/MapLayer.vue +++ b/src/components/map/layer/MapLayer.vue @@ -43,7 +43,16 @@ export default defineComponent({ const store = useStore(), active = computed(() => props.map === store.state.currentMap); - let layer: LiveAtlasTileLayer; + let redrawTimeout = 0, + layer: LiveAtlasTileLayer; + + const redraw = () => { + if(active.value) { + layer._update(); + } + + redrawTimeout = setTimeout(redraw, props.map.tileUpdateInterval); + }; if(store.state.currentServer?.type === 'dynmap') { layer = new DynmapTileLayer({ @@ -71,8 +80,16 @@ export default defineComponent({ enableLayer(); } + if(props.map.tileUpdateInterval) { + redrawTimeout = setTimeout(redraw, props.map.tileUpdateInterval); + } + onUnmounted(() => { disableLayer(); + + if(redrawTimeout) { + clearTimeout(redrawTimeout); + } }); }, diff --git a/src/model/LiveAtlasMapDefinition.ts b/src/model/LiveAtlasMapDefinition.ts index bfbc948..8d32a81 100644 --- a/src/model/LiveAtlasMapDefinition.ts +++ b/src/model/LiveAtlasMapDefinition.ts @@ -34,6 +34,7 @@ export interface LiveAtlasMapDefinitionOptions { worldToMap?: [number, number, number, number, number, number, number, number, number]; nativeZoomLevels: number; extraZoomLevels: number; + tileUpdateInterval?: number; } export default class LiveAtlasMapDefinition { @@ -52,6 +53,7 @@ export default class LiveAtlasMapDefinition { readonly nativeZoomLevels: number; readonly extraZoomLevels: number; readonly scale: number; + readonly tileUpdateInterval?: number; constructor(options: LiveAtlasMapDefinitionOptions) { this.world = options.world; //Ignore append_to_world here otherwise things break @@ -71,6 +73,7 @@ export default class LiveAtlasMapDefinition { this.nativeZoomLevels = options.nativeZoomLevels || 1; this.extraZoomLevels = options.extraZoomLevels || 0; this.scale = (1 / Math.pow(2, this.nativeZoomLevels)); + this.tileUpdateInterval = options.tileUpdateInterval || undefined; if(options.mapToWorld || options.worldToMap) { this.projection = new LiveAtlasProjection({ diff --git a/src/providers/Pl3xmapMapProvider.ts b/src/providers/Pl3xmapMapProvider.ts index ceba348..b8c1609 100644 --- a/src/providers/Pl3xmapMapProvider.ts +++ b/src/providers/Pl3xmapMapProvider.ts @@ -127,6 +127,7 @@ export default class Pl3xmapMapProvider extends MapProvider { nativeZoomLevels: worldResponse.zoom.max || 1, extraZoomLevels: worldResponse.zoom.extra || 0, + tileUpdateInterval: worldResponse.tiles_update_interval ? worldResponse.tiles_update_interval * 1000 : undefined, }))); worlds.push({