From fc6bf82ffba648ff3d8e8de570d7f8646dc0de0b Mon Sep 17 00:00:00 2001 From: panayot-nenov <32521582+panayot-nenov@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:17:00 +0100 Subject: [PATCH] fix: WMTSLayer attributions property (#279) --- .changeset/little-onions-rescue.md | 5 +++++ src/packages/map/api/layers/WMTSLayer.ts | 13 ++++++++----- src/packages/map/model/layers/WMTSLayerImpl.ts | 9 ++++----- 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 .changeset/little-onions-rescue.md diff --git a/.changeset/little-onions-rescue.md b/.changeset/little-onions-rescue.md new file mode 100644 index 00000000..cf725f76 --- /dev/null +++ b/.changeset/little-onions-rescue.md @@ -0,0 +1,5 @@ +--- +"@open-pioneer/map": patch +--- + +introduce sourceOptions parameter to WMTS layer diff --git a/src/packages/map/api/layers/WMTSLayer.ts b/src/packages/map/api/layers/WMTSLayer.ts index bb580aab..0a11a1a4 100644 --- a/src/packages/map/api/layers/WMTSLayer.ts +++ b/src/packages/map/api/layers/WMTSLayer.ts @@ -1,5 +1,6 @@ // SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer) // SPDX-License-Identifier: Apache-2.0 +import type { Options as WMSSourceOptions } from "ol/source/ImageWMS"; import { Layer, LayerConfig } from "./base"; import { WMTSLayerImpl } from "../../model/layers/WMTSLayerImpl"; export interface WMTSLayerConfig extends LayerConfig { @@ -12,8 +13,13 @@ export interface WMTSLayerConfig extends LayerConfig { /** The name of the tile matrix set in the service's capabilities. */ matrixSet: string; - /**Optional license note or source references*/ - attributions?: string; + /** + * Additional source options for the layer's WMTS source. + * + * NOTE: These options are intended for advanced configuration: + * the WMTS Layer manages some of the OpenLayers source options itself. + */ + sourceOptions?: Partial; } export interface WMTSLayer extends Layer { /** URL of the WMTS service. */ @@ -24,9 +30,6 @@ export interface WMTSLayer extends Layer { /** The name of the tile matrix set in the service's capabilities. */ readonly matrixSet: string; - - /**Optional license note or source references*/ - readonly attributions?: string; } export interface WMTSLayerConstructor { prototype: WMTSLayer; diff --git a/src/packages/map/model/layers/WMTSLayerImpl.ts b/src/packages/map/model/layers/WMTSLayerImpl.ts index 51162e1f..63391b02 100644 --- a/src/packages/map/model/layers/WMTSLayerImpl.ts +++ b/src/packages/map/model/layers/WMTSLayerImpl.ts @@ -12,6 +12,7 @@ import { fetchCapabilities } from "../../util/capabilities-utils"; import { AbstractLayer } from "../AbstractLayer"; import { MapModelImpl } from "../MapModelImpl"; import { ImageTile } from "ol"; +import type { Options as WMSSourceOptions } from "ol/source/ImageWMS"; const LOG = createLogger("map:WMTSLayer"); @@ -19,10 +20,10 @@ export class WMTSLayerImpl extends AbstractLayer implements WMTSLayer { #url: string; #name: string; #matrixSet: string; - #attributions?: string | undefined; #layer: TileLayer; #source: WMTS | undefined; #legend: string | undefined; + #sourceOptions?: Partial; readonly #abortController = new AbortController(); constructor(config: WMTSLayerConfig) { @@ -35,6 +36,7 @@ export class WMTSLayerImpl extends AbstractLayer implements WMTSLayer { this.#name = config.name; this.#layer = layer; this.#matrixSet = config.matrixSet; + this.#sourceOptions = config.sourceOptions; } destroy(): void { @@ -61,6 +63,7 @@ export class WMTSLayerImpl extends AbstractLayer implements WMTSLayer { } const source = new WMTS({ ...options, + ...this.#sourceOptions, tileLoadFunction: (tile, tileUrl) => { this.#loadTile(tile, tileUrl); } @@ -97,10 +100,6 @@ export class WMTSLayerImpl extends AbstractLayer implements WMTSLayer { return this.#matrixSet; } - get attributions() { - return this.#attributions; - } - get sublayers(): undefined { return undefined; }