Fix typings for LiveAtlasTileLayer _tiles property

This commit is contained in:
James Lyne 2021-08-31 16:35:30 +01:00
parent 00483025cd
commit 0ae42a9409
3 changed files with 13 additions and 8 deletions

6
src/index.d.ts vendored
View File

@ -17,7 +17,7 @@
import {State} from "@/store";
import {DynmapUrlConfig} from "@/dynmap";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
import {Coords, DoneCallback, PathOptions, PointTuple, PolylineOptions} from "leaflet";
import {Coords, DoneCallback, InternalTiles, PathOptions, PointTuple, PolylineOptions} from "leaflet";
import {CoordinatesControlOptions} from "@/leaflet/control/CoordinatesControl";
import {ClockControlOptions} from "@/leaflet/control/ClockControl";
import {LogoControlOptions} from "@/leaflet/control/LogoControl";
@ -339,6 +339,10 @@ interface LiveAtlasChat {
timestamp: number;
}
export interface LiveAtlasInternalTiles extends InternalTiles {
[key: string]: LiveAtlasTile;
}
export interface LiveAtlasTile {
active?: boolean;
coords: Coords;

View File

@ -19,7 +19,7 @@
import {Coords, DoneCallback} from 'leaflet';
import {useStore} from "@/store";
import {Coordinate, LiveAtlasTile} from "@/index";
import {Coordinate} from "@/index";
import {LiveAtlasTileLayer, LiveAtlasTileLayerOptions} from "@/leaflet/tileLayer/LiveAtlasTileLayer";
import {computed, watch} from "@vue/runtime-core";
import {ComputedRef} from "@vue/reactivity";
@ -123,7 +123,7 @@ export class DynmapTileLayer extends LiveAtlasTileLayer {
continue;
}
tile = this._tiles[i] as LiveAtlasTile;
tile = this._tiles[i];
if (tile.coords.z !== this._tileZoom) {
if (tile.loaded && tile.el && tile.el.tileName) {
@ -136,7 +136,7 @@ export class DynmapTileLayer extends LiveAtlasTileLayer {
}
_removeTile(key: string) {
const tile = this._tiles[key] as LiveAtlasTile;
const tile = this._tiles[key];
if (!tile) {
return;

View File

@ -16,7 +16,7 @@
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
import {Coords, DomUtil, DoneCallback, TileLayer, TileLayerOptions, Util} from "leaflet";
import {LiveAtlasTile, LiveAtlasTileElement} from "@/index";
import {LiveAtlasInternalTiles, LiveAtlasTileElement} from "@/index";
import falseFn = Util.falseFn;
export interface LiveAtlasTileLayerOptions extends TileLayerOptions {
@ -27,6 +27,7 @@ export interface LiveAtlasTileLayerOptions extends TileLayerOptions {
// noinspection JSUnusedGlobalSymbols
export abstract class LiveAtlasTileLayer extends TileLayer {
declare options: LiveAtlasTileLayerOptions;
declare _tiles: LiveAtlasInternalTiles;
protected _mapSettings: LiveAtlasMapDefinition;
private readonly tileTemplate: LiveAtlasTileElement;
@ -150,7 +151,7 @@ export abstract class LiveAtlasTileLayer extends TileLayer {
continue;
}
const tile = this._tiles[i] as LiveAtlasTile;
const tile = this._tiles[i];
if(tile.loaded) {
this.loadQueue.push(tile.el);
@ -168,7 +169,7 @@ export abstract class LiveAtlasTileLayer extends TileLayer {
continue;
}
tile = this._tiles[i] as LiveAtlasTile;
tile = this._tiles[i];
if (tile.coords.z !== this._tileZoom) {
if (!tile.loaded && tile.el && tile.el.abortController) {
@ -187,7 +188,7 @@ export abstract class LiveAtlasTileLayer extends TileLayer {
}
_removeTile(key: string) {
const tile = this._tiles[key] as LiveAtlasTile;
const tile = this._tiles[key];
if (!tile) {
return;