Skip to content

Commit

Permalink
fix: WMTSLayer attributions property (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
panayot-nenov committed Feb 20, 2024
1 parent 1c4aa87 commit fc6bf82
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-onions-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@open-pioneer/map": patch
---

introduce sourceOptions parameter to WMTS layer
13 changes: 8 additions & 5 deletions src/packages/map/api/layers/WMTSLayer.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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<WMSSourceOptions>;
}
export interface WMTSLayer extends Layer {
/** URL of the WMTS service. */
Expand All @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions src/packages/map/model/layers/WMTSLayerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ 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");

export class WMTSLayerImpl extends AbstractLayer implements WMTSLayer {
#url: string;
#name: string;
#matrixSet: string;
#attributions?: string | undefined;
#layer: TileLayer<TileSourceType>;
#source: WMTS | undefined;
#legend: string | undefined;
#sourceOptions?: Partial<WMSSourceOptions>;
readonly #abortController = new AbortController();

constructor(config: WMTSLayerConfig) {
Expand All @@ -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 {
Expand All @@ -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);
}
Expand Down Expand Up @@ -97,10 +100,6 @@ export class WMTSLayerImpl extends AbstractLayer implements WMTSLayer {
return this.#matrixSet;
}

get attributions() {
return this.#attributions;
}

get sublayers(): undefined {
return undefined;
}
Expand Down

0 comments on commit fc6bf82

Please sign in to comment.