diff --git a/src/components/Map.vue b/src/components/Map.vue index 547f0bf..be7aa1f 100644 --- a/src/components/Map.vue +++ b/src/components/Map.vue @@ -149,22 +149,28 @@ export default defineComponent({ deep: true }, currentMap(newValue, oldValue) { - if(this.leaflet && newValue) { - let viewTarget = this.scheduledView; + const store = useStore(); - if(!viewTarget && oldValue) { - viewTarget = {location: oldValue.latLngToLocation(this.leaflet.getCenter(), 64) as LiveAtlasLocation}; - } else if(!viewTarget) { - viewTarget = {location: {x: 0, y: 0, z: 0} as LiveAtlasLocation}; + if(newValue) { + store.state.currentMapProvider!.populateMap(newValue); + + if(this.leaflet) { + let viewTarget = this.scheduledView; + + if(!viewTarget && oldValue) { + viewTarget = {location: oldValue.latLngToLocation(this.leaflet.getCenter(), 64) as LiveAtlasLocation}; + } else if(!viewTarget) { + viewTarget = {location: {x: 0, y: 0, z: 0} as LiveAtlasLocation}; + } + + viewTarget.options = { + animate: false, + noMoveStart: false, + } + + this.setView(viewTarget); + this.scheduledView = null; } - - viewTarget.options = { - animate: false, - noMoveStart: false, - } - - this.setView(viewTarget); - this.scheduledView = null; } }, currentWorld(newValue, oldValue) { diff --git a/src/index.d.ts b/src/index.d.ts index 297fde3..f35b241 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -30,7 +30,7 @@ import {ClockControlOptions} from "@/leaflet/control/ClockControl"; import {LogoControlOptions} from "@/leaflet/control/LogoControl"; import {globalMessages, serverMessages} from "../messages"; import {LiveAtlasMarkerType} from "@/util/markers"; -import {LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer"; +import {LiveAtlasTileLayer, LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer"; declare module "*.png" { const value: any; @@ -183,6 +183,7 @@ interface LiveAtlasParsedUrl { interface LiveAtlasMapProvider { loadServerConfiguration(): Promise; populateWorld(world: LiveAtlasWorldDefinition): Promise; + populateMap(map: LiveAtlasMapDefinition): Promise; startUpdates(): void; stopUpdates(): void; createTileLayer(options: LiveAtlasTileLayerOptions): LiveAtlasTileLayer; diff --git a/src/providers/MapProvider.ts b/src/providers/MapProvider.ts index a81a681..2a8b0a4 100644 --- a/src/providers/MapProvider.ts +++ b/src/providers/MapProvider.ts @@ -15,12 +15,12 @@ */ import { - HeadQueueEntry, LiveAtlasMapProvider, LiveAtlasWorldDefinition } from "@/index"; import {useStore} from "@/store"; import {LiveAtlasTileLayer, LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer"; +import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; export default abstract class MapProvider implements LiveAtlasMapProvider { protected readonly store = useStore(); @@ -31,15 +31,17 @@ export default abstract class MapProvider implements LiveAtlasMapProvider { } abstract loadServerConfiguration(): Promise; - abstract populateWorld(world: LiveAtlasWorldDefinition): Promise; abstract createTileLayer(options: LiveAtlasTileLayerOptions): LiveAtlasTileLayer; - abstract startUpdates(): void; - abstract stopUpdates(): void; - abstract getTilesUrl(): string; abstract getMarkerIconUrl(icon: string): string; + async populateWorld(world: LiveAtlasWorldDefinition): Promise {} + async populateMap(map: LiveAtlasMapDefinition): Promise {} + + startUpdates(): void {} + stopUpdates(): void {} + sendChatMessage(message: string) { throw new Error('Provider does not support chat'); }