From e7945b3f9a579fee39ae14727acbb450807689d4 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Sun, 25 Jul 2021 01:36:47 +0100 Subject: [PATCH] Add fields to DynmapTileLayer --- src/leaflet/tileLayer/DynmapTileLayer.ts | 29 ++++++++---------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/leaflet/tileLayer/DynmapTileLayer.ts b/src/leaflet/tileLayer/DynmapTileLayer.ts index 01fa50b..6c9bf07 100644 --- a/src/leaflet/tileLayer/DynmapTileLayer.ts +++ b/src/leaflet/tileLayer/DynmapTileLayer.ts @@ -17,7 +17,7 @@ * limitations under the License. */ -import {TileLayer, Coords, DoneCallback, TileLayerOptions, DomUtil, Util, LatLng} from 'leaflet'; +import {TileLayer, Coords, DoneCallback, TileLayerOptions, DomUtil, Util} from 'leaflet'; import {store} from "@/store"; import {Coordinate} from "@/index"; import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; @@ -28,20 +28,6 @@ export interface DynmapTileLayerOptions extends TileLayerOptions { night?: boolean; } -export interface DynmapTileLayer extends TileLayer { - options: DynmapTileLayerOptions; - _mapSettings: LiveAtlasMapDefinition; - _cachedTileUrls: Map; - _namedTiles: Map; - _tileTemplate: DynmapTileElement; - _loadQueue: DynmapTileElement[]; - _loadingTiles: Set; - - locationToLatLng(location: Coordinate): LatLng; - - latLngToLocation(latLng: LatLng): Coordinate; -} - export interface DynmapTile { active?: boolean; coords: Coords; @@ -70,6 +56,14 @@ export interface TileInfo { // noinspection JSUnusedGlobalSymbols export class DynmapTileLayer extends TileLayer { + private readonly _mapSettings: LiveAtlasMapDefinition; + private readonly _cachedTileUrls: Map = Object.seal(new Map()); + private readonly _namedTiles: Map = Object.seal(new Map()); + private readonly _loadQueue: DynmapTileElement[] = []; + private readonly _loadingTiles: Set = Object.seal(new Set()); + private readonly _tileTemplate: DynmapTileElement; + declare readonly options: DynmapTileLayerOptions; + constructor(options: DynmapTileLayerOptions) { super('', options); @@ -86,11 +80,6 @@ export class DynmapTileLayer extends TileLayer { throw new TypeError("mapSettings missing"); } - this._cachedTileUrls = Object.seal(new Map()); - this._namedTiles = Object.seal(new Map()); - this._loadQueue = []; - this._loadingTiles = Object.seal(new Set()); - this._tileTemplate = DomUtil.create('img', 'leaflet-tile') as DynmapTileElement; this._tileTemplate.style.width = this._tileTemplate.style.height = this.options.tileSize + 'px'; this._tileTemplate.alt = '';