MapProvider changes
- Add populateMap method to allow reacting to the current map changes - populateWorld, startUpdates and stopUpdates are no longer abstract
This commit is contained in:
parent
3eb9446a5d
commit
50aba2dd7b
@ -149,7 +149,12 @@ export default defineComponent({
|
|||||||
deep: true
|
deep: true
|
||||||
},
|
},
|
||||||
currentMap(newValue, oldValue) {
|
currentMap(newValue, oldValue) {
|
||||||
if(this.leaflet && newValue) {
|
const store = useStore();
|
||||||
|
|
||||||
|
if(newValue) {
|
||||||
|
store.state.currentMapProvider!.populateMap(newValue);
|
||||||
|
|
||||||
|
if(this.leaflet) {
|
||||||
let viewTarget = this.scheduledView;
|
let viewTarget = this.scheduledView;
|
||||||
|
|
||||||
if(!viewTarget && oldValue) {
|
if(!viewTarget && oldValue) {
|
||||||
@ -166,6 +171,7 @@ export default defineComponent({
|
|||||||
this.setView(viewTarget);
|
this.setView(viewTarget);
|
||||||
this.scheduledView = null;
|
this.scheduledView = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
currentWorld(newValue, oldValue) {
|
currentWorld(newValue, oldValue) {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
3
src/index.d.ts
vendored
3
src/index.d.ts
vendored
@ -30,7 +30,7 @@ import {ClockControlOptions} from "@/leaflet/control/ClockControl";
|
|||||||
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
|
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
|
||||||
import {globalMessages, serverMessages} from "../messages";
|
import {globalMessages, serverMessages} from "../messages";
|
||||||
import {LiveAtlasMarkerType} from "@/util/markers";
|
import {LiveAtlasMarkerType} from "@/util/markers";
|
||||||
import {LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer";
|
import {LiveAtlasTileLayer, LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer";
|
||||||
|
|
||||||
declare module "*.png" {
|
declare module "*.png" {
|
||||||
const value: any;
|
const value: any;
|
||||||
@ -183,6 +183,7 @@ interface LiveAtlasParsedUrl {
|
|||||||
interface LiveAtlasMapProvider {
|
interface LiveAtlasMapProvider {
|
||||||
loadServerConfiguration(): Promise<void>;
|
loadServerConfiguration(): Promise<void>;
|
||||||
populateWorld(world: LiveAtlasWorldDefinition): Promise<void>;
|
populateWorld(world: LiveAtlasWorldDefinition): Promise<void>;
|
||||||
|
populateMap(map: LiveAtlasMapDefinition): Promise<void>;
|
||||||
startUpdates(): void;
|
startUpdates(): void;
|
||||||
stopUpdates(): void;
|
stopUpdates(): void;
|
||||||
createTileLayer(options: LiveAtlasTileLayerOptions): LiveAtlasTileLayer;
|
createTileLayer(options: LiveAtlasTileLayerOptions): LiveAtlasTileLayer;
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
HeadQueueEntry,
|
|
||||||
LiveAtlasMapProvider,
|
LiveAtlasMapProvider,
|
||||||
LiveAtlasWorldDefinition
|
LiveAtlasWorldDefinition
|
||||||
} from "@/index";
|
} from "@/index";
|
||||||
import {useStore} from "@/store";
|
import {useStore} from "@/store";
|
||||||
import {LiveAtlasTileLayer, LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer";
|
import {LiveAtlasTileLayer, LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer";
|
||||||
|
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
|
||||||
|
|
||||||
export default abstract class MapProvider implements LiveAtlasMapProvider {
|
export default abstract class MapProvider implements LiveAtlasMapProvider {
|
||||||
protected readonly store = useStore();
|
protected readonly store = useStore();
|
||||||
@ -31,15 +31,17 @@ export default abstract class MapProvider implements LiveAtlasMapProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract loadServerConfiguration(): Promise<void>;
|
abstract loadServerConfiguration(): Promise<void>;
|
||||||
abstract populateWorld(world: LiveAtlasWorldDefinition): Promise<void>;
|
|
||||||
abstract createTileLayer(options: LiveAtlasTileLayerOptions): LiveAtlasTileLayer;
|
abstract createTileLayer(options: LiveAtlasTileLayerOptions): LiveAtlasTileLayer;
|
||||||
|
|
||||||
abstract startUpdates(): void;
|
|
||||||
abstract stopUpdates(): void;
|
|
||||||
|
|
||||||
abstract getTilesUrl(): string;
|
abstract getTilesUrl(): string;
|
||||||
abstract getMarkerIconUrl(icon: string): string;
|
abstract getMarkerIconUrl(icon: string): string;
|
||||||
|
|
||||||
|
async populateWorld(world: LiveAtlasWorldDefinition): Promise<void> {}
|
||||||
|
async populateMap(map: LiveAtlasMapDefinition): Promise<void> {}
|
||||||
|
|
||||||
|
startUpdates(): void {}
|
||||||
|
stopUpdates(): void {}
|
||||||
|
|
||||||
sendChatMessage(message: string) {
|
sendChatMessage(message: string) {
|
||||||
throw new Error('Provider does not support chat');
|
throw new Error('Provider does not support chat');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user