@open-pioneer/map 1.3.0-dev-map-loading.20260202144650 → 1.3.0-dev-attributions.20260212134347

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,15 +1,24 @@
1
1
  # @open-pioneer/map
2
2
 
3
- ## 1.3.0-dev-map-loading.20260202144650
3
+ ## 1.3.0-dev-attributions.20260212134347
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - f5030cc: MapModel: implement new `loading` property.
7
+ - 9b5d5f3: Support for new common container props (role, aria-_, data-_ and css)
8
+ - 6b1e2a3: WMSLayer, WMTSLayer: Derive `attributions` from service capabilities if no explicit attributions have been configured.
9
+ - 2ceb1ca: MapModel: implement new `loading` property.
8
10
  This property is `true` if the map is currently loading any resources, `false` otherwise.
9
11
  The property is based on OpenLayers `loadstart` and `loadend` events (see [Documentation](https://openlayers.org/en/latest/apidoc/module-ol_MapEvent-MapEvent.html#event:loadstart)).
10
- - f5030cc: MapContainer: allow configuration of `rootProps` and `containerProps`.
12
+ - 99a08e6: Sanitize HTML used for layer attributions.
13
+ - d54ccfd: Update to Chakra UI 3.32.0
14
+ - 2ceb1ca: MapContainer: allow configuration of `rootProps` and `containerProps`.
11
15
  This can be used to set custom attributes on the respective DOM elements.
12
16
 
17
+ ### Patch Changes
18
+
19
+ - 4bcc8ce: Prevent update of `olMap.padding` by MapContainer if viewPadding did not change.
20
+ This caused running map animation to be cancelled.
21
+
13
22
  ## 1.2.0
14
23
 
15
24
  ### Patch Changes
@@ -7,10 +7,12 @@ import { sourceId$2 as sourceId } from '../_virtual/source-info.js';
7
7
  import { fetchText } from '../utils/fetch.js';
8
8
  import { INTERNAL_CONSTRUCTOR_TAG } from '../utils/InternalConstructorTag.js';
9
9
  import { AbstractLayer } from './AbstractLayer.js';
10
- import { GET_RAW_SUBLAYERS, ATTACH_TO_PARENT, ATTACH_TO_MAP, DETACH_FROM_MAP, SET_LEGEND, GET_DEPS } from './shared/internals.js';
10
+ import { GET_RAW_SUBLAYERS, ATTACH_TO_PARENT, ATTACH_TO_MAP, DETACH_FROM_MAP, GET_DEPS, SET_LEGEND } from './shared/internals.js';
11
11
  import { SublayersCollection } from './shared/SublayersCollection.js';
12
+ import { getAttributions } from './wms/getAttributions.js';
12
13
  import { getLegendUrl } from './wms/getLegendUrl.js';
13
14
  import { constructSublayers } from './wms/WMSSublayer.js';
15
+ import { sanitizeAttributions } from '../utils/sanitize.js';
14
16
 
15
17
  const LOG = createLogger(sourceId);
16
18
  const deprecatedConstructor = deprecated({
@@ -44,11 +46,13 @@ class WMSLayer extends AbstractLayer {
44
46
  deps,
45
47
  internalTag
46
48
  );
49
+ const { attributions, ...sourceOptions } = config.sourceOptions ?? {};
47
50
  const source = new ImageWMS({
48
- ...config.sourceOptions,
51
+ attributions: sanitizeAttributions(attributions),
52
+ ...sourceOptions,
49
53
  url: config.url,
50
54
  params: {
51
- ...config.sourceOptions?.params
55
+ ...sourceOptions?.params
52
56
  },
53
57
  // Use http service to load tiles; needed for authentication etc.
54
58
  imageLoadFunction: (wrapper, url) => {
@@ -128,38 +132,16 @@ class WMSLayer extends AbstractLayer {
128
132
  return;
129
133
  }
130
134
  this.#loadStarted = true;
131
- const getNestedSublayer = (sublayers, layers) => {
132
- for (const sublayer of sublayers) {
133
- const nested = sublayer.sublayers.getSublayers();
134
- if (nested.length) {
135
- getNestedSublayer(nested, layers);
136
- } else {
137
- if (sublayer.name) {
138
- layers.push(sublayer);
139
- }
140
- }
141
- }
142
- };
143
135
  this.#fetchWMSCapabilities().then((result) => {
144
136
  batch(() => {
145
- const parser = new WMSCapabilities();
146
- const capabilities = parser.read(result);
147
- this.#capabilities = capabilities;
148
- const layers = [];
149
- getNestedSublayer(this.#sublayers.getSublayers(), layers);
150
- for (const layer of layers) {
151
- if (layer.name) {
152
- const legendUrl = getLegendUrl(capabilities, layer.name);
153
- layer[SET_LEGEND](legendUrl);
154
- }
155
- }
137
+ this.#initializeWithMetadata(result);
156
138
  });
157
139
  }).catch((error) => {
158
140
  if (isAbortError(error)) {
159
141
  LOG.debug(`Layer '${this.id}' has been destroyed before fetching capabilities`);
160
142
  return;
161
143
  }
162
- LOG.error(`Failed to fetch WMS capabilities for layer '${this.id}'`, error);
144
+ LOG.error(`Failed to initializes WMS layer '${this.id}'`, error);
163
145
  });
164
146
  }
165
147
  /**
@@ -177,23 +159,11 @@ class WMSLayer extends AbstractLayer {
177
159
  }
178
160
  #getVisibleLayerNames() {
179
161
  const layers = [];
180
- const visitSublayer = (sublayer) => {
181
- if (!sublayer.visible) {
182
- return;
183
- }
184
- const nestedSublayers = sublayer.sublayers[GET_RAW_SUBLAYERS]();
185
- if (nestedSublayers.length) {
186
- for (const nestedSublayer of nestedSublayers) {
187
- visitSublayer(nestedSublayer);
188
- }
189
- } else {
190
- if (sublayer.name) {
191
- layers.push(sublayer.name);
192
- }
162
+ const filter = (sublayer) => sublayer.visible;
163
+ for (const sublayer of walkLeaves(this.#sublayers, filter)) {
164
+ if (sublayer.name) {
165
+ layers.push(sublayer.name);
193
166
  }
194
- };
195
- for (const sublayer of this.sublayers[GET_RAW_SUBLAYERS]()) {
196
- visitSublayer(sublayer);
197
167
  }
198
168
  return layers;
199
169
  }
@@ -202,6 +172,23 @@ class WMSLayer extends AbstractLayer {
202
172
  const url = `${this.#url}?LANGUAGE=ger&SERVICE=WMS&REQUEST=GetCapabilities`;
203
173
  return fetchText(url, httpService, this.#abortController.signal);
204
174
  }
175
+ #initializeWithMetadata(metadata) {
176
+ const parser = new WMSCapabilities();
177
+ const capabilities = parser.read(metadata);
178
+ this.#capabilities = capabilities;
179
+ if (!this.#source.getAttributions()) {
180
+ const attributions = getAttributions(capabilities);
181
+ if (attributions) {
182
+ this.#source.setAttributions(sanitizeAttributions(attributions));
183
+ }
184
+ }
185
+ for (const layer of walkLeaves(this.#sublayers)) {
186
+ if (layer.name) {
187
+ const legendUrl = getLegendUrl(capabilities, layer.name);
188
+ layer[SET_LEGEND](legendUrl);
189
+ }
190
+ }
191
+ }
205
192
  async #loadImage(imageWrapper, imageUrl) {
206
193
  const httpService = this[GET_DEPS]().httpService;
207
194
  const image = imageWrapper.getImage();
@@ -221,6 +208,19 @@ class WMSLayer extends AbstractLayer {
221
208
  image.src = objectUrl;
222
209
  }
223
210
  }
211
+ function* walkLeaves(sublayers, filter) {
212
+ for (const sublayer of sublayers[GET_RAW_SUBLAYERS]()) {
213
+ if (filter && !filter(sublayer)) {
214
+ continue;
215
+ }
216
+ const nested = sublayer.sublayers[GET_RAW_SUBLAYERS]();
217
+ if (nested.length) {
218
+ yield* walkLeaves(sublayer.sublayers, filter);
219
+ } else {
220
+ yield sublayer;
221
+ }
222
+ }
223
+ }
224
224
 
225
225
  export { WMSLayer };
226
226
  //# sourceMappingURL=WMSLayer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WMSLayer.js","sources":["WMSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { batch, computed, ReadonlyReactive, watch } from \"@conterra/reactivity-core\";\nimport {\n createLogger,\n deprecated,\n destroyResource,\n isAbortError,\n Resource\n} from \"@open-pioneer/core\";\nimport { ImageWrapper } from \"ol\";\nimport WMSCapabilities from \"ol/format/WMSCapabilities\";\nimport ImageLayer from \"ol/layer/Image\";\nimport type ImageSource from \"ol/source/Image\";\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport ImageWMS from \"ol/source/ImageWMS\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport type { LayerFactory } from \"../LayerFactory\";\nimport { MapModel } from \"../model/MapModel\";\nimport { fetchText } from \"../utils/fetch\";\nimport { INTERNAL_CONSTRUCTOR_TAG, InternalConstructorTag } from \"../utils/InternalConstructorTag\";\nimport { AbstractLayer } from \"./AbstractLayer\";\nimport {\n ATTACH_TO_MAP,\n ATTACH_TO_PARENT,\n DETACH_FROM_MAP,\n GET_DEPS,\n GET_RAW_SUBLAYERS,\n LayerConstructor,\n LayerDependencies,\n SET_LEGEND\n} from \"./shared/internals\";\nimport { LayerConfig } from \"./shared/LayerConfig\";\nimport { SublayersCollection } from \"./shared/SublayersCollection\";\nimport { getLegendUrl } from \"./wms/getLegendUrl\";\nimport { constructSublayers, WMSSublayer, WMSSublayerConfig } from \"./wms/WMSSublayer\";\n\n/**\n * Configuration options to construct a {@link WMSLayer}.\n *\n * @group Layers\n */\nexport interface WMSLayerConfig extends LayerConfig {\n /** URL of the WMS service. */\n url: string;\n\n /** Configures the layer's sublayers. */\n sublayers?: WMSSublayerConfig[];\n\n /**\n * Additional source options for the layer's WMS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n\n /**\n * Whether to automatically fetch capabilities from the service when needed (default: `true`).\n *\n * Setting this to `false` can be useful as a performance optimization when capabilities are not really required by the application.\n * Note that this will disable some features of the WMS layer: for example, the legend URL will not be available.\n */\n fetchCapabilities?: boolean;\n}\n\nconst LOG = createLogger(sourceId);\n\nconst deprecatedConstructor = deprecated({\n name: \"WMSLayer constructor\",\n packageName: \"@open-pioneer/map\",\n since: \"v1.0.0\",\n alternative: \"use LayerFactory.create() instead\"\n});\n\n/**\n * Displays an OGC Web Map Service (WMS).\n *\n * @group Layers\n */\nexport class WMSLayer extends AbstractLayer {\n #url: string;\n #sublayers: SublayersCollection<WMSSublayer>;\n #layer: ImageLayer<ImageSource>;\n #source: ImageWMS;\n #fetchCapabilities: boolean;\n\n #loadStarted = false;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #capabilities: Record<string, any> | undefined;\n readonly #abortController = new AbortController();\n\n #visibleSublayers: ReadonlyReactive<string[]>;\n #sublayersWatch: Resource | undefined;\n\n /**\n * @deprecated Prefer using {@link LayerFactory.create} instead of calling the constructor directly\n */\n constructor(config: WMSLayerConfig);\n\n /**\n * NOTE: Do not use this overload. Use {@link LayerFactory.create} instead.\n *\n * @internal\n */\n constructor(\n config: WMSLayerConfig,\n deps: LayerDependencies,\n internalTag: InternalConstructorTag\n );\n constructor(\n config: WMSLayerConfig,\n deps?: LayerDependencies,\n internalTag?: InternalConstructorTag\n ) {\n if (!internalTag) {\n deprecatedConstructor();\n }\n\n const layer = new ImageLayer();\n\n super(\n {\n ...config,\n olLayer: layer\n },\n deps,\n internalTag\n );\n\n const source = new ImageWMS({\n ...config.sourceOptions,\n url: config.url,\n params: {\n ...config.sourceOptions?.params\n },\n // Use http service to load tiles; needed for authentication etc.\n imageLoadFunction: (wrapper, url) => {\n return this.#loadImage(wrapper, url).catch((error) => {\n LOG.error(`Failed to load tile at '${url}'`, error);\n });\n }\n });\n this.#url = config.url;\n this.#fetchCapabilities = config.fetchCapabilities ?? true;\n this.#source = source;\n this.#layer = layer;\n\n this.#sublayers = new SublayersCollection(\n constructSublayers(config.sublayers),\n INTERNAL_CONSTRUCTOR_TAG\n );\n this.#sublayers\n [GET_RAW_SUBLAYERS]()\n .forEach((sublayer) => sublayer[ATTACH_TO_PARENT](this, this));\n\n this.#visibleSublayers = computed(() => this.#getVisibleLayerNames(), {\n equal(a, b) {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n });\n\n this.#sublayersWatch = watch(\n () => [this.#visibleSublayers.value],\n ([layers]) => {\n this.#updateLayersParam(layers);\n },\n {\n immediate: true\n }\n );\n }\n\n override destroy() {\n this.#abortController.abort();\n this.#sublayersWatch = destroyResource(this.#sublayersWatch);\n super.destroy();\n }\n\n get type() {\n return \"wms\" as const;\n }\n\n get legend() {\n return undefined;\n }\n\n /** The URL of the WMS service that was used during layer construction. */\n get url(): string {\n return this.#url;\n }\n\n get layers(): undefined {\n return undefined;\n }\n\n /**\n * Holds the sublayers of this layer.\n */\n get sublayers(): SublayersCollection<WMSSublayer> {\n return this.#sublayers;\n }\n\n get capabilities() {\n return this.#capabilities;\n }\n\n /** @internal */\n [ATTACH_TO_MAP](map: MapModel): void {\n super[ATTACH_TO_MAP](map);\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer[ATTACH_TO_MAP](map);\n }\n\n this.#load();\n }\n\n /** @internal */\n [DETACH_FROM_MAP](): void {\n super[DETACH_FROM_MAP]();\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer[DETACH_FROM_MAP]();\n }\n }\n\n #load() {\n if (this.#loadStarted || !this.#fetchCapabilities) {\n return;\n }\n this.#loadStarted = true;\n\n /** Find all leaf nodes representing a layer in the structure */\n const getNestedSublayer = (sublayers: WMSSublayer[], layers: WMSSublayer[]) => {\n for (const sublayer of sublayers) {\n const nested = sublayer.sublayers.getSublayers();\n if (nested.length) {\n getNestedSublayer(nested, layers);\n } else {\n if (sublayer.name) {\n layers.push(sublayer);\n }\n }\n }\n };\n\n this.#fetchWMSCapabilities()\n .then((result: string) => {\n batch(() => {\n const parser = new WMSCapabilities();\n const capabilities = parser.read(result);\n this.#capabilities = capabilities;\n\n const layers: WMSSublayer[] = [];\n getNestedSublayer(this.#sublayers.getSublayers(), layers);\n\n for (const layer of layers) {\n if (layer.name) {\n const legendUrl = getLegendUrl(capabilities, layer.name);\n layer[SET_LEGEND](legendUrl);\n }\n }\n });\n })\n .catch((error) => {\n if (isAbortError(error)) {\n LOG.debug(`Layer '${this.id}' has been destroyed before fetching capabilities`);\n return;\n }\n LOG.error(`Failed to fetch WMS capabilities for layer '${this.id}'`, error);\n });\n }\n\n /**\n * Gathers the visibility of _all_ sublayers and assembles the 'layers' WMS parameter.\n * The parameters are then applied to the WMS source.\n */\n #updateLayersParam(layers: string[]) {\n this.#source.updateParams({\n \"LAYERS\": layers\n });\n\n // only set source if there are visible sublayers, otherwise\n // we send an invalid http request\n const source = layers.length === 0 ? null : this.#source;\n if (this.#layer.getSource() !== source) {\n this.#layer.setSource(source);\n }\n }\n\n #getVisibleLayerNames() {\n const layers: string[] = [];\n const visitSublayer = (sublayer: WMSSublayer) => {\n if (!sublayer.visible) {\n return;\n }\n\n const nestedSublayers = sublayer.sublayers[GET_RAW_SUBLAYERS]();\n if (nestedSublayers.length) {\n for (const nestedSublayer of nestedSublayers) {\n visitSublayer(nestedSublayer);\n }\n } else {\n /**\n * Push sublayer only, if layer name is not an empty string | undefined | ...\n */\n if (sublayer.name) {\n layers.push(sublayer.name);\n }\n }\n };\n\n for (const sublayer of this.sublayers[GET_RAW_SUBLAYERS]()) {\n visitSublayer(sublayer);\n }\n return layers;\n }\n\n async #fetchWMSCapabilities(): Promise<string> {\n const httpService = this[GET_DEPS]().httpService;\n const url = `${this.#url}?LANGUAGE=ger&SERVICE=WMS&REQUEST=GetCapabilities`;\n return fetchText(url, httpService, this.#abortController.signal);\n }\n\n async #loadImage(imageWrapper: ImageWrapper, imageUrl: string): Promise<void> {\n const httpService = this[GET_DEPS]().httpService;\n const image = imageWrapper.getImage() as HTMLImageElement;\n\n const response = await httpService.fetch(imageUrl);\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}.`);\n }\n\n const blob = await response.blob();\n const objectUrl = URL.createObjectURL(blob);\n const finish = () => {\n // Cleanup object URL after load to prevent memory leaks.\n // https://stackoverflow.com/questions/62473876/openlayers-6-settileloadfunction-documented-example-uses-url-createobjecturld\n URL.revokeObjectURL(objectUrl);\n image.removeEventListener(\"load\", finish);\n image.removeEventListener(\"error\", finish);\n };\n\n image.addEventListener(\"load\", finish);\n image.addEventListener(\"error\", finish);\n image.src = objectUrl;\n }\n}\n\n// Ensure layer class is assignable to the constructor interface (there is no \"implements\" for the class itself).\n// eslint-disable-next-line no-constant-condition\nif (false) {\n const check: LayerConstructor<WMSLayerConfig, WMSLayer> = WMSLayer;\n void check;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAkEA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,wBAAwB,UAAA,CAAW;AAAA,EACrC,IAAA,EAAM,sBAAA;AAAA,EACN,WAAA,EAAa,mBAAA;AAAA,EACb,KAA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I,CAAA,iDAAA,CAAA;AACxB,IAAA,OAAO,SAAA,CAAU,GAAA,EAAK,WAAA,EAAa,IAAA,CAAK,iBAAiB,MAAM,CAAA;AAAA,EACnE;AAAA,EAEA,MAAM,UAAA,CAAW,YAAA,EAA4B,QAAA,EAAiC;AAC1E,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,QAAQ,CAAA,EAAE,CAAE,WAAA;AACrC,IAAA,MAAM,KAAA,GAAQ,aAAa,QAAA,EAAS;AAEpC,IAAA,MAAM,QAAA,GAAW,MAAM,WAAA,CAAY,KAAA,CAAM,QAAQ,CAAA;AACjD,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AACd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2BAAA,EAA8B,QAAA,CAAS,MAAM,CAAA,CAAA,CAAG,CAAA;AAAA,IACpE;AAEA,IAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AACjC,IAAA,MAAM,SAAA,GAAY,GAAA,CAAI,eAAA,CAAgB,IAAI,CAAA;AAC1C,IAAA,MAAM,SAAS,MAAM;AAGjB,MAAA,GAAA,CAAI,gBAAgB,SAAS,CAAA;AAC7B,MAAA,KAAA,CAAM,mBAAA,CAAoB,QAAQ,MAAM,CAAA;AACxC,MAAA,KAAA,CAAM,mBAAA,CAAoB,SAAS,MAAM,CAAA;AAAA,IAC7C,CAAA;AAEA,IAAA,KAAA,CAAM,gBAAA,CAAiB,QAAQ,MAAM,CAAA;AACrC,IAAA,KAAA,CAAM,gBAAA,CAAiB,SAAS,MAAM,CAAA;AACtC,IAAA,KAAA,CAAM,GAAA,GAAM,SAAA;AAAA,EAChB;AACJ;;;;"}
1
+ {"version":3,"file":"WMSLayer.js","sources":["WMSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { batch, computed, ReadonlyReactive, watch } from \"@conterra/reactivity-core\";\nimport {\n createLogger,\n deprecated,\n destroyResource,\n isAbortError,\n Resource\n} from \"@open-pioneer/core\";\nimport { ImageWrapper } from \"ol\";\nimport WMSCapabilities from \"ol/format/WMSCapabilities\";\nimport ImageLayer from \"ol/layer/Image\";\nimport type ImageSource from \"ol/source/Image\";\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport ImageWMS from \"ol/source/ImageWMS\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport type { LayerFactory } from \"../LayerFactory\";\nimport { MapModel } from \"../model/MapModel\";\nimport { fetchText } from \"../utils/fetch\";\nimport { INTERNAL_CONSTRUCTOR_TAG, InternalConstructorTag } from \"../utils/InternalConstructorTag\";\nimport { AbstractLayer } from \"./AbstractLayer\";\nimport {\n ATTACH_TO_MAP,\n ATTACH_TO_PARENT,\n DETACH_FROM_MAP,\n GET_DEPS,\n GET_RAW_SUBLAYERS,\n LayerConstructor,\n LayerDependencies,\n SET_LEGEND\n} from \"./shared/internals\";\nimport { LayerConfig } from \"./shared/LayerConfig\";\nimport { SublayersCollection } from \"./shared/SublayersCollection\";\nimport { getAttributions } from \"./wms/getAttributions\";\nimport { getLegendUrl } from \"./wms/getLegendUrl\";\nimport { constructSublayers, WMSSublayer, WMSSublayerConfig } from \"./wms/WMSSublayer\";\nimport { sanitizeAttributions } from \"../utils/sanitize\";\nimport { Sublayer } from \"./unions\";\n\n/**\n * Configuration options to construct a {@link WMSLayer}.\n *\n * @group Layers\n */\nexport interface WMSLayerConfig extends LayerConfig {\n /** URL of the WMS service. */\n url: string;\n\n /** Configures the layer's sublayers. */\n sublayers?: WMSSublayerConfig[];\n\n /**\n * Additional source options for the layer's WMS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n\n /**\n * Whether to automatically fetch capabilities from the service when needed (default: `true`).\n *\n * Setting this to `false` can be useful as a performance optimization when capabilities are not really required by the application.\n * Note that this will disable some features of the WMS layer: for example, the legend URL will not be available.\n */\n fetchCapabilities?: boolean;\n}\n\nconst LOG = createLogger(sourceId);\n\nconst deprecatedConstructor = deprecated({\n name: \"WMSLayer constructor\",\n packageName: \"@open-pioneer/map\",\n since: \"v1.0.0\",\n alternative: \"use LayerFactory.create() instead\"\n});\n\n/**\n * Displays an OGC Web Map Service (WMS).\n *\n * @group Layers\n */\nexport class WMSLayer extends AbstractLayer {\n #url: string;\n #sublayers: SublayersCollection<WMSSublayer>;\n #layer: ImageLayer<ImageSource>;\n #source: ImageWMS;\n #fetchCapabilities: boolean;\n\n #loadStarted = false;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #capabilities: Record<string, any> | undefined;\n readonly #abortController = new AbortController();\n\n #visibleSublayers: ReadonlyReactive<string[]>;\n #sublayersWatch: Resource | undefined;\n\n /**\n * @deprecated Prefer using {@link LayerFactory.create} instead of calling the constructor directly\n */\n constructor(config: WMSLayerConfig);\n\n /**\n * NOTE: Do not use this overload. Use {@link LayerFactory.create} instead.\n *\n * @internal\n */\n constructor(\n config: WMSLayerConfig,\n deps: LayerDependencies,\n internalTag: InternalConstructorTag\n );\n constructor(\n config: WMSLayerConfig,\n deps?: LayerDependencies,\n internalTag?: InternalConstructorTag\n ) {\n if (!internalTag) {\n deprecatedConstructor();\n }\n\n const layer = new ImageLayer();\n super(\n {\n ...config,\n olLayer: layer\n },\n deps,\n internalTag\n );\n const { attributions, ...sourceOptions } = config.sourceOptions ?? {};\n const source = new ImageWMS({\n attributions: sanitizeAttributions(attributions),\n ...sourceOptions,\n url: config.url,\n params: {\n ...sourceOptions?.params\n },\n // Use http service to load tiles; needed for authentication etc.\n imageLoadFunction: (wrapper, url) => {\n return this.#loadImage(wrapper, url).catch((error) => {\n LOG.error(`Failed to load tile at '${url}'`, error);\n });\n }\n });\n this.#url = config.url;\n this.#fetchCapabilities = config.fetchCapabilities ?? true;\n this.#source = source;\n this.#layer = layer;\n\n this.#sublayers = new SublayersCollection(\n constructSublayers(config.sublayers),\n INTERNAL_CONSTRUCTOR_TAG\n );\n this.#sublayers\n [GET_RAW_SUBLAYERS]()\n .forEach((sublayer) => sublayer[ATTACH_TO_PARENT](this, this));\n\n this.#visibleSublayers = computed(() => this.#getVisibleLayerNames(), {\n equal(a, b) {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n });\n\n this.#sublayersWatch = watch(\n () => [this.#visibleSublayers.value],\n ([layers]) => {\n this.#updateLayersParam(layers);\n },\n {\n immediate: true\n }\n );\n }\n\n override destroy() {\n this.#abortController.abort();\n this.#sublayersWatch = destroyResource(this.#sublayersWatch);\n super.destroy();\n }\n\n get type() {\n return \"wms\" as const;\n }\n\n get legend() {\n return undefined;\n }\n\n /** The URL of the WMS service that was used during layer construction. */\n get url(): string {\n return this.#url;\n }\n\n get layers(): undefined {\n return undefined;\n }\n\n /**\n * Holds the sublayers of this layer.\n */\n get sublayers(): SublayersCollection<WMSSublayer> {\n return this.#sublayers;\n }\n\n get capabilities() {\n return this.#capabilities;\n }\n\n /** @internal */\n [ATTACH_TO_MAP](map: MapModel): void {\n super[ATTACH_TO_MAP](map);\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer[ATTACH_TO_MAP](map);\n }\n\n this.#load();\n }\n\n /** @internal */\n [DETACH_FROM_MAP](): void {\n super[DETACH_FROM_MAP]();\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer[DETACH_FROM_MAP]();\n }\n }\n\n #load() {\n if (this.#loadStarted || !this.#fetchCapabilities) {\n return;\n }\n this.#loadStarted = true;\n this.#fetchWMSCapabilities()\n .then((result: string) => {\n batch(() => {\n this.#initializeWithMetadata(result);\n });\n })\n .catch((error) => {\n if (isAbortError(error)) {\n LOG.debug(`Layer '${this.id}' has been destroyed before fetching capabilities`);\n return;\n }\n LOG.error(`Failed to initializes WMS layer '${this.id}'`, error);\n });\n }\n\n /**\n * Gathers the visibility of _all_ sublayers and assembles the 'layers' WMS parameter.\n * The parameters are then applied to the WMS source.\n */\n #updateLayersParam(layers: string[]) {\n this.#source.updateParams({\n \"LAYERS\": layers\n });\n\n // only set source if there are visible sublayers, otherwise\n // we send an invalid http request\n const source = layers.length === 0 ? null : this.#source;\n if (this.#layer.getSource() !== source) {\n this.#layer.setSource(source);\n }\n }\n\n #getVisibleLayerNames() {\n const layers: string[] = [];\n const filter = (sublayer: Sublayer) => sublayer.visible;\n for (const sublayer of walkLeaves(this.#sublayers, filter)) {\n // Push sublayer if layer name is not an empty string | undefined | ...\n if (sublayer.name) {\n layers.push(sublayer.name);\n }\n }\n return layers;\n }\n\n async #fetchWMSCapabilities(): Promise<string> {\n const httpService = this[GET_DEPS]().httpService;\n const url = `${this.#url}?LANGUAGE=ger&SERVICE=WMS&REQUEST=GetCapabilities`;\n return fetchText(url, httpService, this.#abortController.signal);\n }\n\n #initializeWithMetadata(metadata: string) {\n const parser = new WMSCapabilities();\n const capabilities = parser.read(metadata);\n this.#capabilities = capabilities;\n\n // Apply attributions from metadata none are set.\n if (!this.#source.getAttributions()) {\n const attributions = getAttributions(capabilities);\n if (attributions) {\n this.#source.setAttributions(sanitizeAttributions(attributions));\n }\n }\n\n for (const layer of walkLeaves(this.#sublayers)) {\n if (layer.name) {\n const legendUrl = getLegendUrl(capabilities, layer.name);\n layer[SET_LEGEND](legendUrl);\n }\n }\n }\n\n async #loadImage(imageWrapper: ImageWrapper, imageUrl: string): Promise<void> {\n const httpService = this[GET_DEPS]().httpService;\n const image = imageWrapper.getImage() as HTMLImageElement;\n\n const response = await httpService.fetch(imageUrl);\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}.`);\n }\n\n const blob = await response.blob();\n const objectUrl = URL.createObjectURL(blob);\n const finish = () => {\n // Cleanup object URL after load to prevent memory leaks.\n // https://stackoverflow.com/questions/62473876/openlayers-6-settileloadfunction-documented-example-uses-url-createobjecturld\n URL.revokeObjectURL(objectUrl);\n image.removeEventListener(\"load\", finish);\n image.removeEventListener(\"error\", finish);\n };\n\n image.addEventListener(\"load\", finish);\n image.addEventListener(\"error\", finish);\n image.src = objectUrl;\n }\n}\n\n/**\n * Yields all leaf notes in the given collection (recursively).\n */\nfunction* walkLeaves(\n sublayers: SublayersCollection<WMSSublayer>,\n filter?: (sublayer: Sublayer) => boolean\n): Generator<WMSSublayer> {\n for (const sublayer of sublayers[GET_RAW_SUBLAYERS]()) {\n if (filter && !filter(sublayer)) {\n continue;\n }\n\n const nested = sublayer.sublayers[GET_RAW_SUBLAYERS]();\n if (nested.length) {\n yield* walkLeaves(sublayer.sublayers, filter);\n } else {\n yield sublayer;\n }\n }\n}\n\n// Ensure layer class is assignable to the constructor interface (there is no \"implements\" for the class itself).\n// eslint-disable-next-line no-constant-condition\nif (false) {\n const check: LayerConstructor<WMSLayerConfig, WMSLayer> = WMSLayer;\n void check;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAqEA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,wBAAwB,UAAA,CAAW;AAAA,EACrC,IAAA,EAAM,sBAAA;AAAA,EACN,WAAA,EAAa,mBAAA;AAAA,EACb,KAAA,EAAO,QAAA;AAAA,EACP,WAAA,EAAa;AACjB,CAAC,CAAA;AAOM,MAAM,iBAAiB,aAAA,CAAc;AAAA,EACxC,IAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EAEA,YAAA,GAAe,KAAA;AAAA;AAAA,EAEf,aAAA;AAAA,EACS,gBAAA,GAAmB,IAAI,eAAA,EAAgB;AAAA,EAEhD,iBAAA;AAAA,EACA,eAAA;AAAA,EAiBA,WAAA,CACI,MAAA,EACA,IAAA,EACA,WAAA,EACF;AACE,IAAA,IAAI,CAAC,WAAA,EAAa;AACd,MAAA,qBAAA,EAAsB;AAAA,IAC1B;AAEA,IAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,EAAW;AAC7B,IAAA,KAAA;AAAA,MACI;AAAA,QACI,GAAG,MAA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ACrC,IAAA,KAAA,CAAM,gBAAA,CAAiB,SAAS,MAAM,CAAA;AACtC,IAAA,KAAA,CAAM,GAAA,GAAM,SAAA;AAAA,EAChB;AACJ;AAKA,UAAU,UAAA,CACN,WACA,MAAA,EACsB;AACtB,EAAA,KAAA,MAAW,QAAA,IAAY,SAAA,CAAU,iBAAiB,CAAA,EAAE,EAAG;AACnD,IAAA,IAAI,MAAA,IAAU,CAAC,MAAA,CAAO,QAAQ,CAAA,EAAG;AAC7B,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,SAAA,CAAU,iBAAiB,CAAA,EAAE;AACrD,IAAA,IAAI,OAAO,MAAA,EAAQ;AACf,MAAA,OAAO,UAAA,CAAW,QAAA,CAAS,SAAA,EAAW,MAAM,CAAA;AAAA,IAChD,CAAA,MAAO;AACH,MAAA,MAAM,QAAA;AAAA,IACV;AAAA,EACJ;AACJ;;;;"}
@@ -1,4 +1,4 @@
1
- import { reactive } from '@conterra/reactivity-core';
1
+ import { reactive, batch } from '@conterra/reactivity-core';
2
2
  import { createLogger, deprecated, isAbortError } from '@open-pioneer/core';
3
3
  import { ImageTile } from 'ol';
4
4
  import TileState from 'ol/TileState.js';
@@ -7,8 +7,10 @@ import TileLayer from 'ol/layer/Tile.js';
7
7
  import WMTS, { optionsFromCapabilities } from 'ol/source/WMTS.js';
8
8
  import { sourceId$3 as sourceId } from '../_virtual/source-info.js';
9
9
  import { fetchText } from '../utils/fetch.js';
10
+ import { sanitizeAttributions } from '../utils/sanitize.js';
10
11
  import { AbstractLayer } from './AbstractLayer.js';
11
12
  import { ATTACH_TO_MAP, GET_DEPS } from './shared/internals.js';
13
+ import { getAttributions } from './wmts/getAttributions.js';
12
14
  import { getLegendUrl } from './wmts/getLegendUrl.js';
13
15
 
14
16
  const LOG = createLogger(sourceId);
@@ -23,7 +25,6 @@ class WMTSLayer extends AbstractLayer {
23
25
  #name;
24
26
  #matrixSet;
25
27
  #layer;
26
- #source;
27
28
  #sourceOptions;
28
29
  #legend = reactive();
29
30
  #loadStarted = false;
@@ -45,7 +46,7 @@ class WMTSLayer extends AbstractLayer {
45
46
  this.#name = config.name;
46
47
  this.#layer = layer;
47
48
  this.#matrixSet = config.matrixSet;
48
- this.#sourceOptions = config.sourceOptions;
49
+ this.#sourceOptions = config.sourceOptions ?? {};
49
50
  }
50
51
  destroy() {
51
52
  this.#abortController.abort();
@@ -85,63 +86,57 @@ class WMTSLayer extends AbstractLayer {
85
86
  }
86
87
  this.#loadStarted = true;
87
88
  this.#fetchWMTSCapabilities().then((result) => {
88
- const parser = new WMTSCapabilities();
89
- const capabilities = parser.read(result);
90
- const options = optionsFromCapabilities(capabilities, {
91
- layer: this.#name,
92
- matrixSet: this.#matrixSet
89
+ batch(() => {
90
+ this.#initializeWithMetadata(result);
93
91
  });
94
- if (!options) {
95
- throw new Error(`Layer '${this.#name}' was not found in capabilities`);
96
- }
97
- if (options.matrixSet !== this.#matrixSet) {
98
- throw new Error(
99
- `Tile matrix set '${this.#matrixSet}' was not found in capabilities`
100
- );
101
- }
102
- if (this.#sourceOptions?.style && this.#sourceOptions.style !== options.style) {
103
- const styleToUse = this.#existsStyleInCapabilities(
104
- capabilities,
105
- this.#sourceOptions.style
106
- );
107
- if (!styleToUse) {
108
- throw new Error(
109
- `Style '${this.#sourceOptions.style}' was not found in capabilities`
110
- );
111
- }
112
- }
113
- const source = new WMTS({
114
- ...options,
115
- ...this.#sourceOptions,
116
- tileLoadFunction: (tile, tileUrl) => {
117
- this.#loadTile(tile, tileUrl);
118
- }
119
- });
120
- this.#source = source;
121
- this.#layer.setSource(this.#source);
122
- const activeStyleId = source.getStyle();
123
- const legendUrl = getLegendUrl(capabilities, this.name, activeStyleId);
124
- this.#legend.value = legendUrl;
125
92
  }).catch((error) => {
126
93
  if (isAbortError(error)) {
127
- LOG.debug(`Layer ${this.name} has been destroyed before fetching the data`);
94
+ LOG.debug(`Layer '${this.name}' has been destroyed before fetching the data`);
128
95
  return;
129
96
  }
130
- LOG.error(`Failed initialize WMTS for Layer ${this.name}`, error);
97
+ LOG.error(`Failed to initialize WMTS layer '${this.name}'`, error);
131
98
  });
132
99
  }
133
- /* eslint-disable @typescript-eslint/no-explicit-any */
134
- #existsStyleInCapabilities(capabilities, styleToUse) {
135
- const layerDesc = capabilities.Contents?.Layer?.find(
136
- (layer) => layer.Identifier === this.#name
137
- );
138
- return layerDesc?.Style?.some((style) => style.Identifier === styleToUse) ?? false;
139
- }
140
- /* eslint-enable @typescript-eslint/no-explicit-any */
141
100
  async #fetchWMTSCapabilities() {
142
101
  const httpService = this[GET_DEPS]().httpService;
143
102
  return fetchText(this.#url, httpService, this.#abortController.signal);
144
103
  }
104
+ #initializeWithMetadata(metadata) {
105
+ const parser = new WMTSCapabilities();
106
+ const capabilities = parser.read(metadata);
107
+ const options = optionsFromCapabilities(capabilities, {
108
+ layer: this.#name,
109
+ matrixSet: this.#matrixSet
110
+ });
111
+ if (!options) {
112
+ throw new Error(`Layer '${this.#name}' was not found in capabilities`);
113
+ }
114
+ if (options.matrixSet !== this.#matrixSet) {
115
+ throw new Error(`Tile matrix set '${this.#matrixSet}' was not found in capabilities`);
116
+ }
117
+ const { attributions: explicitAttributions, ...sourceOptions } = this.#sourceOptions;
118
+ if (sourceOptions.style && sourceOptions.style !== options.style) {
119
+ const styleToUse = this.#existsStyleInCapabilities(capabilities, sourceOptions.style);
120
+ if (!styleToUse) {
121
+ throw new Error(`Style '${sourceOptions.style}' was not found in capabilities`);
122
+ }
123
+ }
124
+ const attributions = sanitizeAttributions(
125
+ explicitAttributions ?? getAttributions(capabilities)
126
+ );
127
+ const source = new WMTS({
128
+ ...options,
129
+ attributions,
130
+ ...sourceOptions,
131
+ tileLoadFunction: (tile, tileUrl) => {
132
+ this.#loadTile(tile, tileUrl);
133
+ }
134
+ });
135
+ this.#layer.setSource(source);
136
+ const activeStyleId = source.getStyle();
137
+ const legendUrl = getLegendUrl(capabilities, this.name, activeStyleId);
138
+ this.#legend.value = legendUrl;
139
+ }
145
140
  async #loadTile(tile, tileUrl) {
146
141
  const httpService = this[GET_DEPS]().httpService;
147
142
  try {
@@ -173,6 +168,14 @@ class WMTSLayer extends AbstractLayer {
173
168
  }
174
169
  }
175
170
  }
171
+ /* eslint-disable @typescript-eslint/no-explicit-any */
172
+ #existsStyleInCapabilities(capabilities, styleToUse) {
173
+ const layerDesc = capabilities.Contents?.Layer?.find(
174
+ (layer) => layer.Identifier === this.#name
175
+ );
176
+ return layerDesc?.Style?.some((style) => style.Identifier === styleToUse) ?? false;
177
+ }
178
+ /* eslint-enable @typescript-eslint/no-explicit-any */
176
179
  }
177
180
  function isHtmlImage(htmlElement) {
178
181
  return "tagName" in htmlElement && htmlElement.tagName === "IMG";
@@ -1 +1 @@
1
- {"version":3,"file":"WMTSLayer.js","sources":["WMTSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive } from \"@conterra/reactivity-core\";\nimport { createLogger, deprecated, isAbortError } from \"@open-pioneer/core\";\nimport { ImageTile } from \"ol\";\nimport Tile from \"ol/Tile\";\nimport TileState from \"ol/TileState\";\nimport WMTSCapabilities from \"ol/format/WMTSCapabilities\";\nimport TileLayer from \"ol/layer/Tile\";\nimport type TileSourceType from \"ol/source/Tile\";\nimport WMTS, { optionsFromCapabilities, Options as WMTSSourceOptions } from \"ol/source/WMTS\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport type { LayerFactory } from \"../LayerFactory\";\nimport { MapModel } from \"../model/MapModel\";\nimport { InternalConstructorTag } from \"../utils/InternalConstructorTag\";\nimport { fetchText } from \"../utils/fetch\";\nimport { AbstractLayer } from \"./AbstractLayer\";\nimport { LayerConfig } from \"./shared/LayerConfig\";\nimport { ATTACH_TO_MAP, GET_DEPS, LayerConstructor, LayerDependencies } from \"./shared/internals\";\nimport { getLegendUrl } from \"./wmts/getLegendUrl\";\n\n/**\n * Configuration options supported by {@link WMTSLayer}.\n *\n * @group Layers\n */\nexport interface WMTSLayerConfig extends LayerConfig {\n /** URL of the WMTS service. */\n url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n matrixSet: string;\n\n /**\n * Additional source options for the layer's WMTS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMTS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMTSSourceOptions>;\n}\n\nconst LOG = createLogger(sourceId);\n\nconst deprecatedConstructor = deprecated({\n name: \"WMTSLayer constructor\",\n packageName: \"@open-pioneer/map\",\n since: \"v1.0.0\",\n alternative: \"use LayerFactory.create() instead\"\n});\n\n/**\n * Displays an OGC Web Map Tile Service (WMTS).\n *\n * @group Layers\n */\nexport class WMTSLayer extends AbstractLayer {\n #url: string;\n #name: string;\n #matrixSet: string;\n #layer: TileLayer<TileSourceType>;\n #source: WMTS | undefined;\n #sourceOptions?: Partial<WMTSSourceOptions>;\n #legend = reactive<string | undefined>();\n\n #loadStarted = false;\n\n readonly #abortController = new AbortController();\n\n /**\n * @deprecated Prefer using {@link LayerFactory.create} instead of calling the constructor directly\n */\n constructor(config: WMTSLayerConfig);\n\n /**\n * NOTE: Do not use this overload. Use {@link LayerFactory.create} instead.\n *\n * @internal\n */\n constructor(\n config: WMTSLayerConfig,\n deps: LayerDependencies,\n internalTag: InternalConstructorTag\n );\n\n constructor(\n config: WMTSLayerConfig,\n deps?: LayerDependencies,\n internalTag?: InternalConstructorTag\n ) {\n if (!internalTag) {\n deprecatedConstructor();\n }\n\n const layer = new TileLayer();\n super(\n {\n ...config,\n olLayer: layer\n },\n deps,\n internalTag\n );\n this.#url = config.url;\n this.#name = config.name;\n this.#layer = layer;\n this.#matrixSet = config.matrixSet;\n this.#sourceOptions = config.sourceOptions;\n }\n\n destroy(): void {\n this.#abortController.abort();\n super.destroy();\n }\n\n get type() {\n return \"wmts\" as const;\n }\n\n /** URL of the WMTS service. */\n override get legend(): string | undefined {\n return this.#legend.value;\n }\n\n override get sublayers(): undefined {\n return undefined;\n }\n\n override get layers(): undefined {\n return undefined;\n }\n\n get url() {\n return this.#url;\n }\n\n /** The name of the WMTS layer in the service's capabilities. */\n get name() {\n return this.#name;\n }\n\n /** The name of the tile matrix set in the service's capabilities. */\n get matrixSet() {\n return this.#matrixSet;\n }\n\n override [ATTACH_TO_MAP](map: MapModel): void {\n super[ATTACH_TO_MAP](map);\n this.#load();\n }\n\n #load() {\n if (this.#loadStarted) {\n return;\n }\n this.#loadStarted = true;\n this.#fetchWMTSCapabilities()\n .then((result: string) => {\n const parser = new WMTSCapabilities();\n const capabilities = parser.read(result);\n const options = optionsFromCapabilities(capabilities, {\n layer: this.#name,\n matrixSet: this.#matrixSet\n });\n if (!options) {\n throw new Error(`Layer '${this.#name}' was not found in capabilities`);\n }\n if (options.matrixSet !== this.#matrixSet) {\n throw new Error(\n `Tile matrix set '${this.#matrixSet}' was not found in capabilities`\n );\n }\n if (this.#sourceOptions?.style && this.#sourceOptions.style !== options.style) {\n const styleToUse = this.#existsStyleInCapabilities(\n capabilities,\n this.#sourceOptions.style\n );\n if (!styleToUse) {\n throw new Error(\n `Style '${this.#sourceOptions.style}' was not found in capabilities`\n );\n }\n }\n\n const source = new WMTS({\n ...options,\n ...this.#sourceOptions,\n tileLoadFunction: (tile, tileUrl) => {\n this.#loadTile(tile, tileUrl);\n }\n });\n this.#source = source;\n this.#layer.setSource(this.#source);\n const activeStyleId = source.getStyle();\n const legendUrl = getLegendUrl(capabilities, this.name, activeStyleId);\n this.#legend.value = legendUrl;\n })\n .catch((error) => {\n if (isAbortError(error)) {\n LOG.debug(`Layer ${this.name} has been destroyed before fetching the data`);\n return;\n }\n LOG.error(`Failed initialize WMTS for Layer ${this.name}`, error);\n //TODO: how to set the load state to error?\n });\n }\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n #existsStyleInCapabilities(capabilities: any, styleToUse: string): boolean {\n // NOTE: we have a style override, check if the style exists in the capabilities\n // the helper optionsFromCapabilities, supports style, too, but uses the Title instead of the Identifier, to find a match in the capabilities\n const layerDesc = capabilities.Contents?.Layer?.find(\n (layer: any) => layer.Identifier === this.#name\n );\n return layerDesc?.Style?.some((style: any) => style.Identifier === styleToUse) ?? false;\n }\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n async #fetchWMTSCapabilities(): Promise<string> {\n const httpService = this[GET_DEPS]().httpService;\n return fetchText(this.#url, httpService, this.#abortController.signal);\n }\n\n async #loadTile(tile: Tile, tileUrl: string): Promise<void> {\n const httpService = this[GET_DEPS]().httpService;\n try {\n if (!(tile instanceof ImageTile)) {\n throw new Error(\"Only 'ImageTile' is supported for now.\");\n }\n\n const image = tile.getImage();\n if (!isHtmlImage(image)) {\n // Could also be canvas or video\n throw new Error(\"Only <img> tags are supported as tiles for now.\");\n }\n\n const response = await httpService.fetch(tileUrl);\n if (!response.ok) {\n throw new Error(`Tile request failed with status ${response.status}.`);\n }\n\n const blob = await response.blob();\n const objectUrl = URL.createObjectURL(blob);\n const finish = () => {\n // Cleanup object URL after load to prevent memory leaks.\n // https://stackoverflow.com/questions/62473876/openlayers-6-settileloadfunction-documented-example-uses-url-createobjecturld\n URL.revokeObjectURL(objectUrl);\n image.removeEventListener(\"load\", finish);\n image.removeEventListener(\"error\", finish);\n };\n image.addEventListener(\"load\", finish);\n image.addEventListener(\"error\", finish);\n image.src = objectUrl;\n } catch (e) {\n tile.setState(TileState.ERROR);\n if (!isAbortError(e)) {\n LOG.error(\"Failed to load tile\", e);\n }\n }\n }\n}\n\n// Ensure layer class is assignable to the constructor interface (there is no \"implements\" for the class itself).\n// eslint-disable-next-line no-constant-condition\nif (false) {\n const check: LayerConstructor<WMTSLayerConfig, WMTSLayer> = WMTSLayer;\n void check;\n}\n\nfunction isHtmlImage(htmlElement: HTMLElement | OffscreenCanvas): htmlElement is HTMLImageElement {\n return \"tagName\" in htmlElement && htmlElement.tagName === \"IMG\";\n}\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IAAI,CAAC,SAAS,EAAA,EAAI;AACd,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,gCAAA,EAAmC,QAAA,CAAS,MAAM,CAAA,CAAA,CAAG,CAAA;AAAA,MACzE;AAEA,MAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AACjC,MAAA,MAAM,SAAA,GAAY,GAAA,CAAI,eAAA,CAAgB,IAAI,CAAA;AAC1C,MAAA,MAAM,SAAS,MAAM;AAGjB,QAAA,GAAA,CAAI,gBAAgB,SAAS,CAAA;AAC7B,QAAA,KAAA,CAAM,mBAAA,CAAoB,QAAQ,MAAM,CAAA;AACxC,QAAA,KAAA,CAAM,mBAAA,CAAoB,SAAS,MAAM,CAAA;AAAA,MAC7C,CAAA;AACA,MAAA,KAAA,CAAM,gBAAA,CAAiB,QAAQ,MAAM,CAAA;AACrC,MAAA,KAAA,CAAM,gBAAA,CAAiB,SAAS,MAAM,CAAA;AACtC,MAAA,KAAA,CAAM,GAAA,GAAM,SAAA;AAAA,IAChB,SAAS,CAAA,EAAG;AACR,MAAA,IAAA,CAAK,QAAA,CAAS,UAAU,KAAK,CAAA;AAC7B,MAAA,IAAI,CAAC,YAAA,CAAa,CAAC,CAAA,EAAG;AAClB,QAAA,GAAA,CAAI,KAAA,CAAM,uBAAuB,CAAC,CAAA;AAAA,MACtC;AAAA,IACJ;AAAA,EACJ;AACJ;AASA,SAAS,YAAY,WAAA,EAA6E;AAC9F,EAAA,OAAO,SAAA,IAAa,WAAA,IAAe,WAAA,CAAY,OAAA,KAAY,KAAA;AAC/D;;;;"}
1
+ {"version":3,"file":"WMTSLayer.js","sources":["WMTSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { batch, reactive } from \"@conterra/reactivity-core\";\nimport { createLogger, deprecated, isAbortError } from \"@open-pioneer/core\";\nimport { ImageTile } from \"ol\";\nimport Tile from \"ol/Tile\";\nimport TileState from \"ol/TileState\";\nimport WMTSCapabilities from \"ol/format/WMTSCapabilities\";\nimport TileLayer from \"ol/layer/Tile\";\nimport type TileSourceType from \"ol/source/Tile\";\nimport WMTS, { optionsFromCapabilities, Options as WMTSSourceOptions } from \"ol/source/WMTS\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport type { LayerFactory } from \"../LayerFactory\";\nimport { MapModel } from \"../model/MapModel\";\nimport { InternalConstructorTag } from \"../utils/InternalConstructorTag\";\nimport { fetchText } from \"../utils/fetch\";\nimport { sanitizeAttributions } from \"../utils/sanitize\";\nimport { AbstractLayer } from \"./AbstractLayer\";\nimport { LayerConfig } from \"./shared/LayerConfig\";\nimport { ATTACH_TO_MAP, GET_DEPS, LayerConstructor, LayerDependencies } from \"./shared/internals\";\nimport { getAttributions } from \"./wmts/getAttributions\";\nimport { getLegendUrl } from \"./wmts/getLegendUrl\";\n\n/**\n * Configuration options supported by {@link WMTSLayer}.\n *\n * @group Layers\n */\nexport interface WMTSLayerConfig extends LayerConfig {\n /** URL of the WMTS service. */\n url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n matrixSet: string;\n\n /**\n * Additional source options for the layer's WMTS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMTS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMTSSourceOptions>;\n}\n\nconst LOG = createLogger(sourceId);\n\nconst deprecatedConstructor = deprecated({\n name: \"WMTSLayer constructor\",\n packageName: \"@open-pioneer/map\",\n since: \"v1.0.0\",\n alternative: \"use LayerFactory.create() instead\"\n});\n\n/**\n * Displays an OGC Web Map Tile Service (WMTS).\n *\n * @group Layers\n */\nexport class WMTSLayer extends AbstractLayer {\n #url: string;\n #name: string;\n #matrixSet: string;\n #layer: TileLayer<TileSourceType>;\n #sourceOptions: Partial<WMTSSourceOptions>;\n #legend = reactive<string | undefined>();\n\n #loadStarted = false;\n\n readonly #abortController = new AbortController();\n\n /**\n * @deprecated Prefer using {@link LayerFactory.create} instead of calling the constructor directly\n */\n constructor(config: WMTSLayerConfig);\n\n /**\n * NOTE: Do not use this overload. Use {@link LayerFactory.create} instead.\n *\n * @internal\n */\n constructor(\n config: WMTSLayerConfig,\n deps: LayerDependencies,\n internalTag: InternalConstructorTag\n );\n\n constructor(\n config: WMTSLayerConfig,\n deps?: LayerDependencies,\n internalTag?: InternalConstructorTag\n ) {\n if (!internalTag) {\n deprecatedConstructor();\n }\n\n const layer = new TileLayer();\n super(\n {\n ...config,\n olLayer: layer\n },\n deps,\n internalTag\n );\n this.#url = config.url;\n this.#name = config.name;\n this.#layer = layer;\n this.#matrixSet = config.matrixSet;\n this.#sourceOptions = config.sourceOptions ?? {};\n }\n\n destroy(): void {\n this.#abortController.abort();\n super.destroy();\n }\n\n get type() {\n return \"wmts\" as const;\n }\n\n /** URL of the WMTS service. */\n override get legend(): string | undefined {\n return this.#legend.value;\n }\n\n override get sublayers(): undefined {\n return undefined;\n }\n\n override get layers(): undefined {\n return undefined;\n }\n\n get url() {\n return this.#url;\n }\n\n /** The name of the WMTS layer in the service's capabilities. */\n get name() {\n return this.#name;\n }\n\n /** The name of the tile matrix set in the service's capabilities. */\n get matrixSet() {\n return this.#matrixSet;\n }\n\n override [ATTACH_TO_MAP](map: MapModel): void {\n super[ATTACH_TO_MAP](map);\n this.#load();\n }\n\n #load() {\n if (this.#loadStarted) {\n return;\n }\n this.#loadStarted = true;\n this.#fetchWMTSCapabilities()\n .then((result: string) => {\n batch(() => {\n this.#initializeWithMetadata(result);\n });\n })\n .catch((error) => {\n if (isAbortError(error)) {\n LOG.debug(`Layer '${this.name}' has been destroyed before fetching the data`);\n return;\n }\n LOG.error(`Failed to initialize WMTS layer '${this.name}'`, error);\n //TODO: how to set the load state to error?\n });\n }\n\n async #fetchWMTSCapabilities(): Promise<string> {\n const httpService = this[GET_DEPS]().httpService;\n return fetchText(this.#url, httpService, this.#abortController.signal);\n }\n\n #initializeWithMetadata(metadata: string) {\n const parser = new WMTSCapabilities();\n const capabilities = parser.read(metadata);\n const options = optionsFromCapabilities(capabilities, {\n layer: this.#name,\n matrixSet: this.#matrixSet\n });\n if (!options) {\n throw new Error(`Layer '${this.#name}' was not found in capabilities`);\n }\n if (options.matrixSet !== this.#matrixSet) {\n throw new Error(`Tile matrix set '${this.#matrixSet}' was not found in capabilities`);\n }\n\n const { attributions: explicitAttributions, ...sourceOptions } = this.#sourceOptions;\n if (sourceOptions.style && sourceOptions.style !== options.style) {\n const styleToUse = this.#existsStyleInCapabilities(capabilities, sourceOptions.style);\n if (!styleToUse) {\n throw new Error(`Style '${sourceOptions.style}' was not found in capabilities`);\n }\n }\n\n const attributions = sanitizeAttributions(\n explicitAttributions ?? getAttributions(capabilities)\n );\n const source = new WMTS({\n ...options,\n attributions,\n ...sourceOptions,\n tileLoadFunction: (tile, tileUrl) => {\n this.#loadTile(tile, tileUrl);\n }\n });\n this.#layer.setSource(source);\n\n const activeStyleId = source.getStyle();\n const legendUrl = getLegendUrl(capabilities, this.name, activeStyleId);\n this.#legend.value = legendUrl;\n }\n\n async #loadTile(tile: Tile, tileUrl: string): Promise<void> {\n const httpService = this[GET_DEPS]().httpService;\n try {\n if (!(tile instanceof ImageTile)) {\n throw new Error(\"Only 'ImageTile' is supported for now.\");\n }\n\n const image = tile.getImage();\n if (!isHtmlImage(image)) {\n // Could also be canvas or video\n throw new Error(\"Only <img> tags are supported as tiles for now.\");\n }\n\n const response = await httpService.fetch(tileUrl);\n if (!response.ok) {\n throw new Error(`Tile request failed with status ${response.status}.`);\n }\n\n const blob = await response.blob();\n const objectUrl = URL.createObjectURL(blob);\n const finish = () => {\n // Cleanup object URL after load to prevent memory leaks.\n // https://stackoverflow.com/questions/62473876/openlayers-6-settileloadfunction-documented-example-uses-url-createobjecturld\n URL.revokeObjectURL(objectUrl);\n image.removeEventListener(\"load\", finish);\n image.removeEventListener(\"error\", finish);\n };\n image.addEventListener(\"load\", finish);\n image.addEventListener(\"error\", finish);\n image.src = objectUrl;\n } catch (e) {\n tile.setState(TileState.ERROR);\n if (!isAbortError(e)) {\n LOG.error(\"Failed to load tile\", e);\n }\n }\n }\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n #existsStyleInCapabilities(capabilities: any, styleToUse: string): boolean {\n // NOTE: we have a style override, check if the style exists in the capabilities\n // the helper optionsFromCapabilities, supports style, too, but uses the Title instead of the Identifier, to find a match in the capabilities\n const layerDesc = capabilities.Contents?.Layer?.find(\n (layer: any) => layer.Identifier === this.#name\n );\n return layerDesc?.Style?.some((style: any) => style.Identifier === styleToUse) ?? false;\n }\n /* eslint-enable @typescript-eslint/no-explicit-any */\n}\n\n// Ensure layer class is assignable to the constructor interface (there is no \"implements\" for the class itself).\n// eslint-disable-next-line no-constant-condition\nif (false) {\n const check: LayerConstructor<WMTSLayerConfig, WMTSLayer> = WMTSLayer;\n void check;\n}\n\nfunction isHtmlImage(htmlElement: HTMLElement | OffscreenCanvas): htmlElement is HTMLImageElement {\n return \"tagName\" in htmlElement && htmlElement.tagName === \"IMG\";\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA+CA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,wBAAwB,UAAA,CAAW;AAAA,EACrC,IAAA,EAAM,uBAAA;AAAA,EACN,WAAA,EAAa,mBAAA;AAAA,EACb,KAAA,EAAO,QAAA;AAAA,EACP,WAAA,EAAa;AACjB,CAAC,CAAA;AAOM,MAAM,kBAAkB,aAAA,CAAc;AAAA,EACzC,IAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAU,QAAA,EAA6B;AAAA,EAEvC,YAAA,GAAe,KAAA;AAAA,EAEN,gBAAA,GAAmB,IAAI,eAAA,EAAgB;AAAA,EAkBhD,WAAA,CACI,MAAA,EACA,IAAA,EACA,WAAA,EACF;AACE,IAAA,IAAI,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,SAAS,CAAA,EAAG;AACR,MAAA,IAAA,CAAK,QAAA,CAAS,UAAU,KAAK,CAAA;AAC7B,MAAA,IAAI,CAAC,YAAA,CAAa,CAAC,CAAA,EAAG;AAClB,QAAA,GAAA,CAAI,KAAA,CAAM,uBAAuB,CAAC,CAAA;AAAA,MACtC;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA,EAGA,0BAAA,CAA2B,cAAmB,UAAA,EAA6B;AAGvE,IAAA,MAAM,SAAA,GAAY,YAAA,CAAa,QAAA,EAAU,KAAA,EAAO,IAAA;AAAA,MAC5C,CAAC,KAAA,KAAe,KAAA,CAAM,UAAA,KAAe,IAAA,CAAK;AAAA,KAC9C;AACA,IAAA,OAAO,SAAA,EAAW,OAAO,IAAA,CAAK,CAAC,UAAe,KAAA,CAAM,UAAA,KAAe,UAAU,CAAA,IAAK,KAAA;AAAA,EACtF;AAAA;AAEJ;AASA,SAAS,YAAY,WAAA,EAA6E;AAC9F,EAAA,OAAO,SAAA,IAAa,WAAA,IAAe,WAAA,CAAY,OAAA,KAAY,KAAA;AAC/D;;;;"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the attribution derived from the WMS service metadata (if any).
3
+ *
4
+ * @param capabilities Parsed service capabilities
5
+ */
6
+ export declare function getAttributions(capabilities: Record<string, any>): string | undefined;
@@ -0,0 +1,22 @@
1
+ function getAttributions(capabilities) {
2
+ const service = capabilities?.Service;
3
+ if (!service) {
4
+ return void 0;
5
+ }
6
+ const constraints = service.AccessConstraints;
7
+ if (isSet(constraints)) {
8
+ return constraints;
9
+ }
10
+ const fees = service.Fees;
11
+ if (isSet(fees)) {
12
+ return fees;
13
+ }
14
+ return void 0;
15
+ }
16
+ const NONE = /none/i;
17
+ function isSet(value) {
18
+ return typeof value === "string" && !!value && !NONE.test(value);
19
+ }
20
+
21
+ export { getAttributions };
22
+ //# sourceMappingURL=getAttributions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAttributions.js","sources":["getAttributions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Returns the attribution derived from the WMS service metadata (if any).\n *\n * @param capabilities Parsed service capabilities\n */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport function getAttributions(capabilities: Record<string, any>): string | undefined {\n const service = capabilities?.Service;\n if (!service) {\n return undefined;\n }\n\n const constraints = service.AccessConstraints;\n if (isSet(constraints)) {\n return constraints;\n }\n\n const fees = service.Fees;\n if (isSet(fees)) {\n return fees;\n }\n\n return undefined;\n}\n\nconst NONE = /none/i;\n\nfunction isSet(value: any): value is string {\n return typeof value === \"string\" && !!value && !NONE.test(value);\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"],"names":[],"mappings":"AASO,SAAS,gBAAgB,YAAA,EAAuD;AACnF,EAAA,MAAM,UAAU,YAAA,EAAc,OAAA;AAC9B,EAAA,IAAI,CAAC,OAAA,EAAS;AACV,IAAA,OAAO,MAAA;AAAA,EACX;AAEA,EAAA,MAAM,cAAc,OAAA,CAAQ,iBAAA;AAC5B,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACpB,IAAA,OAAO,WAAA;AAAA,EACX;AAEA,EAAA,MAAM,OAAO,OAAA,CAAQ,IAAA;AACrB,EAAA,IAAI,KAAA,CAAM,IAAI,CAAA,EAAG;AACb,IAAA,OAAO,IAAA;AAAA,EACX;AAEA,EAAA,OAAO,MAAA;AACX;AAEA,MAAM,IAAA,GAAO,OAAA;AAEb,SAAS,MAAM,KAAA,EAA6B;AACxC,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,CAAC,CAAC,KAAA,IAAS,CAAC,IAAA,CAAK,IAAA,CAAK,KAAK,CAAA;AACnE;;;;"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the attribution derived from the WMTS service metadata (if any).
3
+ *
4
+ * @param capabilities Parsed service capabilities
5
+ */
6
+ export declare function getAttributions(capabilities: Record<string, any>): string | undefined;
@@ -0,0 +1,22 @@
1
+ function getAttributions(capabilities) {
2
+ const service = capabilities?.ServiceIdentification;
3
+ if (!service) {
4
+ return void 0;
5
+ }
6
+ const constraints = service.AccessConstraints;
7
+ if (isSet(constraints)) {
8
+ return constraints;
9
+ }
10
+ const fees = service.Fees;
11
+ if (isSet(fees)) {
12
+ return fees;
13
+ }
14
+ return void 0;
15
+ }
16
+ const NONE = /none/i;
17
+ function isSet(value) {
18
+ return typeof value === "string" && !!value && !NONE.test(value);
19
+ }
20
+
21
+ export { getAttributions };
22
+ //# sourceMappingURL=getAttributions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAttributions.js","sources":["getAttributions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Returns the attribution derived from the WMTS service metadata (if any).\n *\n * @param capabilities Parsed service capabilities\n */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport function getAttributions(capabilities: Record<string, any>): string | undefined {\n const service = capabilities?.ServiceIdentification;\n if (!service) {\n return undefined;\n }\n\n const constraints = service.AccessConstraints;\n if (isSet(constraints)) {\n return constraints;\n }\n\n const fees = service.Fees;\n if (isSet(fees)) {\n return fees;\n }\n\n return undefined;\n}\n\nconst NONE = /none/i;\n\nfunction isSet(value: any): value is string {\n return typeof value === \"string\" && !!value && !NONE.test(value);\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"],"names":[],"mappings":"AASO,SAAS,gBAAgB,YAAA,EAAuD;AACnF,EAAA,MAAM,UAAU,YAAA,EAAc,qBAAA;AAC9B,EAAA,IAAI,CAAC,OAAA,EAAS;AACV,IAAA,OAAO,MAAA;AAAA,EACX;AAEA,EAAA,MAAM,cAAc,OAAA,CAAQ,iBAAA;AAC5B,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACpB,IAAA,OAAO,WAAA;AAAA,EACX;AAEA,EAAA,MAAM,OAAO,OAAA,CAAQ,IAAA;AACrB,EAAA,IAAI,KAAA,CAAM,IAAI,CAAA,EAAG;AACb,IAAA,OAAO,IAAA;AAAA,EACX;AAEA,EAAA,OAAO,MAAA;AACX;AAEA,MAAM,IAAA,GAAO,OAAA;AAEb,SAAS,MAAM,KAAA,EAA6B;AACxC,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,CAAC,CAAC,KAAA,IAAS,CAAC,IAAA,CAAK,IAAA,CAAK,KAAK,CAAA;AACnE;;;;"}
package/model/MapModel.js CHANGED
@@ -329,11 +329,9 @@ class MapModel {
329
329
  */
330
330
  #watchLoadingState() {
331
331
  this.#loadStartEventHandler = this.#olMap.on("loadstart", () => {
332
- LOG.debug("Map is loading");
333
332
  this.#olLoading.value = true;
334
333
  });
335
334
  this.#loadEndEventHandler = this.#olMap.on("loadend", () => {
336
- LOG.debug("Map finished loading");
337
335
  this.#olLoading.value = false;
338
336
  });
339
337
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MapModel.js","sources":["MapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { computed, reactive, ReadonlyReactive, synchronized } from \"@conterra/reactivity-core\";\nimport { emit, emitter, EventSource } from \"@conterra/reactivity-events\";\nimport type { Resource } from \"@open-pioneer/core\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n isAbortError,\n ManualPromise\n} from \"@open-pioneer/core\";\nimport { HttpService } from \"@open-pioneer/http\";\nimport OlMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport OlView from \"ol/View\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { EventsKey } from \"ol/events\";\nimport { getCenter } from \"ol/extent\";\nimport { Geometry } from \"ol/geom\";\nimport { getPointResolution, Projection } from \"ol/proj\";\nimport type { StyleLike } from \"ol/style/Style\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { LAYER_DEPS, LayerDependencies } from \"../layers/shared/internals\";\nimport type { BaseFeature } from \"../utils/BaseFeature\";\nimport {\n assertInternalConstructor,\n INTERNAL_CONSTRUCTOR_TAG,\n InternalConstructorTag\n} from \"../utils/InternalConstructorTag\";\nimport { Highlights } from \"./Highlights\";\nimport { LayerCollection } from \"./LayerCollection\";\nimport { ExtentConfig } from \"./MapConfig\";\n\nconst LOG = createLogger(sourceId);\n\nconst DEFAULT_DPI = 25.4 / 0.28;\nconst INCHES_PER_METRE = 39.37;\n\n/**\n * Style options supported when creating a new {@link Highlight}.\n *\n * @group Map Model\n **/\nexport interface HighlightOptions {\n /**\n * Optional styles to override the default styles.\n */\n highlightStyle?: HighlightStyle;\n}\n\n/**\n * Zoom options supported when creating a new {@link Highlight}.\n *\n * @group Map Model\n **/\nexport interface ZoomOptions {\n /**\n * The zoom-level used if there is no valid extend (such as for single points).\n */\n pointZoom?: number;\n\n /**\n * The maximum zoom-level for multiple points, line or polygon results.\n */\n maxZoom?: number;\n\n /**\n * The view padding to make all features visible.\n */\n viewPadding?: MapPadding;\n\n /**\n * The buffer factor around the extent of the zoomed features. E.g. a value of 1.1 will add\n * 10% to specify the size increase of the extent's width and height.\n */\n buffer?: number;\n}\n\n/**\n * Options supported by the map model's {@link MapModel.highlightAndZoom | highlightAndZoom} method.\n *\n * @group Map Model\n **/\nexport interface HighlightZoomOptions extends HighlightOptions, ZoomOptions {}\n\n/**\n * Custom styles when creating a new {@link Highlight}.\n *\n * @group Map Model\n */\nexport type HighlightStyle = {\n Point?: StyleLike;\n LineString?: StyleLike;\n Polygon?: StyleLike;\n MultiPolygon?: StyleLike;\n MultiPoint?: StyleLike;\n MultiLineString?: StyleLike;\n};\n\n/**\n * Map padding, all values are pixels.\n *\n * See https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding\n *\n * @group Map Model\n */\nexport interface MapPadding {\n left?: number;\n right?: number;\n top?: number;\n bottom?: number;\n}\n\n/**\n * Represents the additional graphical representations of objects.\n *\n * See also {@link MapModel.highlight}.\n *\n * @group Map Model\n */\nexport interface Highlight extends Resource {\n readonly isActive: boolean;\n}\n\n/**\n * Represents an object in the map.\n *\n * @group Map Model\n */\nexport type DisplayTarget = BaseFeature | Geometry;\n\n/**\n * Represents a map.\n *\n * @group Map Model\n */\nexport class MapModel {\n readonly #id: string;\n readonly #olMap: OlMap;\n readonly #olView: ReadonlyReactive<OlView>;\n readonly #layers = new LayerCollection(this, INTERNAL_CONSTRUCTOR_TAG);\n readonly #highlights: Highlights;\n readonly #layerDeps: LayerDependencies;\n readonly #destroyed = emitter();\n\n #loadStartEventHandler: EventsKey | undefined;\n #loadEndEventHandler: EventsKey | undefined;\n readonly #olLoading = reactive(false);\n\n #isDestroyed = false;\n #container: ReadonlyReactive<HTMLElement | undefined>;\n #initialExtent = reactive<ExtentConfig>();\n #viewBindings: ReadonlyReactive<ViewBindings>;\n #scale: ReadonlyReactive<number | undefined>;\n\n readonly #abortController = new AbortController();\n #displayStatus: \"waiting\" | \"ready\" | \"error\";\n #displayWaiter: ManualPromise<void> | undefined;\n\n /**\n * @internal\n */\n constructor(\n properties: {\n id: string;\n olMap: OlMap;\n initialExtent: ExtentConfig | undefined;\n httpService: HttpService;\n },\n tag: InternalConstructorTag\n ) {\n assertInternalConstructor(tag);\n\n this.#id = properties.id;\n this.#olMap = properties.olMap;\n this.#olView = synchronized(\n () => this.#olMap.getView(),\n (cb) => {\n const key = this.#olMap.on(\"change:view\", cb);\n return () => unByKey(key);\n }\n );\n\n // NOTE: As early as possible (before any async actions) so we don't miss any events.\n this.#watchLoadingState();\n\n this.#initialExtent.value = properties.initialExtent;\n this.#layerDeps = {\n httpService: properties.httpService\n };\n\n this.#displayStatus = \"waiting\";\n this.#initializeView().then(\n () => {\n this.#displayStatus = \"ready\";\n this.#displayWaiter?.resolve();\n this.#displayWaiter = undefined;\n },\n (error) => {\n if (!isAbortError(error)) {\n LOG.error(`Failed to initialize map`, error);\n }\n\n this.#displayStatus = \"error\";\n this.#displayWaiter?.reject(new Error(`Failed to initialize map.`));\n this.#displayWaiter = undefined;\n }\n );\n\n this.#container = synchronized(\n () => this.#olMap.getTargetElement() ?? undefined,\n (cb) => {\n const key = this.#olMap.on(\"change:target\", cb);\n return () => unByKey(key);\n }\n );\n\n this.#viewBindings = computed(() => createViewBindings(this.#olView.value));\n this.#scale = computed(() => {\n const { projection, resolution, center } = this;\n if (projection == null || resolution == null || center == null) {\n return undefined;\n }\n\n /**\n * Returns the appropriate scale for the given resolution and units, see OpenLayers function getScaleForResolution()\n * https://github.com/openlayers/openlayers/blob/7fa9df03431e9e1bc517e6c414565d9f848a3132/src/ol/control/ScaleLine.js#L454C3-L454C24\n */\n const pointResolution = getPointResolution(projection, resolution, center, \"m\"); //point resolution in meter per pixel\n const scale = Math.round(pointResolution * INCHES_PER_METRE * DEFAULT_DPI);\n return scale;\n });\n\n // expects fully constructed mapModel\n this.#highlights = new Highlights(this, this.#layerDeps);\n }\n\n /**\n * Destroys this objects, including all layers, highlights and the OL map itself.\n */\n destroy() {\n if (this.#isDestroyed) {\n return;\n }\n\n this.#isDestroyed = true;\n try {\n emit(this.#destroyed);\n } catch (e) {\n LOG.warn(`Unexpected error from event listener during map model destruction:`, e);\n }\n\n this.#loadStartEventHandler && unByKey(this.#loadStartEventHandler);\n this.#loadStartEventHandler = undefined;\n this.#loadEndEventHandler && unByKey(this.#loadEndEventHandler);\n this.#loadEndEventHandler = undefined;\n\n this.#abortController.abort();\n this.#displayWaiter?.reject(new Error(\"Map model was destroyed.\"));\n this.#layers.destroy();\n this.#highlights.destroy();\n this.#olMap.dispose();\n }\n\n /**\n * Emitted when the map model is destroyed.\n */\n get destroyed(): EventSource<void> {\n return this.#destroyed;\n }\n\n /**\n * The unique id of the map.\n */\n get id(): string {\n return this.#id;\n }\n\n /**\n * The initial map extent.\n *\n * May be undefined before the map is shown.\n * This is guaranteed to be initialized if the promise returned by {@link whenDisplayed} has resolved.\n */\n get initialExtent(): ExtentConfig | undefined {\n return this.#initialExtent.value;\n }\n\n /**\n * Returns the current projection of the map (reactive).\n */\n get projection(): Projection {\n return this.#viewBindings.value.projection;\n }\n\n /**\n * Returns the current center of the map.\n * Same as `olView.getCenter()`, but reactive.\n */\n get center(): Coordinate | undefined {\n return this.#viewBindings.value.center.value;\n }\n\n /**\n * Returns the current resolution of the map.\n * Same as `olView.getResolution()`, but reactive.\n */\n get resolution(): number | undefined {\n return this.#viewBindings.value.resolution.value;\n }\n\n /**\n * Returns the current zoom level of the map.\n * Same as `olView.getZoom()`, but reactive.\n */\n get zoomLevel(): number | undefined {\n return this.#viewBindings.value.zoom.value;\n }\n\n /**\n * Returns the current scale of the map.\n *\n * The scale is a value derived from the current `center`, `resolution` and `projection` of the map.\n * The scale will change when the map is zoomed in our out, but depending on the projection, it may also\n * change when the map is _panned_.\n *\n * > NOTE: Technically, this is the _denominator_ of the current scale.\n * > In order to display it, use a format like `1:${scale}`.\n */\n get scale(): number | undefined {\n return this.#scale.value;\n }\n\n /**\n * Returns true if the map is currently loading.\n *\n * This is based on the OpenLayers events `loadstart` and `loadend`,\n * see [Documentation](https://openlayers.org/en/latest/apidoc/module-ol_MapEvent-MapEvent.html#event:loadstart).\n */\n get loading(): boolean {\n return this.#olLoading.value;\n }\n\n /**\n * Contains all known layers of this map.\n *\n * Note that not all layers in this collection may be active in the OpenLayers map.\n * Also note that not all layers in the OpenLayers map may be contained in this collection.\n */\n get layers(): LayerCollection {\n return this.#layers;\n }\n\n /**\n * The container in which the map is currently being rendered.\n * This is the same as the target element of the underlying OpenLayers map.\n *\n * May be undefined if the map is not being rendered at the moment.\n * May change at runtime.\n */\n get container(): HTMLElement | undefined {\n return this.#container.value;\n }\n\n /**\n * The raw OpenLayers map.\n */\n get olMap(): OlMap {\n return this.#olMap;\n }\n\n /**\n * Returns the current view of the OpenLayers map.\n */\n get olView(): OlView {\n return this.#olView.value;\n }\n\n /**\n * TODO: Can be removed once the LayerFactory is the only supported way of constructing a layer.\n *\n * @internal\n */\n get [LAYER_DEPS](): LayerDependencies {\n return this.#layerDeps;\n }\n\n /**\n * Changes the current scale of the map to the given value.\n *\n * Internally, this computes a new zoom level / resolution based on the scale\n * and the current center.\n * The new resolution is then applied to the current `olView`.\n *\n * See also {@link scale}.\n */\n setScale(newScale: number): void {\n const view = this.olView;\n const projection = this.projection;\n const center = this.center;\n if (!center) {\n return;\n }\n\n const mpu = projection.getMetersPerUnit() ?? 1;\n const resolution = INCHES_PER_METRE * DEFAULT_DPI * mpu;\n const pointResolution = newScale / getPointResolution(projection, resolution, center);\n view.setResolution(pointResolution);\n }\n\n /**\n * Creates a highlight at the given targets.\n *\n * A highlight is a temporary graphic on the map that calls attention to a point or an area.\n *\n * Call `destroy()` on the returned highlight object to remove the highlight again.\n */\n highlight(geometries: DisplayTarget[], options?: HighlightOptions | undefined): Highlight {\n return this.#highlights.addHighlight(geometries, options);\n }\n\n /**\n * Zooms to the given targets.\n */\n zoom(geometries: DisplayTarget[], options?: ZoomOptions | undefined): void {\n this.#highlights.zoomToHighlight(geometries, options);\n }\n\n /**\n * Creates a highlight and zooms to the given targets.\n *\n * See also {@link highlight} and {@link zoom}.\n */\n highlightAndZoom(geometries: DisplayTarget[], options?: HighlightZoomOptions) {\n return this.#highlights.addHighlightAndZoom(geometries, options ?? {});\n }\n\n /**\n * Removes any existing highlights from the map.\n */\n removeHighlights() {\n this.#highlights.clearHighlight();\n }\n\n /**\n * Returns a promise that resolves when the map has mounted in the DOM.\n */\n whenDisplayed(): Promise<void> {\n if (this.#isDestroyed) {\n return Promise.reject(new Error(\"Map model was destroyed.\"));\n }\n if (this.#displayStatus === \"error\") {\n return Promise.reject(new Error(`Failed to initialize map.`));\n }\n if (this.#displayStatus === \"ready\") {\n return Promise.resolve();\n }\n return (this.#displayWaiter ??= createManualPromise()).promise;\n }\n\n /**\n * Waits for the map to be displayed and then initializes the view (if necessary).\n *\n * May simply resolve when done, or throw an error when a problem occurs.\n * AbortError is thrown when cancelled via `this.#abortController`, for example\n * when the map model is destroyed before it has ever been displayed.\n */\n async #initializeView(): Promise<void> {\n try {\n await waitForMapSize(this.olMap, this.#abortController.signal); // may throw on cancel\n } catch (e) {\n if (isAbortError(e)) {\n throw e;\n }\n throw new Error(`Failed to wait for the map to be displayed.`, { cause: e });\n }\n\n try {\n const olMap = this.#olMap;\n const view = olMap.getView();\n\n if (this.#initialExtent.value) {\n // Initial extent was set from the outside. We simply ensure that it gets displayed by the map.\n const extent = this.#initialExtent.value;\n const olExtent = [extent.xMin, extent.yMin, extent.xMax, extent.yMax];\n\n const olCenter = getCenter(olExtent);\n const resolution = view.getResolutionForExtent(olExtent);\n LOG.debug(`Applying initial extent`, extent);\n LOG.debug(` Computed center:`, olCenter);\n LOG.debug(` Computed resolution:`, resolution);\n\n view.setCenter(olCenter);\n view.setResolution(resolution);\n } else {\n // Initial extent was NOT set from the outside.\n // We detect whatever the view is displaying and consider it to be the initial extent.\n const olExtent = view.calculateExtent();\n const [xMin = 0, yMin = 0, xMax = 0, yMax = 0] = olExtent;\n const extent: ExtentConfig = { xMin, yMin, xMax, yMax };\n LOG.debug(`Detected initial extent`, extent);\n\n this.#initialExtent.value = extent;\n }\n } catch (e) {\n throw new Error(`Failed to apply the initial extent.`, { cause: e });\n }\n }\n\n /**\n * Subscribes to the OpenLayers loading state.\n */\n #watchLoadingState() {\n this.#loadStartEventHandler = this.#olMap.on(\"loadstart\", () => {\n LOG.debug(\"Map is loading\");\n this.#olLoading.value = true;\n });\n this.#loadEndEventHandler = this.#olMap.on(\"loadend\", () => {\n LOG.debug(\"Map finished loading\");\n this.#olLoading.value = false;\n });\n }\n}\n\ninterface ViewBindings {\n resolution: ReadonlyReactive<number | undefined>;\n center: ReadonlyReactive<Coordinate | undefined>;\n zoom: ReadonlyReactive<number | undefined>;\n projection: Projection; // not reactive (change view to change projection)\n}\n\nfunction createViewBindings(view: OlView): ViewBindings {\n return {\n resolution: synchronized(\n () => view.getResolution(),\n (cb) => {\n const key = view.on(\"change:resolution\", cb);\n return () => unByKey(key);\n }\n ),\n center: synchronized(\n () => view.getCenter(),\n (cb) => {\n const key = view.on(\"change:center\", cb);\n return () => unByKey(key);\n }\n ),\n zoom: synchronized(\n () => view.getZoom(),\n (cb) => {\n const key = view.on(\"change:resolution\", cb);\n return () => unByKey(key);\n }\n ),\n projection: view.getProjection()\n };\n}\n\nfunction waitForMapSize(olMap: OlMap, signal: AbortSignal): Promise<void> {\n const promise = new Promise<void>((resolve, reject) => {\n let eventKey: EventsKey | undefined;\n\n function checkSize() {\n const currentSize = olMap.getSize() ?? [];\n const [width = 0, height = 0] = currentSize;\n if (currentSize && width > 0 && height > 0) {\n finish();\n }\n }\n\n function onAbort() {\n finish(createAbortError());\n }\n\n function finish(error?: Error | undefined) {\n if (eventKey) {\n unByKey(eventKey);\n eventKey = undefined;\n }\n signal.removeEventListener(\"abort\", onAbort);\n\n if (error) {\n reject(error);\n } else {\n resolve(wait(25)); // Give the map some time to render\n }\n }\n\n if (signal.aborted) {\n finish(createAbortError());\n return;\n }\n\n signal.addEventListener(\"abort\", onAbort);\n eventKey = olMap.on(\"change:size\", checkSize);\n });\n return promise;\n}\n\nfunction wait(milliseconds: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, milliseconds));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAkCA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,cAAc,IAAA,GAAO,IAAA;AAC3B,MAAM,gBAAA,GAAmB,KAAA;AAoGlB,MAAM,QAAA,CAAS;AAAA,EACT,GAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA,GAAU,IAAI,eAAA,CAAgB,IAAA,EAAM,wBAAwB,CAAA;AAAA,EAC5D,WAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAa,OAAA,EAAQ;AAAA,EAE9B,sBAAA;AAAA,EACA,oBAAA;AAAA,EACS,UAAA,GAAa,SAAS,KAAK,CAAA;AAAA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AAA;AAChC,MAAA,IAAI,WAAA,IAAe,KAAA,GAAQ,CAAA,IAAK,MAAA,GAAS,CAAA,EAAG;AACxC,QAAA,MAAA,EAAO;AAAA,MACX;AAAA,IACJ;AAEA,IAAA,SAAS,OAAA,GAAU;AACf,MAAA,MAAA,CAAO,kBAAkB,CAAA;AAAA,IAC7B;AAEA,IAAA,SAAS,OAAO,KAAA,EAA2B;AACvC,MAAA,IAAI,QAAA,EAAU;AACV,QAAA,OAAA,CAAQ,QAAQ,CAAA;AAChB,QAAA,QAAA,GAAW,MAAA;AAAA,MACf;AACA,MAAA,MAAA,CAAO,mBAAA,CAAoB,SAAS,OAAO,CAAA;AAE3C,MAAA,IAAI,KAAA,EAAO;AACP,QAAA,MAAA,CAAO,KAAK,CAAA;AAAA,MAChB,CAAA,MAAO;AACH,QAAA,OAAA,CAAQ,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA,MACpB;AAAA,IACJ;AAEA,IAAA,IAAI,OAAO,OAAA,EAAS;AAChB,MAAA,MAAA,CAAO,kBAAkB,CAAA;AACzB,MAAA;AAAA,IACJ;AAEA,IAAA,MAAA,CAAO,gBAAA,CAAiB,SAAS,OAAO,CAAA;AACxC,IAAA,QAAA,GAAW,KAAA,CAAM,EAAA,CAAG,aAAA,EAAe,SAAS,CAAA;AAAA,EAChD,CAAC,CAAA;AACD,EAAA,OAAO,OAAA;AACX;AAEA,SAAS,KAAK,YAAA,EAAqC;AAC/C,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,YAAY,UAAA,CAAW,OAAA,EAAS,YAAY,CAAC,CAAA;AACrE;;;;"}
1
+ {"version":3,"file":"MapModel.js","sources":["MapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { computed, reactive, ReadonlyReactive, synchronized } from \"@conterra/reactivity-core\";\nimport { emit, emitter, EventSource } from \"@conterra/reactivity-events\";\nimport type { Resource } from \"@open-pioneer/core\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n isAbortError,\n ManualPromise\n} from \"@open-pioneer/core\";\nimport { HttpService } from \"@open-pioneer/http\";\nimport OlMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport OlView from \"ol/View\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { EventsKey } from \"ol/events\";\nimport { getCenter } from \"ol/extent\";\nimport { Geometry } from \"ol/geom\";\nimport { getPointResolution, Projection } from \"ol/proj\";\nimport type { StyleLike } from \"ol/style/Style\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { LAYER_DEPS, LayerDependencies } from \"../layers/shared/internals\";\nimport type { BaseFeature } from \"../utils/BaseFeature\";\nimport {\n assertInternalConstructor,\n INTERNAL_CONSTRUCTOR_TAG,\n InternalConstructorTag\n} from \"../utils/InternalConstructorTag\";\nimport { Highlights } from \"./Highlights\";\nimport { LayerCollection } from \"./LayerCollection\";\nimport { ExtentConfig } from \"./MapConfig\";\n\nconst LOG = createLogger(sourceId);\n\nconst DEFAULT_DPI = 25.4 / 0.28;\nconst INCHES_PER_METRE = 39.37;\n\n/**\n * Style options supported when creating a new {@link Highlight}.\n *\n * @group Map Model\n **/\nexport interface HighlightOptions {\n /**\n * Optional styles to override the default styles.\n */\n highlightStyle?: HighlightStyle;\n}\n\n/**\n * Zoom options supported when creating a new {@link Highlight}.\n *\n * @group Map Model\n **/\nexport interface ZoomOptions {\n /**\n * The zoom-level used if there is no valid extend (such as for single points).\n */\n pointZoom?: number;\n\n /**\n * The maximum zoom-level for multiple points, line or polygon results.\n */\n maxZoom?: number;\n\n /**\n * The view padding to make all features visible.\n */\n viewPadding?: MapPadding;\n\n /**\n * The buffer factor around the extent of the zoomed features. E.g. a value of 1.1 will add\n * 10% to specify the size increase of the extent's width and height.\n */\n buffer?: number;\n}\n\n/**\n * Options supported by the map model's {@link MapModel.highlightAndZoom | highlightAndZoom} method.\n *\n * @group Map Model\n **/\nexport interface HighlightZoomOptions extends HighlightOptions, ZoomOptions {}\n\n/**\n * Custom styles when creating a new {@link Highlight}.\n *\n * @group Map Model\n */\nexport type HighlightStyle = {\n Point?: StyleLike;\n LineString?: StyleLike;\n Polygon?: StyleLike;\n MultiPolygon?: StyleLike;\n MultiPoint?: StyleLike;\n MultiLineString?: StyleLike;\n};\n\n/**\n * Map padding, all values are pixels.\n *\n * See https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding\n *\n * @group Map Model\n */\nexport interface MapPadding {\n left?: number;\n right?: number;\n top?: number;\n bottom?: number;\n}\n\n/**\n * Represents the additional graphical representations of objects.\n *\n * See also {@link MapModel.highlight}.\n *\n * @group Map Model\n */\nexport interface Highlight extends Resource {\n readonly isActive: boolean;\n}\n\n/**\n * Represents an object in the map.\n *\n * @group Map Model\n */\nexport type DisplayTarget = BaseFeature | Geometry;\n\n/**\n * Represents a map.\n *\n * @group Map Model\n */\nexport class MapModel {\n readonly #id: string;\n readonly #olMap: OlMap;\n readonly #olView: ReadonlyReactive<OlView>;\n readonly #layers = new LayerCollection(this, INTERNAL_CONSTRUCTOR_TAG);\n readonly #highlights: Highlights;\n readonly #layerDeps: LayerDependencies;\n readonly #destroyed = emitter();\n\n #loadStartEventHandler: EventsKey | undefined;\n #loadEndEventHandler: EventsKey | undefined;\n readonly #olLoading = reactive(false);\n\n #isDestroyed = false;\n #container: ReadonlyReactive<HTMLElement | undefined>;\n #initialExtent = reactive<ExtentConfig>();\n #viewBindings: ReadonlyReactive<ViewBindings>;\n #scale: ReadonlyReactive<number | undefined>;\n\n readonly #abortController = new AbortController();\n #displayStatus: \"waiting\" | \"ready\" | \"error\";\n #displayWaiter: ManualPromise<void> | undefined;\n\n /**\n * @internal\n */\n constructor(\n properties: {\n id: string;\n olMap: OlMap;\n initialExtent: ExtentConfig | undefined;\n httpService: HttpService;\n },\n tag: InternalConstructorTag\n ) {\n assertInternalConstructor(tag);\n\n this.#id = properties.id;\n this.#olMap = properties.olMap;\n this.#olView = synchronized(\n () => this.#olMap.getView(),\n (cb) => {\n const key = this.#olMap.on(\"change:view\", cb);\n return () => unByKey(key);\n }\n );\n\n // NOTE: As early as possible (before any async actions) so we don't miss any events.\n this.#watchLoadingState();\n\n this.#initialExtent.value = properties.initialExtent;\n this.#layerDeps = {\n httpService: properties.httpService\n };\n\n this.#displayStatus = \"waiting\";\n this.#initializeView().then(\n () => {\n this.#displayStatus = \"ready\";\n this.#displayWaiter?.resolve();\n this.#displayWaiter = undefined;\n },\n (error) => {\n if (!isAbortError(error)) {\n LOG.error(`Failed to initialize map`, error);\n }\n\n this.#displayStatus = \"error\";\n this.#displayWaiter?.reject(new Error(`Failed to initialize map.`));\n this.#displayWaiter = undefined;\n }\n );\n\n this.#container = synchronized(\n () => this.#olMap.getTargetElement() ?? undefined,\n (cb) => {\n const key = this.#olMap.on(\"change:target\", cb);\n return () => unByKey(key);\n }\n );\n\n this.#viewBindings = computed(() => createViewBindings(this.#olView.value));\n this.#scale = computed(() => {\n const { projection, resolution, center } = this;\n if (projection == null || resolution == null || center == null) {\n return undefined;\n }\n\n /**\n * Returns the appropriate scale for the given resolution and units, see OpenLayers function getScaleForResolution()\n * https://github.com/openlayers/openlayers/blob/7fa9df03431e9e1bc517e6c414565d9f848a3132/src/ol/control/ScaleLine.js#L454C3-L454C24\n */\n const pointResolution = getPointResolution(projection, resolution, center, \"m\"); //point resolution in meter per pixel\n const scale = Math.round(pointResolution * INCHES_PER_METRE * DEFAULT_DPI);\n return scale;\n });\n\n // expects fully constructed mapModel\n this.#highlights = new Highlights(this, this.#layerDeps);\n }\n\n /**\n * Destroys this objects, including all layers, highlights and the OL map itself.\n */\n destroy() {\n if (this.#isDestroyed) {\n return;\n }\n\n this.#isDestroyed = true;\n try {\n emit(this.#destroyed);\n } catch (e) {\n LOG.warn(`Unexpected error from event listener during map model destruction:`, e);\n }\n\n this.#loadStartEventHandler && unByKey(this.#loadStartEventHandler);\n this.#loadStartEventHandler = undefined;\n this.#loadEndEventHandler && unByKey(this.#loadEndEventHandler);\n this.#loadEndEventHandler = undefined;\n\n this.#abortController.abort();\n this.#displayWaiter?.reject(new Error(\"Map model was destroyed.\"));\n this.#layers.destroy();\n this.#highlights.destroy();\n this.#olMap.dispose();\n }\n\n /**\n * Emitted when the map model is destroyed.\n */\n get destroyed(): EventSource<void> {\n return this.#destroyed;\n }\n\n /**\n * The unique id of the map.\n */\n get id(): string {\n return this.#id;\n }\n\n /**\n * The initial map extent.\n *\n * May be undefined before the map is shown.\n * This is guaranteed to be initialized if the promise returned by {@link whenDisplayed} has resolved.\n */\n get initialExtent(): ExtentConfig | undefined {\n return this.#initialExtent.value;\n }\n\n /**\n * Returns the current projection of the map (reactive).\n */\n get projection(): Projection {\n return this.#viewBindings.value.projection;\n }\n\n /**\n * Returns the current center of the map.\n * Same as `olView.getCenter()`, but reactive.\n */\n get center(): Coordinate | undefined {\n return this.#viewBindings.value.center.value;\n }\n\n /**\n * Returns the current resolution of the map.\n * Same as `olView.getResolution()`, but reactive.\n */\n get resolution(): number | undefined {\n return this.#viewBindings.value.resolution.value;\n }\n\n /**\n * Returns the current zoom level of the map.\n * Same as `olView.getZoom()`, but reactive.\n */\n get zoomLevel(): number | undefined {\n return this.#viewBindings.value.zoom.value;\n }\n\n /**\n * Returns the current scale of the map.\n *\n * The scale is a value derived from the current `center`, `resolution` and `projection` of the map.\n * The scale will change when the map is zoomed in our out, but depending on the projection, it may also\n * change when the map is _panned_.\n *\n * > NOTE: Technically, this is the _denominator_ of the current scale.\n * > In order to display it, use a format like `1:${scale}`.\n */\n get scale(): number | undefined {\n return this.#scale.value;\n }\n\n /**\n * Returns true if the map is currently loading.\n *\n * This is based on the OpenLayers events `loadstart` and `loadend`,\n * see [Documentation](https://openlayers.org/en/latest/apidoc/module-ol_MapEvent-MapEvent.html#event:loadstart).\n */\n get loading(): boolean {\n return this.#olLoading.value;\n }\n\n /**\n * Contains all known layers of this map.\n *\n * Note that not all layers in this collection may be active in the OpenLayers map.\n * Also note that not all layers in the OpenLayers map may be contained in this collection.\n */\n get layers(): LayerCollection {\n return this.#layers;\n }\n\n /**\n * The container in which the map is currently being rendered.\n * This is the same as the target element of the underlying OpenLayers map.\n *\n * May be undefined if the map is not being rendered at the moment.\n * May change at runtime.\n */\n get container(): HTMLElement | undefined {\n return this.#container.value;\n }\n\n /**\n * The raw OpenLayers map.\n */\n get olMap(): OlMap {\n return this.#olMap;\n }\n\n /**\n * Returns the current view of the OpenLayers map.\n */\n get olView(): OlView {\n return this.#olView.value;\n }\n\n /**\n * TODO: Can be removed once the LayerFactory is the only supported way of constructing a layer.\n *\n * @internal\n */\n get [LAYER_DEPS](): LayerDependencies {\n return this.#layerDeps;\n }\n\n /**\n * Changes the current scale of the map to the given value.\n *\n * Internally, this computes a new zoom level / resolution based on the scale\n * and the current center.\n * The new resolution is then applied to the current `olView`.\n *\n * See also {@link scale}.\n */\n setScale(newScale: number): void {\n const view = this.olView;\n const projection = this.projection;\n const center = this.center;\n if (!center) {\n return;\n }\n\n const mpu = projection.getMetersPerUnit() ?? 1;\n const resolution = INCHES_PER_METRE * DEFAULT_DPI * mpu;\n const pointResolution = newScale / getPointResolution(projection, resolution, center);\n view.setResolution(pointResolution);\n }\n\n /**\n * Creates a highlight at the given targets.\n *\n * A highlight is a temporary graphic on the map that calls attention to a point or an area.\n *\n * Call `destroy()` on the returned highlight object to remove the highlight again.\n */\n highlight(geometries: DisplayTarget[], options?: HighlightOptions | undefined): Highlight {\n return this.#highlights.addHighlight(geometries, options);\n }\n\n /**\n * Zooms to the given targets.\n */\n zoom(geometries: DisplayTarget[], options?: ZoomOptions | undefined): void {\n this.#highlights.zoomToHighlight(geometries, options);\n }\n\n /**\n * Creates a highlight and zooms to the given targets.\n *\n * See also {@link highlight} and {@link zoom}.\n */\n highlightAndZoom(geometries: DisplayTarget[], options?: HighlightZoomOptions) {\n return this.#highlights.addHighlightAndZoom(geometries, options ?? {});\n }\n\n /**\n * Removes any existing highlights from the map.\n */\n removeHighlights() {\n this.#highlights.clearHighlight();\n }\n\n /**\n * Returns a promise that resolves when the map has mounted in the DOM.\n */\n whenDisplayed(): Promise<void> {\n if (this.#isDestroyed) {\n return Promise.reject(new Error(\"Map model was destroyed.\"));\n }\n if (this.#displayStatus === \"error\") {\n return Promise.reject(new Error(`Failed to initialize map.`));\n }\n if (this.#displayStatus === \"ready\") {\n return Promise.resolve();\n }\n return (this.#displayWaiter ??= createManualPromise()).promise;\n }\n\n /**\n * Waits for the map to be displayed and then initializes the view (if necessary).\n *\n * May simply resolve when done, or throw an error when a problem occurs.\n * AbortError is thrown when cancelled via `this.#abortController`, for example\n * when the map model is destroyed before it has ever been displayed.\n */\n async #initializeView(): Promise<void> {\n try {\n await waitForMapSize(this.olMap, this.#abortController.signal); // may throw on cancel\n } catch (e) {\n if (isAbortError(e)) {\n throw e;\n }\n throw new Error(`Failed to wait for the map to be displayed.`, { cause: e });\n }\n\n try {\n const olMap = this.#olMap;\n const view = olMap.getView();\n\n if (this.#initialExtent.value) {\n // Initial extent was set from the outside. We simply ensure that it gets displayed by the map.\n const extent = this.#initialExtent.value;\n const olExtent = [extent.xMin, extent.yMin, extent.xMax, extent.yMax];\n\n const olCenter = getCenter(olExtent);\n const resolution = view.getResolutionForExtent(olExtent);\n LOG.debug(`Applying initial extent`, extent);\n LOG.debug(` Computed center:`, olCenter);\n LOG.debug(` Computed resolution:`, resolution);\n\n view.setCenter(olCenter);\n view.setResolution(resolution);\n } else {\n // Initial extent was NOT set from the outside.\n // We detect whatever the view is displaying and consider it to be the initial extent.\n const olExtent = view.calculateExtent();\n const [xMin = 0, yMin = 0, xMax = 0, yMax = 0] = olExtent;\n const extent: ExtentConfig = { xMin, yMin, xMax, yMax };\n LOG.debug(`Detected initial extent`, extent);\n\n this.#initialExtent.value = extent;\n }\n } catch (e) {\n throw new Error(`Failed to apply the initial extent.`, { cause: e });\n }\n }\n\n /**\n * Subscribes to the OpenLayers loading state.\n */\n #watchLoadingState() {\n this.#loadStartEventHandler = this.#olMap.on(\"loadstart\", () => {\n this.#olLoading.value = true;\n });\n this.#loadEndEventHandler = this.#olMap.on(\"loadend\", () => {\n this.#olLoading.value = false;\n });\n }\n}\n\ninterface ViewBindings {\n resolution: ReadonlyReactive<number | undefined>;\n center: ReadonlyReactive<Coordinate | undefined>;\n zoom: ReadonlyReactive<number | undefined>;\n projection: Projection; // not reactive (change view to change projection)\n}\n\nfunction createViewBindings(view: OlView): ViewBindings {\n return {\n resolution: synchronized(\n () => view.getResolution(),\n (cb) => {\n const key = view.on(\"change:resolution\", cb);\n return () => unByKey(key);\n }\n ),\n center: synchronized(\n () => view.getCenter(),\n (cb) => {\n const key = view.on(\"change:center\", cb);\n return () => unByKey(key);\n }\n ),\n zoom: synchronized(\n () => view.getZoom(),\n (cb) => {\n const key = view.on(\"change:resolution\", cb);\n return () => unByKey(key);\n }\n ),\n projection: view.getProjection()\n };\n}\n\nfunction waitForMapSize(olMap: OlMap, signal: AbortSignal): Promise<void> {\n const promise = new Promise<void>((resolve, reject) => {\n let eventKey: EventsKey | undefined;\n\n function checkSize() {\n const currentSize = olMap.getSize() ?? [];\n const [width = 0, height = 0] = currentSize;\n if (currentSize && width > 0 && height > 0) {\n finish();\n }\n }\n\n function onAbort() {\n finish(createAbortError());\n }\n\n function finish(error?: Error | undefined) {\n if (eventKey) {\n unByKey(eventKey);\n eventKey = undefined;\n }\n signal.removeEventListener(\"abort\", onAbort);\n\n if (error) {\n reject(error);\n } else {\n resolve(wait(25)); // Give the map some time to render\n }\n }\n\n if (signal.aborted) {\n finish(createAbortError());\n return;\n }\n\n signal.addEventListener(\"abort\", onAbort);\n eventKey = olMap.on(\"change:size\", checkSize);\n });\n return promise;\n}\n\nfunction wait(milliseconds: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, milliseconds));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAkCA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,cAAc,IAAA,GAAO,IAAA;AAC3B,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package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/map",
4
- "version": "1.3.0-dev-map-loading.20260202144650",
4
+ "version": "1.3.0-dev-attributions.20260212134347",
5
5
  "description": "This package integrates OpenLayers maps into an open pioneer trails application.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,19 +14,21 @@
14
14
  "directory": "src/packages/map"
15
15
  },
16
16
  "dependencies": {
17
- "@chakra-ui/react": "^3.31.0",
18
- "@open-pioneer/core": "^4.4.0",
19
- "@open-pioneer/http": "^4.4.0",
20
- "@open-pioneer/react-utils": "^4.4.0",
21
- "@open-pioneer/runtime": "^4.4.0",
17
+ "@chakra-ui/react": "^3.32.0",
18
+ "@conterra/reactivity-core": "^0.8.1",
19
+ "@conterra/reactivity-events": "^0.8.1",
20
+ "@esri/arcgis-html-sanitizer": "^4.1.0",
21
+ "@open-pioneer/core": "4.5.0-dev.20260211105402",
22
+ "@open-pioneer/http": "4.5.0-dev.20260211105402",
23
+ "@open-pioneer/react-utils": "4.5.0-dev.20260211105402",
24
+ "@open-pioneer/reactivity": "4.5.0-dev.20260211105402",
25
+ "@open-pioneer/runtime": "4.5.0-dev.20260211105402",
22
26
  "ol": "^10.7.0",
23
27
  "proj4": "^2.20.2",
24
- "react": "^19.2.3",
25
- "react-dom": "^19.2.3",
28
+ "react-dom": "^19.2.4",
26
29
  "react-use": "^17.6.0",
27
- "uuid": "^13.0.0",
28
- "@conterra/reactivity-core": "^0.8.1",
29
- "@conterra/reactivity-events": "^0.8.1"
30
+ "react": "^19.2.4",
31
+ "uuid": "^13.0.0"
30
32
  },
31
33
  "exports": {
32
34
  "./package.json": "./package.json",
package/ui/MapAnchor.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { Box } from '@chakra-ui/react';
3
- import { useCommonComponentProps } from '@open-pioneer/react-utils';
3
+ import { useCommonComponentProps, mergeChakraProps } from '@open-pioneer/react-utils';
4
4
  import { useMemo } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { computeMapAnchorStyles } from './computeMapAnchorStyles.js';
@@ -11,14 +11,17 @@ function MapAnchor(props) {
11
11
  const { position = defaultPosition, children, horizontalGap, verticalGap } = props;
12
12
  const { containerProps } = useCommonComponentProps("map-anchor", props);
13
13
  const { mapAnchorsHost } = useMapContainerContext();
14
- const styleProps = useMemo(
14
+ const css = useMemo(
15
15
  () => computeMapAnchorStyles(position, horizontalGap, verticalGap),
16
16
  [position, horizontalGap, verticalGap]
17
17
  );
18
- return createPortal(
19
- /* @__PURE__ */ jsx(Box, { ...containerProps, ...styleProps, children }),
20
- mapAnchorsHost
18
+ const boxProps = mergeChakraProps(
19
+ {
20
+ css
21
+ },
22
+ containerProps
21
23
  );
24
+ return createPortal(/* @__PURE__ */ jsx(Box, { ...boxProps, children }), mapAnchorsHost);
22
25
  }
23
26
 
24
27
  export { MapAnchor };
@@ -1 +1 @@
1
- {"version":3,"file":"MapAnchor.js","sources":["MapAnchor.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box } from \"@chakra-ui/react\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { ReactNode, useMemo } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { computeMapAnchorStyles } from \"./computeMapAnchorStyles\";\nimport { useMapContainerContext } from \"./MapContainerContext\";\n\n/**\n * The position of an anchor on the map.\n *\n * This is either a predefined position (like a corner) or a completely manual position.\n *\n * @group UI Components and Hooks\n */\nexport type MapAnchorPosition =\n | \"manual\"\n | \"top-left\"\n | \"top-right\"\n | \"top-center\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"bottom-center\"\n | \"left-center\"\n | \"right-center\"\n | \"center\";\n\nconst defaultPosition: MapAnchorPosition = \"top-right\";\n\n/**\n * @group UI Components and Hooks\n */\nexport interface MapAnchorProps extends CommonComponentProps {\n /**\n * The position of the anchor container above the map.\n *\n * Use `manual` if you wish to position the anchor manually using absolute positioning.\n * This can be achieved by configuring a css class on the map anchor and using css properties like `left`, `top`, etc.\n *\n * @default \"top-right\"\n */\n position?: MapAnchorPosition;\n\n /**\n * Horizontal gap in pixel applied to anchor container.\n * Only interpreted if a non-manual position is used.\n *\n * @default 0\n */\n horizontalGap?: number;\n\n /**\n * Vertical gap in pixel applied to anchor container.\n * Only interpreted if a non-manual position is used.\n *\n * @default 0 (If positioned at the bottom, default verticalGap == `30`)\n */\n verticalGap?: number;\n\n children?: ReactNode;\n}\n\n/**\n * A map anchor is a layout component that sits on top of the map.\n *\n * It can be used to position widgets (such as zoom buttons) at a specific location.\n *\n * Map anchors respect the map's current _view padding_.\n *\n * @group UI Components and Hooks\n */\nexport function MapAnchor(props: MapAnchorProps): ReactNode {\n const { position = defaultPosition, children, horizontalGap, verticalGap } = props;\n const { containerProps } = useCommonComponentProps(\"map-anchor\", props);\n const { mapAnchorsHost } = useMapContainerContext();\n const styleProps = useMemo(\n () => computeMapAnchorStyles(position, horizontalGap, verticalGap),\n [position, horizontalGap, verticalGap]\n );\n\n return createPortal(\n <Box {...containerProps} {...styleProps}>\n {children}\n </Box>,\n mapAnchorsHost\n );\n}\n"],"names":[],"mappings":";;;;;;;;AA4BA,MAAM,eAAA,GAAqC,WAAA;AA4CpC,SAAS,UAAU,KAAA,EAAkC;AACxD,EAAA,MAAM,EAAE,QAAA,GAAW,eAAA,EAAiB,QAAA,EAAU,aAAA,EAAe,aAAY,GAAI,KAAA;AAC7E,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,uBAAA,CAAwB,cAAc,KAAK,CAAA;AACtE,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,sBAAA,EAAuB;AAClD,EAAA,MAAM,UAAA,GAAa,OAAA;AAAA,IACf,MAAM,sBAAA,CAAuB,QAAA,EAAU,aAAA,EAAe,WAAW,CAAA;AAAA,IACjE,CAAC,QAAA,EAAU,aAAA,EAAe,WAAW;AAAA,GACzC;AAEA,EAAA,OAAO,YAAA;AAAA,wBACF,GAAA,EAAA,EAAK,GAAG,cAAA,EAAiB,GAAG,YACxB,QAAA,EACL,CAAA;AAAA,IACA;AAAA,GACJ;AACJ;;;;"}
1
+ {"version":3,"file":"MapAnchor.js","sources":["MapAnchor.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, BoxProps } from \"@chakra-ui/react\";\nimport {\n CommonComponentProps,\n mergeChakraProps,\n useCommonComponentProps\n} from \"@open-pioneer/react-utils\";\nimport { ReactNode, useMemo } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { computeMapAnchorStyles } from \"./computeMapAnchorStyles\";\nimport { useMapContainerContext } from \"./MapContainerContext\";\n\n/**\n * The position of an anchor on the map.\n *\n * This is either a predefined position (like a corner) or a completely manual position.\n *\n * @group UI Components and Hooks\n */\nexport type MapAnchorPosition =\n | \"manual\"\n | \"top-left\"\n | \"top-right\"\n | \"top-center\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"bottom-center\"\n | \"left-center\"\n | \"right-center\"\n | \"center\";\n\nconst defaultPosition: MapAnchorPosition = \"top-right\";\n\n/**\n * @group UI Components and Hooks\n */\nexport interface MapAnchorProps extends CommonComponentProps {\n /**\n * The position of the anchor container above the map.\n *\n * Use `manual` if you wish to position the anchor manually using absolute positioning.\n * This can be achieved by configuring a css class on the map anchor and using css properties like `left`, `top`, etc.\n *\n * @default \"top-right\"\n */\n position?: MapAnchorPosition;\n\n /**\n * Horizontal gap in pixel applied to anchor container.\n * Only interpreted if a non-manual position is used.\n *\n * @default 0\n */\n horizontalGap?: number;\n\n /**\n * Vertical gap in pixel applied to anchor container.\n * Only interpreted if a non-manual position is used.\n *\n * @default 0 (If positioned at the bottom, default verticalGap == `30`)\n */\n verticalGap?: number;\n\n children?: ReactNode;\n}\n\n/**\n * A map anchor is a layout component that sits on top of the map.\n *\n * It can be used to position widgets (such as zoom buttons) at a specific location.\n *\n * Map anchors respect the map's current _view padding_.\n *\n * @group UI Components and Hooks\n */\nexport function MapAnchor(props: MapAnchorProps): ReactNode {\n const { position = defaultPosition, children, horizontalGap, verticalGap } = props;\n const { containerProps } = useCommonComponentProps(\"map-anchor\", props);\n const { mapAnchorsHost } = useMapContainerContext();\n const css = useMemo(\n () => computeMapAnchorStyles(position, horizontalGap, verticalGap),\n [position, horizontalGap, verticalGap]\n );\n\n const boxProps = mergeChakraProps<BoxProps>(\n {\n css\n },\n containerProps\n );\n return createPortal(<Box {...boxProps}>{children}</Box>, mapAnchorsHost);\n}\n"],"names":[],"mappings":";;;;;;;;AAgCA,MAAM,eAAA,GAAqC,WAAA;AA4CpC,SAAS,UAAU,KAAA,EAAkC;AACxD,EAAA,MAAM,EAAE,QAAA,GAAW,eAAA,EAAiB,QAAA,EAAU,aAAA,EAAe,aAAY,GAAI,KAAA;AAC7E,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,uBAAA,CAAwB,cAAc,KAAK,CAAA;AACtE,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,sBAAA,EAAuB;AAClD,EAAA,MAAM,GAAA,GAAM,OAAA;AAAA,IACR,MAAM,sBAAA,CAAuB,QAAA,EAAU,aAAA,EAAe,WAAW,CAAA;AAAA,IACjE,CAAC,QAAA,EAAU,aAAA,EAAe,WAAW;AAAA,GACzC;AAEA,EAAA,MAAM,QAAA,GAAW,gBAAA;AAAA,IACb;AAAA,MACI;AAAA,KACJ;AAAA,IACA;AAAA,GACJ;AACA,EAAA,OAAO,6BAAa,GAAA,CAAC,GAAA,EAAA,EAAK,GAAG,QAAA,EAAW,QAAA,EAAS,GAAQ,cAAc,CAAA;AAC3E;;;;"}
@@ -1,7 +1,8 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { chakra } from '@chakra-ui/react';
3
3
  import { createLogger } from '@open-pioneer/core';
4
- import { useCommonComponentProps } from '@open-pioneer/react-utils';
4
+ import { useCommonComponentProps, mergeChakraProps } from '@open-pioneer/react-utils';
5
+ import { useReactiveSnapshot } from '@open-pioneer/reactivity';
5
6
  import { sourceId$9 as sourceId } from '../_virtual/source-info.js';
6
7
  import { useRef, useState, useEffect, useMemo } from 'react';
7
8
  import { MapContainerContextProvider } from './MapContainerContext.js';
@@ -10,62 +11,56 @@ import { useMapModelValue } from './hooks/useMapModel.js';
10
11
  const LOG = createLogger(sourceId);
11
12
  function MapContainer(props) {
12
13
  const {
13
- viewPadding,
14
+ viewPadding: viewPaddingProp,
14
15
  viewPaddingChangeBehavior,
15
16
  children,
16
17
  role = "application",
17
18
  "aria-label": ariaLabel,
18
19
  "aria-labelledby": ariaLabelledBy,
19
20
  rootProps,
20
- containerProps
21
+ containerProps,
22
+ ...restProps
21
23
  } = props;
22
24
  const { containerProps: rootContainerProps } = useCommonComponentProps(
23
25
  "map-container-root",
24
- props
26
+ restProps
27
+ // hide role, aria label etc from helper
25
28
  );
26
29
  const mapContainer = useRef(null);
27
30
  const mapAnchorsHost = useRef(null);
28
31
  const map = useMapModelValue(props);
32
+ const viewPadding = useViewPadding(viewPaddingProp);
29
33
  const [ready, setReady] = useState(false);
30
- useEffect(() => {
31
- if (mapContainer.current) {
32
- const resource = registerMapTarget(map, mapContainer.current);
33
- return () => resource?.destroy();
34
- }
35
- }, [map]);
34
+ useMapContainerRegistration(mapContainer, map);
36
35
  useEffect(() => {
37
36
  setReady(true);
38
37
  }, []);
39
- const styleProps = useMemo(() => {
40
- return {
41
- height: "100%",
42
- position: "relative",
43
- // set css variables according to view padding
44
- "--map-padding-top": `${viewPadding?.top ?? 0}px`,
45
- "--map-padding-bottom": `${viewPadding?.bottom ?? 0}px`,
46
- "--map-padding-left": `${viewPadding?.left ?? 0}px`,
47
- "--map-padding-right": `${viewPadding?.right ?? 0}px`
48
- };
49
- }, [viewPadding]);
50
- return /* @__PURE__ */ jsxs(chakra.div, { ...rootProps, ...rootContainerProps, css: styleProps, children: [
51
- /* @__PURE__ */ jsx(
52
- chakra.div,
38
+ const css = useRootCss(viewPadding);
39
+ const mergedRootProps = useMemo(
40
+ () => mergeChakraProps({ css }, rootContainerProps, rootProps ?? {}),
41
+ [css, rootProps, rootContainerProps]
42
+ );
43
+ const mergedContainerProps = useMemo(
44
+ () => mergeChakraProps(
53
45
  {
54
- ...containerProps,
55
46
  className: "map-container",
56
- ref: mapContainer,
57
47
  role,
58
48
  "aria-label": ariaLabel,
59
49
  "aria-labelledby": ariaLabelledBy,
60
50
  h: "100%",
61
51
  w: "100%",
62
52
  tabIndex: 0
63
- }
53
+ },
54
+ containerProps ?? {}
64
55
  ),
56
+ [role, ariaLabel, ariaLabelledBy, containerProps]
57
+ );
58
+ return /* @__PURE__ */ jsxs(chakra.div, { ...mergedRootProps, children: [
59
+ /* @__PURE__ */ jsx(chakra.div, { ref: mapContainer, ...mergedContainerProps }),
65
60
  /* @__PURE__ */ jsx(chakra.div, { ref: mapAnchorsHost, className: "map-anchors", children: ready && map && /* @__PURE__ */ jsx(
66
61
  MapContainerReady,
67
62
  {
68
- olMap: map.olMap,
63
+ map,
69
64
  mapAnchorsHost: mapAnchorsHost.current,
70
65
  viewPadding,
71
66
  viewPaddingChangeBehavior,
@@ -76,27 +71,69 @@ function MapContainer(props) {
76
71
  }
77
72
  function MapContainerReady(props) {
78
73
  const {
79
- olMap,
74
+ map,
80
75
  mapAnchorsHost,
81
- viewPadding: viewPaddingProp,
76
+ viewPadding,
82
77
  viewPaddingChangeBehavior = "preserve-center",
83
78
  children
84
79
  } = props;
85
- const viewPadding = useMemo(() => {
80
+ useSyncViewPadding(viewPadding, viewPaddingChangeBehavior, map);
81
+ const mapContext = useMemo(() => {
82
+ return {
83
+ mapAnchorsHost
84
+ };
85
+ }, [mapAnchorsHost]);
86
+ return /* @__PURE__ */ jsx(MapContainerContextProvider, { value: mapContext, children });
87
+ }
88
+ function useMapContainerRegistration(mapContainer, map) {
89
+ useEffect(() => {
90
+ if (mapContainer.current) {
91
+ const resource = registerMapTarget(map, mapContainer.current);
92
+ return () => resource?.destroy();
93
+ }
94
+ }, [mapContainer, map]);
95
+ }
96
+ function useRootCss(viewPadding) {
97
+ return useMemo(() => {
98
+ return {
99
+ height: "100%",
100
+ position: "relative",
101
+ // set css variables according to view padding
102
+ "--map-padding-top": `${viewPadding.top}px`,
103
+ "--map-padding-bottom": `${viewPadding.bottom}px`,
104
+ "--map-padding-left": `${viewPadding.left}px`,
105
+ "--map-padding-right": `${viewPadding.right}px`
106
+ };
107
+ }, [viewPadding]);
108
+ }
109
+ function useViewPadding(viewPaddingProp) {
110
+ return useMemo(() => {
86
111
  return {
87
112
  left: viewPaddingProp?.left ?? 0,
88
113
  right: viewPaddingProp?.right ?? 0,
89
114
  top: viewPaddingProp?.top ?? 0,
90
115
  bottom: viewPaddingProp?.bottom ?? 0
91
116
  };
92
- }, [viewPaddingProp]);
117
+ }, [
118
+ viewPaddingProp?.left,
119
+ viewPaddingProp?.right,
120
+ viewPaddingProp?.top,
121
+ viewPaddingProp?.bottom
122
+ ]);
123
+ }
124
+ function useSyncViewPadding(viewPadding, viewPaddingChangeBehavior, map) {
125
+ const mapView = useReactiveSnapshot(() => map.olView, [map]);
93
126
  useEffect(() => {
94
- const mapView = olMap?.getView();
95
- if (!olMap || !mapView) {
127
+ const olMap = map.olMap;
128
+ if (!mapView) {
96
129
  return;
97
130
  }
98
- const oldCenter = mapView.getCenter();
99
131
  const oldPadding = fromOlPadding(mapView.padding);
132
+ const paddingNotChanged = isPaddingEqual(viewPadding, oldPadding);
133
+ if (paddingNotChanged) {
134
+ return;
135
+ }
136
+ const oldCenter = mapView.getCenter();
100
137
  const oldExtent = extentIncludingPadding(olMap, oldPadding);
101
138
  mapView.padding = toOlPadding(viewPadding);
102
139
  switch (viewPaddingChangeBehavior) {
@@ -114,13 +151,7 @@ function MapContainerReady(props) {
114
151
  break;
115
152
  }
116
153
  }
117
- }, [viewPadding, olMap, viewPaddingChangeBehavior]);
118
- const mapContext = useMemo(() => {
119
- return {
120
- mapAnchorsHost
121
- };
122
- }, [mapAnchorsHost]);
123
- return /* @__PURE__ */ jsx(MapContainerContextProvider, { value: mapContext, children });
154
+ }, [viewPadding, viewPaddingChangeBehavior, map, mapView]);
124
155
  }
125
156
  function registerMapTarget(mapModel, target) {
126
157
  const mapId = mapModel.id;
@@ -181,6 +212,9 @@ function toOlPadding(padding) {
181
212
  const { top, right, bottom, left } = padding;
182
213
  return [top, right, bottom, left];
183
214
  }
215
+ function isPaddingEqual(a, b) {
216
+ return a.top === b.top && a.right === b.right && a.bottom === b.bottom && a.left === b.left;
217
+ }
184
218
 
185
219
  export { MapContainer };
186
220
  //# sourceMappingURL=MapContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MapContainer.js","sources":["MapContainer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { BoxProps, chakra } from \"@chakra-ui/react\";\nimport { createLogger, Resource } from \"@open-pioneer/core\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport type OlMap from \"ol/Map\";\nimport { Extent } from \"ol/extent\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { MapModel, MapPadding } from \"../model/MapModel\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { MapModelProps, useMapModelValue } from \"./hooks/useMapModel\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * @group UI Components and Hooks\n */\nexport interface MapContainerProps extends CommonComponentProps, MapModelProps {\n /**\n * Sets the map's padding directly.\n * Do not use the view's padding property directly on the OL map.\n *\n * See: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)\n */\n viewPadding?: MapPadding | undefined;\n\n /**\n * Behavior performed by the map when the view padding changes.\n *\n * - `none`: Do nothing.\n * - `preserve-center`: Ensures that the center point remains the same by animating the view.\n * - `preserve-extent`: Ensures that the extent remains the same by zooming.\n *\n * @default \"preserve-center\"\n */\n viewPaddingChangeBehavior?: \"none\" | \"preserve-center\" | \"preserve-extent\";\n\n children?: ReactNode;\n\n /**\n * Optional role property.\n *\n * This property is directly applied to the map's container div element.\n *\n * @default \"application\"\n */\n role?: string;\n\n /**\n * Optional aria-labelledby property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-labelledby\"?: string;\n\n /**\n * Optional aria-label property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-label\"?: string;\n\n /**\n * Arbitrary html properties that will be applied to the map container's _root_ element.\n * This is the element that contains the map container and any UI elements (like map anchors, for example).\n *\n * Use these at your own risk since they may be overwritten by the map container root itself.\n *\n * Use cases: setting custom data attributes, registering custom event handlers, ...\n */\n rootProps?: BoxProps;\n\n /**\n * Arbitrary html properties that will be applied to the map container's element.\n * This is the element that _renders_ the OpenLayers map.\n *\n * Use these at your own risk since they may be overwritten by the map container itself.\n *\n * Use cases: setting custom data attributes, registering custom event handlers, ...\n */\n containerProps?: BoxProps;\n}\n\n/**\n * Displays the map with the given id.\n *\n * There can only be at most one MapContainer for every map.\n *\n * @group UI Components and Hooks\n */\nexport function MapContainer(props: MapContainerProps) {\n const {\n viewPadding,\n viewPaddingChangeBehavior,\n children,\n role = \"application\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n rootProps,\n containerProps\n } = props;\n const { containerProps: rootContainerProps } = useCommonComponentProps(\n \"map-container-root\",\n props\n );\n const mapContainer = useRef<HTMLDivElement>(null);\n const mapAnchorsHost = useRef<HTMLDivElement>(null);\n const map = useMapModelValue(props);\n\n const [ready, setReady] = useState(false);\n\n useEffect(() => {\n // Mount the map into the DOM\n if (mapContainer.current) {\n const resource = registerMapTarget(map, mapContainer.current);\n return () => resource?.destroy();\n }\n }, [map]);\n\n // Wait for mount to make sure that the map anchors host is available\n useEffect(() => {\n setReady(true);\n }, []);\n\n const styleProps = useMemo(() => {\n return {\n height: \"100%\",\n position: \"relative\",\n\n // set css variables according to view padding\n \"--map-padding-top\": `${viewPadding?.top ?? 0}px`,\n \"--map-padding-bottom\": `${viewPadding?.bottom ?? 0}px`,\n \"--map-padding-left\": `${viewPadding?.left ?? 0}px`,\n \"--map-padding-right\": `${viewPadding?.right ?? 0}px`\n };\n }, [viewPadding]);\n\n return (\n <chakra.div {...rootProps} {...rootContainerProps} css={styleProps}>\n {/* Used by open layers to mount the map. This node receives the keyboard focus when interacting with the map. */}\n <chakra.div\n {...containerProps}\n className=\"map-container\"\n ref={mapContainer}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n h=\"100%\"\n w=\"100%\"\n tabIndex={0}\n />\n\n {/* Contains user widgets (map anchors and raw children). These are separate from the map so they don't interfere with mouse/keyboard events. */}\n <chakra.div ref={mapAnchorsHost} className=\"map-anchors\">\n {ready && map && (\n <MapContainerReady\n olMap={map.olMap}\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n mapAnchorsHost={mapAnchorsHost.current!}\n viewPadding={viewPadding}\n viewPaddingChangeBehavior={viewPaddingChangeBehavior}\n >\n {children}\n </MapContainerReady>\n )}\n </chakra.div>\n </chakra.div>\n );\n}\n\n/**\n * This inner component is rendered when the map has been loaded.\n *\n * It provides the map instance and additional properties down the component tree.\n */\nfunction MapContainerReady(\n props: { olMap: OlMap; mapAnchorsHost: HTMLElement } & Omit<\n MapContainerProps,\n \"mapId\" | \"map\" | \"className\"\n >\n): ReactNode {\n const {\n olMap,\n mapAnchorsHost,\n viewPadding: viewPaddingProp,\n viewPaddingChangeBehavior = \"preserve-center\",\n children\n } = props;\n\n const viewPadding = useMemo<Required<MapPadding>>(() => {\n return {\n left: viewPaddingProp?.left ?? 0,\n right: viewPaddingProp?.right ?? 0,\n top: viewPaddingProp?.top ?? 0,\n bottom: viewPaddingProp?.bottom ?? 0\n };\n }, [viewPaddingProp]);\n\n // Apply view padding\n useEffect(() => {\n const mapView = olMap?.getView();\n if (!olMap || !mapView) {\n return;\n }\n\n const oldCenter = mapView.getCenter();\n const oldPadding = fromOlPadding(mapView.padding);\n const oldExtent = extentIncludingPadding(olMap, oldPadding);\n\n mapView.padding = toOlPadding(viewPadding);\n switch (viewPaddingChangeBehavior) {\n case \"preserve-center\":\n mapView.animate({ center: oldCenter, duration: 300 });\n break;\n case \"preserve-extent\": {\n if (oldExtent) {\n mapView.animate({\n center: oldCenter,\n resolution: mapView.getResolutionForExtent(oldExtent),\n duration: 300\n });\n }\n break;\n }\n case \"none\":\n }\n }, [viewPadding, olMap, viewPaddingChangeBehavior]);\n\n const mapContext = useMemo((): MapContainerContextType => {\n return {\n mapAnchorsHost\n };\n }, [mapAnchorsHost]);\n return <MapContainerContextProvider value={mapContext}>{children}</MapContainerContextProvider>;\n}\n\nfunction registerMapTarget(mapModel: MapModel, target: HTMLDivElement): Resource | undefined {\n const mapId = mapModel.id;\n const olMap = mapModel.olMap;\n if (olMap.getTarget()) {\n LOG.error(\n `Failed to display the map: the map already has a target. There may be more than one <MapContainer />.`\n );\n return undefined;\n }\n\n LOG.isDebug() && LOG.debug(`Setting target of map '${mapId}':`, target);\n if (!(\"keyboardEventTarget_\" in olMap)) {\n throw new Error(\n \"Internal error: failed to override keyboard event target. The property is no longer present.\"\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = target;\n olMap.setTarget(target);\n\n let unregistered = false;\n return {\n destroy() {\n if (!unregistered) {\n LOG.isDebug() && LOG.debug(`Removing target of map '${mapId}':`, target);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = undefined;\n olMap.setTarget(undefined);\n unregistered = true;\n }\n }\n };\n}\n\n/**\n * Returns the extent visible in the non-padded region of the map.\n */\nfunction extentIncludingPadding(map: OlMap, padding: Required<MapPadding>): Extent | undefined {\n const size = map.getSize();\n if (!size || size.length < 2) {\n return undefined;\n }\n\n const [width, height] = size as [number, number];\n const bottomLeft = map.getCoordinateFromPixel([padding.left, padding.bottom]);\n const topRight = map.getCoordinateFromPixel([\n Math.max(0, width - padding.right),\n Math.max(0, height - padding.top)\n ]);\n if (!bottomLeft || !topRight) {\n return undefined;\n }\n\n const [xmin, ymin] = bottomLeft;\n const [xmax, ymax] = topRight;\n return [xmin, ymin, xmax, ymax] as Extent;\n}\n\nfunction fromOlPadding(padding: number[] | undefined): Required<MapPadding> {\n // top, right, bottom, left\n return {\n top: padding?.[0] ?? 0,\n right: padding?.[1] ?? 0,\n bottom: padding?.[2] ?? 0,\n left: padding?.[3] ?? 0\n };\n}\n\nfunction toOlPadding(padding: Required<MapPadding>): number[] {\n // top, right, bottom, left\n const { top, right, bottom, left } = padding;\n return [top, right, bottom, left];\n}\n"],"names":[],"mappings":";;;;;;;;;AAaA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAgF1B,SAAS,aAAa,KAAA,EAA0B;AACnD,EAAA,MAAM;AAAA,IACF,WAAA;AAAA,IACA,yBAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA,GAAO,aAAA;AAAA,IACP,YAAA,EAAc,SAAA;AAAA,IACd,iBAAA,EAAmB,cAAA;AAAA,IACnB,SAAA;AAAA,IACA;AAAA,GACJ,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,cAAA,EAAgB,kBAAA,EAAmB,GAAI,uBAAA;AAAA,IAC3C,oBAAA;AAAA,IACA;AAAA,GACJ;AACA,EAAA,MAAM,YAAA,GAAe,OAAuB,IAAI,CAAA;AAChD,EAAA,MAAM,cAAA,GAAiB,OAAuB,IAAI,CAAA;AAClD,EAAA,MAAM,GAAA,GAAM,iBAAiB,KAAK,CAAA;AAElC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,KAAK,CAAA;AAExC,EAAA,SAAA,C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A,MAAM,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,UAAA;AACrB,EAAA,MAAM,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,QAAA;AACrB,EAAA,OAAO,CAAC,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA;AAClC;AAEA,SAAS,cAAc,OAAA,EAAqD;AAExE,EAAA,OAAO;AAAA,IACH,GAAA,EAAK,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACrB,KAAA,EAAO,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACvB,MAAA,EAAQ,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACxB,IAAA,EAAM,OAAA,GAAU,CAAC,CAAA,IAAK;AAAA,GAC1B;AACJ;AAEA,SAAS,YAAY,OAAA,EAAyC;AAE1D,EAAA,MAAM,EAAE,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,MAAK,GAAI,OAAA;AACrC,EAAA,OAAO,CAAC,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,IAAI,CAAA;AACpC;;;;"}
1
+ {"version":3,"file":"MapContainer.js","sources":["MapContainer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { BoxProps, chakra, SystemStyleObject } from \"@chakra-ui/react\";\nimport { createLogger, Resource } from \"@open-pioneer/core\";\nimport {\n CommonComponentProps,\n mergeChakraProps,\n useCommonComponentProps\n} from \"@open-pioneer/react-utils\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport type OlMap from \"ol/Map\";\nimport { Extent } from \"ol/extent\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ReactNode, RefObject, useEffect, useMemo, useRef, useState } from \"react\";\nimport { MapModel, MapPadding } from \"../model/MapModel\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { MapModelProps, useMapModelValue } from \"./hooks/useMapModel\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * @group UI Components and Hooks\n */\nexport interface MapContainerProps extends CommonComponentProps, MapModelProps {\n /**\n * Sets the map's padding directly.\n * Do not use the view's padding property directly on the OL map.\n *\n * See: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)\n */\n viewPadding?: MapPadding | undefined;\n\n /**\n * Behavior performed by the map when the view padding changes.\n *\n * - `none`: Do nothing.\n * - `preserve-center`: Ensures that the center point remains the same by animating the view.\n * - `preserve-extent`: Ensures that the extent remains the same by zooming.\n *\n * @default \"preserve-center\"\n */\n viewPaddingChangeBehavior?: \"none\" | \"preserve-center\" | \"preserve-extent\";\n\n children?: ReactNode;\n\n /**\n * Optional role property.\n *\n * This property is directly applied to the map's container div element.\n *\n * @default \"application\"\n */\n role?: string;\n\n /**\n * Optional aria-labelledby property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-labelledby\"?: string;\n\n /**\n * Optional aria-label property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-label\"?: string;\n\n /**\n * Arbitrary html properties that will be applied to the map container's _root_ element.\n * This is the element that contains the map container and any UI elements (like map anchors, for example).\n *\n * Use these at your own risk since they may be overwritten by the map container root itself.\n *\n * Use cases: setting custom data attributes, registering custom event handlers, ...\n */\n rootProps?: BoxProps;\n\n /**\n * Arbitrary html properties that will be applied to the map container's element.\n * This is the element that _renders_ the OpenLayers map.\n *\n * Use these at your own risk since they may be overwritten by the map container itself.\n *\n * Use cases: setting custom data attributes, registering custom event handlers, ...\n */\n containerProps?: BoxProps;\n}\n\n/**\n * Displays the map with the given id.\n *\n * There can only be at most one MapContainer for every map.\n *\n * @group UI Components and Hooks\n */\nexport function MapContainer(props: MapContainerProps) {\n const {\n viewPadding: viewPaddingProp,\n viewPaddingChangeBehavior,\n children,\n role = \"application\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n rootProps,\n containerProps,\n ...restProps\n } = props;\n const { containerProps: rootContainerProps } = useCommonComponentProps(\n \"map-container-root\",\n restProps // hide role, aria label etc from helper\n );\n const mapContainer = useRef<HTMLDivElement>(null);\n const mapAnchorsHost = useRef<HTMLDivElement>(null);\n const map = useMapModelValue(props);\n const viewPadding = useViewPadding(viewPaddingProp);\n const [ready, setReady] = useState(false);\n\n // Register as renderer for map model\n useMapContainerRegistration(mapContainer, map);\n\n // Wait for mount to make sure that the map anchors host is available\n useEffect(() => {\n setReady(true);\n }, []);\n\n const css = useRootCss(viewPadding);\n const mergedRootProps = useMemo(\n () => mergeChakraProps<BoxProps>({ css }, rootContainerProps, rootProps ?? {}),\n [css, rootProps, rootContainerProps]\n );\n const mergedContainerProps = useMemo(\n () =>\n mergeChakraProps<BoxProps>(\n {\n className: \"map-container\",\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n h: \"100%\",\n w: \"100%\",\n tabIndex: 0\n },\n containerProps ?? {}\n ),\n [role, ariaLabel, ariaLabelledBy, containerProps]\n );\n return (\n <chakra.div {...mergedRootProps}>\n {/* Used by open layers to mount the map. This node receives the keyboard focus when interacting with the map. */}\n <chakra.div ref={mapContainer} {...mergedContainerProps} />\n\n {/* Contains user widgets (map anchors and raw children). These are separate from the map so they don't interfere with mouse/keyboard events. */}\n <chakra.div ref={mapAnchorsHost} className=\"map-anchors\">\n {ready && map && (\n <MapContainerReady\n map={map}\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n mapAnchorsHost={mapAnchorsHost.current!}\n viewPadding={viewPadding}\n viewPaddingChangeBehavior={viewPaddingChangeBehavior}\n >\n {children}\n </MapContainerReady>\n )}\n </chakra.div>\n </chakra.div>\n );\n}\n\n/**\n * This inner component is rendered when the map has been loaded.\n *\n * It provides the map instance and additional properties down the component tree.\n */\nfunction MapContainerReady(\n props: {\n map: MapModel;\n mapAnchorsHost: HTMLElement;\n viewPadding: Required<MapPadding>;\n } & Omit<MapContainerProps, \"mapId\" | \"map\" | \"className\">\n): ReactNode {\n const {\n map,\n mapAnchorsHost,\n viewPadding,\n viewPaddingChangeBehavior = \"preserve-center\",\n children\n } = props;\n\n // Apply view padding\n useSyncViewPadding(viewPadding, viewPaddingChangeBehavior, map);\n\n const mapContext = useMemo((): MapContainerContextType => {\n return {\n mapAnchorsHost\n };\n }, [mapAnchorsHost]);\n return <MapContainerContextProvider value={mapContext}>{children}</MapContainerContextProvider>;\n}\n\n/**\n * Registers the map container as the map's renderer.\n * This can only be done once at a time: there cannot be two renderers for the same map model.\n */\nfunction useMapContainerRegistration(\n mapContainer: RefObject<HTMLDivElement | null>,\n map: MapModel\n) {\n useEffect(() => {\n // Mount the map into the DOM\n if (mapContainer.current) {\n const resource = registerMapTarget(map, mapContainer.current);\n return () => resource?.destroy();\n }\n }, [mapContainer, map]);\n}\n\n/**\n * Custom CSS rules for the root element.\n */\nfunction useRootCss(viewPadding: Required<MapPadding>) {\n return useMemo((): SystemStyleObject => {\n return {\n height: \"100%\",\n position: \"relative\",\n\n // set css variables according to view padding\n \"--map-padding-top\": `${viewPadding.top}px`,\n \"--map-padding-bottom\": `${viewPadding.bottom}px`,\n \"--map-padding-left\": `${viewPadding.left}px`,\n \"--map-padding-right\": `${viewPadding.right}px`\n };\n }, [viewPadding]);\n}\n\n/**\n * Normalizes the view padding property.\n */\nfunction useViewPadding(viewPaddingProp: MapPadding | undefined): Required<MapPadding> {\n return useMemo<Required<MapPadding>>(() => {\n return {\n left: viewPaddingProp?.left ?? 0,\n right: viewPaddingProp?.right ?? 0,\n top: viewPaddingProp?.top ?? 0,\n bottom: viewPaddingProp?.bottom ?? 0\n };\n }, [\n viewPaddingProp?.left,\n viewPaddingProp?.right,\n viewPaddingProp?.top,\n viewPaddingProp?.bottom\n ]);\n}\n\n/**\n * Applies the current view padding to the view.\n */\nfunction useSyncViewPadding(\n viewPadding: Required<MapPadding>,\n viewPaddingChangeBehavior: MapContainerProps[\"viewPaddingChangeBehavior\"],\n map: MapModel\n) {\n const mapView = useReactiveSnapshot(() => map.olView, [map]);\n useEffect(() => {\n const olMap = map.olMap;\n if (!mapView) {\n return;\n }\n\n const oldPadding = fromOlPadding(mapView.padding);\n const paddingNotChanged = isPaddingEqual(viewPadding, oldPadding);\n if (paddingNotChanged) {\n return;\n }\n\n const oldCenter = mapView.getCenter();\n const oldExtent = extentIncludingPadding(olMap, oldPadding);\n mapView.padding = toOlPadding(viewPadding);\n switch (viewPaddingChangeBehavior) {\n case \"preserve-center\":\n mapView.animate({ center: oldCenter, duration: 300 });\n break;\n case \"preserve-extent\": {\n if (oldExtent) {\n mapView.animate({\n center: oldCenter,\n resolution: mapView.getResolutionForExtent(oldExtent),\n duration: 300\n });\n }\n break;\n }\n case \"none\":\n }\n }, [viewPadding, viewPaddingChangeBehavior, map, mapView]);\n}\n\nfunction registerMapTarget(mapModel: MapModel, target: HTMLDivElement): Resource | undefined {\n const mapId = mapModel.id;\n const olMap = mapModel.olMap;\n if (olMap.getTarget()) {\n LOG.error(\n `Failed to display the map: the map already has a target. There may be more than one <MapContainer />.`\n );\n return undefined;\n }\n\n LOG.isDebug() && LOG.debug(`Setting target of map '${mapId}':`, target);\n if (!(\"keyboardEventTarget_\" in olMap)) {\n throw new Error(\n \"Internal error: failed to override keyboard event target. The property is no longer present.\"\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = target;\n olMap.setTarget(target);\n\n let unregistered = false;\n return {\n destroy() {\n if (!unregistered) {\n LOG.isDebug() && LOG.debug(`Removing target of map '${mapId}':`, target);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = undefined;\n olMap.setTarget(undefined);\n unregistered = true;\n }\n }\n };\n}\n\n/**\n * Returns the extent visible in the non-padded region of the map.\n */\nfunction extentIncludingPadding(map: OlMap, padding: Required<MapPadding>): Extent | undefined {\n const size = map.getSize();\n if (!size || size.length < 2) {\n return undefined;\n }\n\n const [width, height] = size as [number, number];\n const bottomLeft = map.getCoordinateFromPixel([padding.left, padding.bottom]);\n const topRight = map.getCoordinateFromPixel([\n Math.max(0, width - padding.right),\n Math.max(0, height - padding.top)\n ]);\n if (!bottomLeft || !topRight) {\n return undefined;\n }\n\n const [xmin, ymin] = bottomLeft;\n const [xmax, ymax] = topRight;\n return [xmin, ymin, xmax, ymax] as Extent;\n}\n\nfunction fromOlPadding(padding: number[] | undefined): Required<MapPadding> {\n // top, right, bottom, left\n return {\n top: padding?.[0] ?? 0,\n right: padding?.[1] ?? 0,\n bottom: padding?.[2] ?? 0,\n left: padding?.[3] ?? 0\n };\n}\n\nfunction toOlPadding(padding: Required<MapPadding>): number[] {\n // top, right, bottom, left\n const { top, right, bottom, left } = padding;\n return [top, right, bottom, left];\n}\n\nfunction isPaddingEqual(a: Required<MapPadding>, b: Required<MapPadding>): boolean {\n return a.top === b.top && a.right === b.right && a.bottom === b.bottom && a.left === b.left;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAkBA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAgF1B,SAAS,aAAa,KAAA,EAA0B;AACnD,EAAA,MAAM;AAAA,IACF,WAAA,EAAa,eAAA;AAAA,IACb,yBAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA,GAAO,aAAA;AAAA,IACP,YAAA,EAAc,SAAA;AAAA,IACd,iBAAA,EAAmB,cAAA;AAAA,IACnB,SAAA;AAAA,IACA,cAAA;AAAA,IACA,GAAG;AAAA,GACP,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,cAAA,EAAgB,kBAAA,EAAmB,GAAI,uBAAA;AAAA,IAC3C,oBAAA;AAAA,IACA;AAAA;AAAA,GACJ;AACA,EAAA,MAAM,YAAA,GAAe,OAAuB,IAAI,CAAA;AAChD,EAAA,MAAM,cAAA,GAAiB,OAAuB,IAAI,CAAA;AAClD,EAAA,MAAM,GAAA,GAAM,iBAAiB,KAAK,CAAA;AAClC,EAA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AAA,EAAK,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACrB,KAAA,EAAO,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACvB,MAAA,EAAQ,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACxB,IAAA,EAAM,OAAA,GAAU,CAAC,CAAA,IAAK;AAAA,GAC1B;AACJ;AAEA,SAAS,YAAY,OAAA,EAAyC;AAE1D,EAAA,MAAM,EAAE,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,MAAK,GAAI,OAAA;AACrC,EAAA,OAAO,CAAC,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,IAAI,CAAA;AACpC;AAEA,SAAS,cAAA,CAAe,GAAyB,CAAA,EAAkC;AAC/E,EAAA,OAAO,CAAA,CAAE,GAAA,KAAQ,CAAA,CAAE,GAAA,IAAO,EAAE,KAAA,KAAU,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,MAAA,KAAW,CAAA,CAAE,MAAA,IAAU,CAAA,CAAE,SAAS,CAAA,CAAE,IAAA;AAC3F;;;;"}
@@ -0,0 +1,11 @@
1
+ import { AttributionLike } from "ol/source/Source";
2
+ /**
3
+ * Sanitizes the given raw html string.
4
+ *
5
+ * The result is safe to use as raw HTML in properties like `innerHTML`.
6
+ */
7
+ export declare function sanitizeHtml(rawHtml: string): string;
8
+ /**
9
+ * Sanitizes an OpenLayers AttributionLike option.
10
+ */
11
+ export declare function sanitizeAttributions(attributions: AttributionLike | undefined): AttributionLike | undefined;
@@ -0,0 +1,34 @@
1
+ import { Sanitizer } from '@esri/arcgis-html-sanitizer';
2
+
3
+ const sanitizer = new Sanitizer();
4
+ function sanitizeHtml(rawHtml) {
5
+ return sanitizer.sanitize(rawHtml);
6
+ }
7
+ function sanitizeAttributions(attributions) {
8
+ if (!attributions) {
9
+ return attributions;
10
+ }
11
+ if (typeof attributions === "function") {
12
+ return function sanitizedAttributionFunction(...args) {
13
+ return sanitizeAttributionItems(attributions(...args));
14
+ };
15
+ }
16
+ return sanitizeAttributionItems(attributions);
17
+ }
18
+ function sanitizeAttributionItems(items) {
19
+ if (typeof items === "string") {
20
+ return sanitizeHtml(items);
21
+ }
22
+ if (Array.isArray(items)) {
23
+ return items.map((item) => {
24
+ if (typeof item === "string") {
25
+ return sanitizeHtml(item);
26
+ }
27
+ throw new Error("Expected a string");
28
+ });
29
+ }
30
+ throw new Error("Expected a string or an array of strings");
31
+ }
32
+
33
+ export { sanitizeAttributions };
34
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.js","sources":["sanitize.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Sanitizer } from \"@esri/arcgis-html-sanitizer\";\nimport { AttributionLike } from \"ol/source/Source\";\n\nconst sanitizer = new Sanitizer();\n\n/**\n * Sanitizes the given raw html string.\n *\n * The result is safe to use as raw HTML in properties like `innerHTML`.\n */\nexport function sanitizeHtml(rawHtml: string): string {\n return sanitizer.sanitize(rawHtml);\n}\n\n/**\n * Sanitizes an OpenLayers AttributionLike option.\n */\nexport function sanitizeAttributions(\n attributions: AttributionLike | undefined\n): AttributionLike | undefined {\n if (!attributions) {\n return attributions;\n }\n if (typeof attributions === \"function\") {\n return function sanitizedAttributionFunction(...args) {\n return sanitizeAttributionItems(attributions(...args));\n };\n }\n return sanitizeAttributionItems(attributions);\n}\n\nfunction sanitizeAttributionItems(items: string | string[]): string | string[] {\n if (typeof items === \"string\") {\n return sanitizeHtml(items);\n }\n if (Array.isArray(items)) {\n return items.map((item) => {\n if (typeof item === \"string\") {\n return sanitizeHtml(item);\n }\n throw new Error(\"Expected a string\");\n });\n }\n throw new Error(\"Expected a string or an array of strings\");\n}\n"],"names":[],"mappings":";;AAKA,MAAM,SAAA,GAAY,IAAI,SAAA,EAAU;AAOzB,SAAS,aAAa,OAAA,EAAyB;AAClD,EAAA,OAAO,SAAA,CAAU,SAAS,OAAO,CAAA;AACrC;AAKO,SAAS,qBACZ,YAAA,EAC2B;AAC3B,EAAA,IAAI,CAAC,YAAA,EAAc;AACf,IAAA,OAAO,YAAA;AAAA,EACX;AACA,EAAA,IAAI,OAAO,iBAAiB,UAAA,EAAY;AACpC,IAAA,OAAO,SAAS,gCAAgC,IAAA,EAAM;AAClD,MAAA,OAAO,wBAAA,CAAyB,YAAA,CAAa,GAAG,IAAI,CAAC,CAAA;AAAA,IACzD,CAAA;AAAA,EACJ;AACA,EAAA,OAAO,yBAAyB,YAAY,CAAA;AAChD;AAEA,SAAS,yBAAyB,KAAA,EAA6C;AAC3E,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC3B,IAAA,OAAO,aAAa,KAAK,CAAA;AAAA,EAC7B;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACtB,IAAA,OAAO,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,KAAS;AACvB,MAAA,IAAI,OAAO,SAAS,QAAA,EAAU;AAC1B,QAAA,OAAO,aAAa,IAAI,CAAA;AAAA,MAC5B;AACA,MAAA,MAAM,IAAI,MAAM,mBAAmB,CAAA;AAAA,IACvC,CAAC,CAAA;AAAA,EACL;AACA,EAAA,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAC9D;;;;"}