From 334b316d52f3118dccaf82d4d5ba6fd0f96007a1 Mon Sep 17 00:00:00 2001 From: NiclasNorin Date: Thu, 6 Mar 2025 15:46:50 +0100 Subject: [PATCH] feat: adding methods to tileLayer --- js/features/createTileLayer/tileLayer.ts | 9 +++++++++ js/features/createTileLayer/tileLayerInterface.ts | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/js/features/createTileLayer/tileLayer.ts b/js/features/createTileLayer/tileLayer.ts index b7c8983..2affe64 100644 --- a/js/features/createTileLayer/tileLayer.ts +++ b/js/features/createTileLayer/tileLayer.ts @@ -15,6 +15,15 @@ export class TileLayer implements TileLayerInterface { this.getAttribution().addTo(this.mapInstance.getMap()); } + public removeTileLayer(): void { + this.getTileLayer().remove(); + this.getAttribution().remove(); + } + + public setUrl(url: string): void { + this.getTileLayer().setUrl(url); + } + private getAttribution(): L.Control.Attribution { return this.attribution; } diff --git a/js/features/createTileLayer/tileLayerInterface.ts b/js/features/createTileLayer/tileLayerInterface.ts index f6401d8..5fdd377 100644 --- a/js/features/createTileLayer/tileLayerInterface.ts +++ b/js/features/createTileLayer/tileLayerInterface.ts @@ -1,5 +1,6 @@ import { AddTo } from "../../addToInterface"; export interface TileLayerInterface extends AddTo { - + setUrl(url: string): void; + removeTileLayer(): void; } \ No newline at end of file