@open-pioneer/map 1.4.0-dev.20260727093741 → 1.4.0
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 +39 -21
- package/LayerFactory.d.ts +1 -1
- package/LayerFactory.js.map +1 -1
- package/MapRegistry.js.map +1 -1
- package/layers/AbstractLayer.d.ts +36 -3
- package/layers/AbstractLayer.js +123 -79
- package/layers/AbstractLayer.js.map +1 -1
- package/layers/AbstractLayerBase.d.ts +2 -2
- package/layers/AbstractLayerBase.js.map +1 -1
- package/layers/GroupLayer.d.ts +2 -1
- package/layers/GroupLayer.js +4 -1
- package/layers/GroupLayer.js.map +1 -1
- package/layers/SimpleLayer.d.ts +1 -1
- package/layers/SimpleLayer.js +1 -1
- package/layers/SimpleLayer.js.map +1 -1
- package/layers/WMSLayer.js +58 -10
- package/layers/WMSLayer.js.map +1 -1
- package/layers/WMTSLayer.d.ts +1 -1
- package/layers/WMTSLayer.js +10 -4
- package/layers/WMTSLayer.js.map +1 -1
- package/layers/group/GroupLayerCollection.d.ts +2 -2
- package/layers/group/GroupLayerCollection.js +1 -1
- package/layers/group/GroupLayerCollection.js.map +1 -1
- package/layers/shared/SublayerBaseType.d.ts +9 -0
- package/layers/shared/SublayersCollection.js.map +1 -1
- package/layers/shared/getRecursiveLayers.d.ts +1 -1
- package/layers/shared/getRecursiveLayers.js +12 -5
- package/layers/shared/getRecursiveLayers.js.map +1 -1
- package/layers/shared/internals.d.ts +3 -2
- package/layers/shared/internals.js +2 -1
- package/layers/shared/internals.js.map +1 -1
- package/layers/unions.js.map +1 -1
- package/layers/wms/WMSSublayer.d.ts +14 -1
- package/layers/wms/WMSSublayer.js +29 -2
- package/layers/wms/WMSSublayer.js.map +1 -1
- package/layers/wms/getAttributions.js.map +1 -1
- package/layers/wms/getLegendUrl.js.map +1 -1
- package/layers/wmts/getAttributions.js.map +1 -1
- package/layers/wmts/getLegendUrl.js.map +1 -1
- package/model/Highlights.js.map +1 -1
- package/model/LayerCollection.js.map +1 -1
- package/model/MapAttributions.js.map +1 -1
- package/model/MapModel.d.ts +5 -5
- package/model/MapModel.js +4 -4
- package/model/MapModel.js.map +1 -1
- package/model/Overlays.d.ts +2 -2
- package/model/Overlays.js +2 -2
- package/model/Overlays.js.map +1 -1
- package/model/createMapModel.js +2 -2
- package/model/createMapModel.js.map +1 -1
- package/model/getGeometries.js.map +1 -1
- package/package.json +7 -7
- package/ui/DefaultMapProvider.js.map +1 -1
- package/ui/MapAnchor.js.map +1 -1
- package/ui/MapContainer.js +1 -1
- package/ui/MapContainer.js.map +1 -1
- package/ui/MapContainerContext.js.map +1 -1
- package/ui/OverlaysRenderer.js.map +1 -1
- package/ui/computeMapAnchorStyles.js.map +1 -1
- package/ui/hooks/useMapModel.js +2 -2
- package/ui/hooks/useMapModel.js.map +1 -1
- package/utils/fetch.js.map +1 -1
- package/utils/geometry-utils.js.map +1 -1
- package/utils/ol-test-support.js.map +1 -1
- package/utils/projections.js.map +1 -1
- package/utils/sanitize.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMapModel.js","sources":["createMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { batch, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { createLogger } from \"@open-pioneer/core\";\nimport { HttpService } from \"@open-pioneer/http\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { MapBrowserEvent } from \"ol\";\nimport OlMap, { MapOptions } from \"ol/Map\";\nimport View, { ViewOptions } from \"ol/View\";\nimport { getCenter } from \"ol/extent\";\nimport { DragZoom, defaults as defaultInteractions } from \"ol/interaction\";\nimport TileLayer from \"ol/layer/Tile\";\nimport { Projection, get as getProjection } from \"ol/proj\";\nimport OSM from \"ol/source/OSM\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { INTERNAL_CONSTRUCTOR_TAG } from \"../utils/InternalConstructorTag\";\nimport { patchOpenLayersClassesForTesting } from \"../utils/ol-test-support\";\nimport { registerProjections } from \"../utils/projections\";\nimport { MapConfig } from \"./MapConfig\";\nimport { MapModel } from \"./MapModel\";\n\n/**\n * Register custom projection to the global proj4js definitions. User can select `EPSG:25832`\n * and `EPSG:25833` from the predefined projections without calling `registerProjections`.\n */\nregisterProjections({\n \"EPSG:25832\":\n \"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\",\n \"EPSG:25833\":\n \"+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\"\n});\nconst LOG = createLogger(sourceId);\n\nexport async function createMapModel(\n mapId: string,\n mapConfig: MapConfig,\n currentIntl: ReadonlyReactive<PackageIntl>,\n httpService: HttpService\n): Promise<MapModel> {\n return await new MapModelFactory(mapId, mapConfig, currentIntl, httpService).createMapModel();\n}\n\nclass MapModelFactory {\n #mapId: string;\n #mapConfig: MapConfig;\n #currentIntl: ReadonlyReactive<PackageIntl>;\n #httpService: HttpService;\n\n constructor(\n mapId: string,\n mapConfig: MapConfig,\n currentIntl: ReadonlyReactive<PackageIntl>,\n httpService: HttpService\n ) {\n this.#mapId = mapId;\n this.#mapConfig = mapConfig;\n this.#currentIntl = currentIntl;\n this.#httpService = httpService;\n }\n\n async createMapModel() {\n const mapId = this.#mapId;\n const mapConfig = this.#mapConfig;\n const { view: viewOption, ...rawOlOptions } = mapConfig.advanced ?? {};\n const showDefaultAttributions =\n mapConfig.showAttributions ?? (rawOlOptions.controls ? false : true);\n\n const mapOptions: MapOptions = {\n ...rawOlOptions\n };\n if (!mapOptions.controls) {\n mapOptions.controls = [];\n }\n if (!mapOptions.interactions) {\n const shiftCtrlKeysOnly = (\n mapBrowserEvent: MapBrowserEvent<KeyboardEvent | WheelEvent | PointerEvent>\n ) => {\n const originalEvent = mapBrowserEvent.originalEvent;\n return (originalEvent.metaKey || originalEvent.ctrlKey) && originalEvent.shiftKey;\n };\n\n // setting altShiftDragRotate to false disables or excludes DragRotate interaction\n mapOptions.interactions = defaultInteractions({\n dragPan: true,\n altShiftDragRotate: false,\n pinchRotate: false,\n mouseWheelZoom: true\n }).extend([new DragZoom({ out: true, condition: shiftCtrlKeysOnly })]);\n }\n\n const view = (await viewOption) ?? {};\n this.#initializeViewOptions(view);\n mapOptions.view = view instanceof View ? view : new View(view);\n\n if (!mapOptions.layers && !mapConfig.layers) {\n mapOptions.layers = [\n new TileLayer({\n source: new OSM()\n })\n ];\n }\n\n const initialView = mapConfig.initialView;\n const initialExtent = initialView?.kind === \"extent\" ? initialView.extent : undefined;\n\n LOG.debug(`Constructing OpenLayers map with options`, mapOptions);\n\n if (import.meta.env.VITEST) {\n patchOpenLayersClassesForTesting();\n }\n\n const olMap = new OlMap(mapOptions);\n const mapModel = new MapModel(\n {\n id: mapId,\n olMap,\n initialExtent,\n showDefaultAttributions,\n currentIntl: this.#currentIntl,\n httpService: this.#httpService\n },\n INTERNAL_CONSTRUCTOR_TAG\n );\n\n return batch(() => {\n try {\n if (mapConfig.layers) {\n for (const layerConfig of mapConfig.layers) {\n mapModel.layers.addLayer(layerConfig);\n }\n }\n return mapModel;\n } catch (e) {\n mapModel.destroy();\n throw e;\n }\n });\n }\n\n #initializeViewOptions(view: View | ViewOptions) {\n const mapId = this.#mapId;\n const mapConfig = this.#mapConfig;\n if (view instanceof View) {\n const warn = (prop: string) => {\n LOG.warn(\n `The advanced configuration for map id '${mapId}' has provided a fully constructed view instance: ${prop} cannot be applied.\\n` +\n `Use ViewOptions instead of a View instance.`\n );\n };\n\n if (mapConfig.projection != null) {\n warn(\"projection\");\n }\n if (mapConfig.initialView != null) {\n warn(\"initialView\");\n }\n return;\n }\n\n const projection = (view.projection = this.#initializeProjection(mapConfig.projection));\n const initialView = mapConfig.initialView;\n if (initialView) {\n switch (initialView.kind) {\n case \"position\":\n view.zoom = initialView.zoom;\n view.center = [initialView.center.x, initialView.center.y];\n break;\n case \"extent\": {\n /*\n OpenLayers does not support configuration of the initial map extent.\n The only relevant options here are center, zoom (and resolution).\n We must set those values because otherwise OpenLayers will not initialize layer sources.\n\n The actual initial extent is applied once tha map has loaded and its size is known.\n */\n const extent = initialView.extent;\n view.zoom = 0;\n view.center = [\n extent.xMin + (extent.xMax - extent.xMin) / 2,\n extent.yMin + (extent.yMax - extent.yMin) / 2\n ];\n break;\n }\n }\n } else {\n this.#setViewDefaults(view, projection);\n }\n }\n\n #setViewDefaults(view: ViewOptions, projection: Projection) {\n if (view.center == null) {\n const extent = projection.getExtent(); // can be null\n if (!extent) {\n LOG.warn(\n `Cannot set default center coordinate because the current projection has no associated extent.\\n` +\n `Try to configure 'initialView' explicity.`\n );\n } else {\n view.center = getCenter(extent);\n }\n }\n\n if (view.zoom == null || view.resolution == null) {\n view.zoom = 0;\n }\n }\n\n #initializeProjection(projectionOption: MapConfig[\"projection\"]) {\n if (projectionOption == null) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return getProjection(\"EPSG:3857\")!; // default OpenLayers projection\n }\n\n const projection = getProjection(projectionOption);\n if (!projection) {\n throw new Error(`Failed to retrieve projection for code '${projectionOption}'.`);\n }\n return projection;\n }\n}\n"],"names":["defaultInteractions","getProjection"],"mappings":";;;;;;;;;;;;;;;AAyBA,mBAAA,CAAoB;AAAA,EAChB,YAAA,EACI,oFAAA;AAAA,EACJ,YAAA,EACI;AACR,CAAC,CAAA;AACD,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,eAAsB,cAAA,CAClB,KAAA,EACA,SAAA,EACA,WAAA,EACA,WAAA,EACiB;AACjB,EAAA,OAAO,MAAM,IAAI,eAAA,CAAgB,KAAA,EAAO,WAAW,WAAA,EAAa,WAAW,EAAE,cAAA,EAAe;AAChG;AAEA,MAAM,eAAA,CAAgB;AAAA,EAClB,MAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAA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":"createMapModel.js","sources":["createMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { batch, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { createLogger } from \"@open-pioneer/core\";\nimport { HttpService } from \"@open-pioneer/http\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { MapBrowserEvent } from \"ol\";\nimport { getCenter } from \"ol/extent\";\nimport { DragZoom, defaults as defaultInteractions } from \"ol/interaction\";\nimport TileLayer from \"ol/layer/Tile\";\nimport OlMap, { MapOptions } from \"ol/Map\";\nimport { Projection, get as getProjection } from \"ol/proj\";\nimport OSM from \"ol/source/OSM\";\nimport View, { ViewOptions } from \"ol/View\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { INTERNAL_CONSTRUCTOR_TAG } from \"../utils/InternalConstructorTag\";\nimport { patchOpenLayersClassesForTesting } from \"../utils/ol-test-support\";\nimport { registerProjections } from \"../utils/projections\";\nimport { MapConfig } from \"./MapConfig\";\nimport { MapModel } from \"./MapModel\";\n\n/**\n * Register custom projection to the global proj4js definitions. User can select `EPSG:25832`\n * and `EPSG:25833` from the predefined projections without calling `registerProjections`.\n */\nregisterProjections({\n \"EPSG:25832\":\n \"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\",\n \"EPSG:25833\":\n \"+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\"\n});\nconst LOG = createLogger(sourceId);\n\nexport async function createMapModel(\n mapId: string,\n mapConfig: MapConfig,\n currentIntl: ReadonlyReactive<PackageIntl>,\n httpService: HttpService\n): Promise<MapModel> {\n return await new MapModelFactory(mapId, mapConfig, currentIntl, httpService).createMapModel();\n}\n\nclass MapModelFactory {\n #mapId: string;\n #mapConfig: MapConfig;\n #currentIntl: ReadonlyReactive<PackageIntl>;\n #httpService: HttpService;\n\n constructor(\n mapId: string,\n mapConfig: MapConfig,\n currentIntl: ReadonlyReactive<PackageIntl>,\n httpService: HttpService\n ) {\n this.#mapId = mapId;\n this.#mapConfig = mapConfig;\n this.#currentIntl = currentIntl;\n this.#httpService = httpService;\n }\n\n async createMapModel() {\n const mapId = this.#mapId;\n const mapConfig = this.#mapConfig;\n const { view: viewOption, ...rawOlOptions } = mapConfig.advanced ?? {};\n const showDefaultAttributions =\n mapConfig.showAttributions ?? (rawOlOptions.controls ? false : true);\n\n const mapOptions: MapOptions = {\n ...rawOlOptions\n };\n if (!mapOptions.controls) {\n mapOptions.controls = [];\n }\n if (!mapOptions.interactions) {\n const shiftCtrlKeysOnly = (\n mapBrowserEvent: MapBrowserEvent<KeyboardEvent | WheelEvent | PointerEvent>\n ) => {\n const originalEvent = mapBrowserEvent.originalEvent;\n return (originalEvent.metaKey || originalEvent.ctrlKey) && originalEvent.shiftKey;\n };\n\n // setting altShiftDragRotate to false disables or excludes DragRotate interaction\n mapOptions.interactions = defaultInteractions({\n dragPan: true,\n altShiftDragRotate: false,\n pinchRotate: false,\n mouseWheelZoom: true\n }).extend([new DragZoom({ out: true, condition: shiftCtrlKeysOnly })]);\n }\n\n const view = (await viewOption) ?? {};\n this.#initializeViewOptions(view);\n mapOptions.view = view instanceof View ? view : new View(view);\n\n if (!mapOptions.layers && !mapConfig.layers) {\n mapOptions.layers = [\n new TileLayer({\n source: new OSM()\n })\n ];\n }\n\n const initialView = mapConfig.initialView;\n const initialExtent = initialView?.kind === \"extent\" ? initialView.extent : undefined;\n\n LOG.debug(`Constructing OpenLayers map with options`, mapOptions);\n\n if (import.meta.env.VITEST) {\n patchOpenLayersClassesForTesting();\n }\n\n const olMap = new OlMap(mapOptions);\n const mapModel = new MapModel(\n {\n id: mapId,\n olMap,\n initialExtent,\n showDefaultAttributions,\n currentIntl: this.#currentIntl,\n httpService: this.#httpService\n },\n INTERNAL_CONSTRUCTOR_TAG\n );\n\n return batch(() => {\n try {\n if (mapConfig.layers) {\n for (const layerConfig of mapConfig.layers) {\n mapModel.layers.addLayer(layerConfig);\n }\n }\n return mapModel;\n } catch (e) {\n mapModel.destroy();\n throw e;\n }\n });\n }\n\n #initializeViewOptions(view: View | ViewOptions) {\n const mapId = this.#mapId;\n const mapConfig = this.#mapConfig;\n if (view instanceof View) {\n const warn = (prop: string) => {\n LOG.warn(\n `The advanced configuration for map id '${mapId}' has provided a fully constructed view instance: ${prop} cannot be applied.\\n` +\n `Use ViewOptions instead of a View instance.`\n );\n };\n\n if (mapConfig.projection != null) {\n warn(\"projection\");\n }\n if (mapConfig.initialView != null) {\n warn(\"initialView\");\n }\n return;\n }\n\n const projection = (view.projection = this.#initializeProjection(mapConfig.projection));\n const initialView = mapConfig.initialView;\n if (initialView) {\n switch (initialView.kind) {\n case \"position\":\n view.zoom = initialView.zoom;\n view.center = [initialView.center.x, initialView.center.y];\n break;\n case \"extent\": {\n /*\n OpenLayers does not support configuration of the initial map extent.\n The only relevant options here are center, zoom (and resolution).\n We must set those values because otherwise OpenLayers will not initialize layer sources.\n\n The actual initial extent is applied once tha map has loaded and its size is known.\n */\n const extent = initialView.extent;\n view.zoom = 0;\n view.center = [\n extent.xMin + (extent.xMax - extent.xMin) / 2,\n extent.yMin + (extent.yMax - extent.yMin) / 2\n ];\n break;\n }\n }\n } else {\n this.#setViewDefaults(view, projection);\n }\n }\n\n #setViewDefaults(view: ViewOptions, projection: Projection) {\n if (view.center == null) {\n const extent = projection.getExtent(); // can be null\n if (!extent) {\n LOG.warn(\n `Cannot set default center coordinate because the current projection has no associated extent.\\n` +\n `Try to configure 'initialView' explicity.`\n );\n } else {\n view.center = getCenter(extent);\n }\n }\n\n if (view.zoom == null || view.resolution == null) {\n view.zoom = 0;\n }\n }\n\n #initializeProjection(projectionOption: MapConfig[\"projection\"]) {\n if (projectionOption == null) {\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n return getProjection(\"EPSG:3857\")!; // default OpenLayers projection\n }\n\n const projection = getProjection(projectionOption);\n if (!projection) {\n throw new Error(`Failed to retrieve projection for code '${projectionOption}'.`);\n }\n return projection;\n }\n}\n"],"names":["defaultInteractions","getProjection"],"mappings":";;;;;;;;;;;;;;;AA0BA,mBAAA,CAAoB;AAAA,EAChB,YAAA,EACI,oFAAA;AAAA,EACJ,YAAA,EACI;AACR,CAAC,CAAA;AACD,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,eAAsB,cAAA,CAClB,KAAA,EACA,SAAA,EACA,WAAA,EACA,WAAA,EACiB;AACjB,EAAA,OAAO,MAAM,IAAI,eAAA,CAAgB,KAAA,EAAO,WAAW,WAAA,EAAa,WAAW,EAAE,cAAA,EAAe;AAChG;AAEA,MAAM,eAAA,CAAgB;AAAA,EAClB,MAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EAEA,WAAA,CACI,KAAA,EACA,SAAA,EACA,WAAA,EACA,WAAA,EACF;AACE,IAAA,IAAA,CAAK,MAAA,GAAS,KAAA;AACd,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAClB,IAAA,IAAA,CAAK,YAAA,GAAe,WAAA;AACpB,IAAA,IAAA,CAAK,YAAA,GAAe,WAAA;AAAA,EACxB;AAAA,EAEA,MAAM,cAAA,GAAiB;AACnB,IAAA,MAAM,QAAQ,IAAA,CAAK,MAAA;AACnB,IAAA,MAAM,YAAY,IAAA,CAAK,UAAA;AACvB,IAAA,MAAM,EAAE,MAAM,UAAA,EAAY,GAAG,cAAa,GAAI,SAAA,CAAU,YAAY,EAAC;AACrE,IAAA,MAAM,uBAAA,GACF,SAAA,CAAU,gBAAA,KAAqB,YAAA,CAAa,WAAW,KAAA,GAAQ,IAAA,CAAA;AAEnE,IAAA,MAAM,UAAA,GAAyB;AAAA,MAC3B,GAAG;AAAA,KACP;AACA,IAAA,IAAI,CAAC,WAAW,QAAA,EAAU;AACtB,MAAA,UAAA,CAAW,WAAW,EAAC;AAAA,I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;AAEA,IAAA,IAAI,IAAA,CAAK,IAAA,IAAQ,IAAA,IAAQ,IAAA,CAAK,cAAc,IAAA,EAAM;AAC9C,MAAA,IAAA,CAAK,IAAA,GAAO,CAAA;AAAA,IAChB;AAAA,EACJ;AAAA,EAEA,sBAAsB,gBAAA,EAA2C;AAC7D,IAAA,IAAI,oBAAoB,IAAA,EAAM;AAE1B,MAAA,OAAOC,IAAc,WAAW,CAAA;AAAA,IACpC;AAEA,IAAA,MAAM,UAAA,GAAaA,IAAc,gBAAgB,CAAA;AACjD,IAAA,IAAI,CAAC,UAAA,EAAY;AACb,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,wCAAA,EAA2C,gBAAgB,CAAA,EAAA,CAAI,CAAA;AAAA,IACnF;AACA,IAAA,OAAO,UAAA;AAAA,EACX;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getGeometries.js","sources":["getGeometries.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Geometry } from \"ol/geom\";\nimport { DisplayTarget } from \"./MapModel\";\n\nexport function getGeometries(geoObjects: DisplayTarget[]): Geometry[] {\n const geometries: Geometry[] = [];\n geoObjects.forEach((item) => {\n if (\"getType\" in item) geometries.push(item);\n if (\"geometry\" in item && item.geometry) geometries.push(item.geometry);\n });\n return geometries;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getGeometries.js","sources":["getGeometries.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Geometry } from \"ol/geom\";\nimport { DisplayTarget } from \"./MapModel\";\n\nexport function getGeometries(geoObjects: DisplayTarget[]): Geometry[] {\n const geometries: Geometry[] = [];\n geoObjects.forEach((item) => {\n if (\"getType\" in item) geometries.push(item);\n if (\"geometry\" in item && item.geometry) geometries.push(item.geometry);\n });\n return geometries;\n}\n"],"names":[],"mappings":"AAMO,SAAS,cAAc,UAAA,EAAyC;AACnE,EAAA,MAAM,aAAyB,EAAC;AAChC,EAAA,UAAA,CAAW,OAAA,CAAQ,CAAC,IAAA,KAAS;AACzB,IAAA,IAAI,SAAA,IAAa,IAAA,EAAM,UAAA,CAAW,IAAA,CAAK,IAAI,CAAA;AAC3C,IAAA,IAAI,cAAc,IAAA,IAAQ,IAAA,CAAK,UAAU,UAAA,CAAW,IAAA,CAAK,KAAK,QAAQ,CAAA;AAAA,EAC1E,CAAC,CAAA;AACD,EAAA,OAAO,UAAA;AACX;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/map",
|
|
4
|
-
"version": "1.4.0
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"description": "This package integrates OpenLayers maps into an open pioneer trails application.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"@conterra/reactivity-core": "^0.8.6",
|
|
19
19
|
"@conterra/reactivity-events": "^0.8.6",
|
|
20
20
|
"@esri/arcgis-html-sanitizer": "^4.1.0",
|
|
21
|
-
"@open-pioneer/core": "4.7.0
|
|
22
|
-
"@open-pioneer/http": "4.7.0
|
|
23
|
-
"@open-pioneer/react-utils": "4.7.0
|
|
24
|
-
"@open-pioneer/reactivity": "4.7.0
|
|
25
|
-
"@open-pioneer/runtime": "4.7.0
|
|
21
|
+
"@open-pioneer/core": "^4.7.0",
|
|
22
|
+
"@open-pioneer/http": "^4.7.0",
|
|
23
|
+
"@open-pioneer/react-utils": "^4.7.0",
|
|
24
|
+
"@open-pioneer/reactivity": "^4.7.0",
|
|
25
|
+
"@open-pioneer/runtime": "^4.7.0",
|
|
26
26
|
"ol": "^10.9.0",
|
|
27
27
|
"proj4": "^2.20.9",
|
|
28
|
+
"react": "^19.2.8",
|
|
28
29
|
"react-dom": "^19.2.8",
|
|
29
30
|
"react-use": "^17.6.1",
|
|
30
|
-
"react": "^19.2.8",
|
|
31
31
|
"uuid": "^14.0.1"
|
|
32
32
|
},
|
|
33
33
|
"exports": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultMapProvider.js","sources":["DefaultMapProvider.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createContext, useContext } from \"react\";\nimport { MapModel } from \"../model/MapModel\";\nimport { MapModelProps } from \"./hooks/useMapModel\";\n\nconst DefaultMapContext = createContext<MapModel | undefined>(undefined);\nDefaultMapContext.displayName = \"DefaultMapContext\";\n\n/**\n * Configures the given map as the default map for all child components.\n * Child components do not need to specify the map explicitly, unless they wish to use a different one.\n *\n * @example\n *\n * Using map model reference:\n *\n * ```tsx\n * <DefaultMapProvider map={myMapModel}>\n * <MapContainer />\n * <Toc />\n * </DefaultMapProvider>\n * ```\n *\n * @group UI Components and Hooks\n */\nexport function DefaultMapProvider(\n props: Required<MapModelProps> & { children?: React.ReactNode }\n) {\n const { map, children } = props;\n if (map == null) {\n throw new Error(`DefaultMapProvider requires the 'map' property.`);\n }\n return <DefaultMapContext.Provider value={map}>{children}</DefaultMapContext.Provider>;\n}\n\n/**\n * Accesses the default map props provided by {@link DefaultMapProvider} (or returns undefined).\n *\n * @internal\n */\nexport function useDefaultMap(): MapModel | undefined {\n return useContext(DefaultMapContext);\n}\n"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"DefaultMapProvider.js","sources":["DefaultMapProvider.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createContext, useContext } from \"react\";\nimport { MapModel } from \"../model/MapModel\";\nimport { MapModelProps } from \"./hooks/useMapModel\";\n\nconst DefaultMapContext = createContext<MapModel | undefined>(undefined);\nDefaultMapContext.displayName = \"DefaultMapContext\";\n\n/**\n * Configures the given map as the default map for all child components.\n * Child components do not need to specify the map explicitly, unless they wish to use a different one.\n *\n * @example\n *\n * Using map model reference:\n *\n * ```tsx\n * <DefaultMapProvider map={myMapModel}>\n * <MapContainer />\n * <Toc />\n * </DefaultMapProvider>\n * ```\n *\n * @group UI Components and Hooks\n */\nexport function DefaultMapProvider(\n props: Required<MapModelProps> & { children?: React.ReactNode }\n) {\n const { map, children } = props;\n if (map == null) {\n throw new Error(`DefaultMapProvider requires the 'map' property.`);\n }\n return <DefaultMapContext.Provider value={map}>{children}</DefaultMapContext.Provider>;\n}\n\n/**\n * Accesses the default map props provided by {@link DefaultMapProvider} (or returns undefined).\n *\n * @internal\n */\nexport function useDefaultMap(): MapModel | undefined {\n return useContext(DefaultMapContext);\n}\n"],"names":[],"mappings":";;;AAOA,MAAM,iBAAA,GAAoB,cAAoC,MAAS,CAAA;AACvE,iBAAA,CAAkB,WAAA,GAAc,mBAAA;AAmBzB,SAAS,mBACZ,KAAA,EACF;AACE,EAAA,MAAM,EAAE,GAAA,EAAK,QAAA,EAAS,GAAI,KAAA;AAC1B,EAAA,IAAI,OAAO,IAAA,EAAM;AACb,IAAA,MAAM,IAAI,MAAM,CAAA,+CAAA,CAAiD,CAAA;AAAA,EACrE;AACA,EAAA,2BAAQ,iBAAA,CAAkB,QAAA,EAAlB,EAA2B,KAAA,EAAO,KAAM,QAAA,EAAS,CAAA;AAC7D;AAOO,SAAS,aAAA,GAAsC;AAClD,EAAA,OAAO,WAAW,iBAAiB,CAAA;AACvC;;;;"}
|
package/ui/MapAnchor.js.map
CHANGED
|
@@ -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, 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":";;;;;;;;
|
|
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\n\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":";;;;;;;;AAiCA,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;;;;"}
|
package/ui/MapContainer.js
CHANGED
|
@@ -6,8 +6,8 @@ import { useReactiveSnapshot } from '@open-pioneer/reactivity';
|
|
|
6
6
|
import { sourceId$5 as sourceId } from '../_virtual/source-info.js';
|
|
7
7
|
import { useRef, useState, useEffect, useMemo } from 'react';
|
|
8
8
|
import { DISPLAY_STATUS } from '../model/MapModel.js';
|
|
9
|
-
import { MapContainerContextProvider } from './MapContainerContext.js';
|
|
10
9
|
import { useMapModelValue } from './hooks/useMapModel.js';
|
|
10
|
+
import { MapContainerContextProvider } from './MapContainerContext.js';
|
|
11
11
|
import { OverlaysRenderer } from './OverlaysRenderer.js';
|
|
12
12
|
|
|
13
13
|
const LOG = createLogger(sourceId);
|
package/ui/MapContainer.js.map
CHANGED
|
@@ -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, 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 { DISPLAY_STATUS, MapModel, MapPadding } from \"../model/MapModel\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { MapModelProps, useMapModelValue } from \"./hooks/useMapModel\";\nimport { OverlaysRenderer } from \"./OverlaysRenderer\";\nimport { Coordinate } from \"ol/coordinate\";\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 (\n <MapContainerContextProvider value={mapContext}>\n <OverlaysRenderer map={map} />\n {children}\n </MapContainerContextProvider>\n );\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\ninterface TargetViewPoint {\n center: Coordinate;\n extent: Extent | undefined;\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\n // Tracks target state for in-progress animations.\n const targetViewPoint = useRef<TargetViewPoint>(undefined);\n\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 let target = targetViewPoint.current;\n if (!target || !mapView.getAnimating()) {\n const currentCenter = mapView.getCenter();\n if (!currentCenter) {\n return;\n }\n targetViewPoint.current = target = {\n center: currentCenter,\n extent: extentIncludingPadding(olMap, oldPadding)\n };\n }\n mapView.padding = toOlPadding(viewPadding);\n\n const shouldAnimate = map[DISPLAY_STATUS] === \"ready\";\n switch (viewPaddingChangeBehavior) {\n case \"preserve-center\": {\n if (shouldAnimate) {\n mapView.animate({ center: target.center, duration: 300 }, (done) => {\n if (done) {\n targetViewPoint.current = undefined;\n }\n });\n } else {\n mapView.setCenter(target.center);\n targetViewPoint.current = undefined;\n }\n break;\n }\n case \"preserve-extent\": {\n if (target.extent) {\n const res = mapView.getResolutionForExtent(target.extent);\n if (shouldAnimate) {\n mapView.animate(\n {\n center: target.center,\n resolution: res,\n duration: 300\n },\n (done) => {\n if (done) {\n targetViewPoint.current = undefined;\n }\n }\n );\n } else {\n mapView.setCenter(target.center);\n mapView.setResolution(res);\n targetViewPoint.current = undefined;\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":";;;;;;;;;;;;AAoBA,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,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AAM,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;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;;;;"}
|
|
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\n\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 { Coordinate } from \"ol/coordinate\";\nimport { Extent } from \"ol/extent\";\nimport type OlMap from \"ol/Map\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ReactNode, RefObject, useEffect, useMemo, useRef, useState } from \"react\";\nimport { DISPLAY_STATUS, MapModel, MapPadding } from \"../model/MapModel\";\nimport { MapModelProps, useMapModelValue } from \"./hooks/useMapModel\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { OverlaysRenderer } from \"./OverlaysRenderer\";\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 // oxlint-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 (\n <MapContainerContextProvider value={mapContext}>\n <OverlaysRenderer map={map} />\n {children}\n </MapContainerContextProvider>\n );\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\ninterface TargetViewPoint {\n center: Coordinate;\n extent: Extent | undefined;\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\n // Tracks target state for in-progress animations.\n const targetViewPoint = useRef<TargetViewPoint>(undefined);\n\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 let target = targetViewPoint.current;\n if (!target || !mapView.getAnimating()) {\n const currentCenter = mapView.getCenter();\n if (!currentCenter) {\n return;\n }\n targetViewPoint.current = target = {\n center: currentCenter,\n extent: extentIncludingPadding(olMap, oldPadding)\n };\n }\n mapView.padding = toOlPadding(viewPadding);\n\n const shouldAnimate = map[DISPLAY_STATUS] === \"ready\";\n switch (viewPaddingChangeBehavior) {\n case \"preserve-center\": {\n if (shouldAnimate) {\n mapView.animate({ center: target.center, duration: 300 }, (done) => {\n if (done) {\n targetViewPoint.current = undefined;\n }\n });\n } else {\n mapView.setCenter(target.center);\n targetViewPoint.current = undefined;\n }\n break;\n }\n case \"preserve-extent\": {\n if (target.extent) {\n const res = mapView.getResolutionForExtent(target.extent);\n if (shouldAnimate) {\n mapView.animate(\n {\n center: target.center,\n resolution: res,\n duration: 300\n },\n (done) => {\n if (done) {\n targetViewPoint.current = undefined;\n }\n }\n );\n } else {\n mapView.setCenter(target.center);\n mapView.setResolution(res);\n targetViewPoint.current = undefined;\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 // oxlint-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 // oxlint-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":";;;;;;;;;;;;AAqBA,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,EAAA,MAAM,WAAA,GAAc,eAAe,eAAe,CAAA;AAClD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,KAAK,CAAA;AAGxC,EAAA,2BAAA,CAA4B,cAAc,GAAG,CAAA;AAG7C,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,QAAA,CAAS,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,GAAA,GAAM,WAAW,WAAW,CAAA;AAClC,EAAA,MAAM,eAAA,GAAkB,OAAA;AAAA,IACpB,MAAM,iBAA2B,EAAE,GAAA,IAAO,kB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;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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapContainerContext.js","sources":["MapContainerContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Provider, createContext, useContext } from \"react\";\n\n/** Values provided to children of {@link MapContainer}. */\nexport interface MapContainerContextType {\n mapAnchorsHost: HTMLElement;\n}\n\nconst MapContainerContext = createContext<MapContainerContextType | undefined>(undefined);\nMapContainerContext.displayName = \"MapContainerContext\";\n\nexport const MapContainerContextProvider: Provider<MapContainerContextType> =\n MapContainerContext.Provider as Provider<MapContainerContextType>;\n\nexport function useMapContainerContext(): MapContainerContextType {\n const contextValue = useContext(MapContainerContext);\n if (!contextValue) {\n throw new Error(\n `Map container context is not available. The component must be a child of the <MapContainer /> component.`\n );\n }\n return contextValue;\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"MapContainerContext.js","sources":["MapContainerContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Provider, createContext, useContext } from \"react\";\n\n/** Values provided to children of {@link MapContainer}. */\nexport interface MapContainerContextType {\n mapAnchorsHost: HTMLElement;\n}\n\nconst MapContainerContext = createContext<MapContainerContextType | undefined>(undefined);\nMapContainerContext.displayName = \"MapContainerContext\";\n\nexport const MapContainerContextProvider: Provider<MapContainerContextType> =\n MapContainerContext.Provider as Provider<MapContainerContextType>;\n\nexport function useMapContainerContext(): MapContainerContextType {\n const contextValue = useContext(MapContainerContext);\n if (!contextValue) {\n throw new Error(\n `Map container context is not available. The component must be a child of the <MapContainer /> component.`\n );\n }\n return contextValue;\n}\n"],"names":[],"mappings":";;AAUA,MAAM,mBAAA,GAAsB,cAAmD,MAAS,CAAA;AACxF,mBAAA,CAAoB,WAAA,GAAc,qBAAA;AAE3B,MAAM,8BACT,mBAAA,CAAoB;AAEjB,SAAS,sBAAA,GAAkD;AAC9D,EAAA,MAAM,YAAA,GAAe,WAAW,mBAAmB,CAAA;AACnD,EAAA,IAAI,CAAC,YAAA,EAAc;AACf,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,wGAAA;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,OAAO,YAAA;AACX;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverlaysRenderer.js","sources":["OverlaysRenderer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport {
|
|
1
|
+
{"version":3,"file":"OverlaysRenderer.js","sources":["OverlaysRenderer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { createPortal } from \"react-dom\";\nimport { MapModel } from \"../model/MapModel\";\nimport { Overlay } from \"../model/Overlays\";\n\nexport function OverlaysRenderer(props: { map: MapModel }) {\n const { map } = props;\n const overlays = useReactiveSnapshot(() => {\n return map.overlays.getAll();\n }, [map]);\n return overlays.map((overlay) => <OverlayRenderer key={overlay.id} overlay={overlay} />);\n}\n\nfunction OverlayRenderer(props: { overlay: Overlay }) {\n const { overlay } = props;\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n const target = overlay.olOverlay.getElement()!; // not reactive, always the same\n const content = useReactiveSnapshot(() => overlay.content, [overlay]);\n return createPortal(content, target);\n}\n"],"names":[],"mappings":";;;;AAQO,SAAS,iBAAiB,KAAA,EAA0B;AACvD,EAAA,MAAM,EAAE,KAAI,GAAI,KAAA;AAChB,EAAA,MAAM,QAAA,GAAW,oBAAoB,MAAM;AACvC,IAAA,OAAO,GAAA,CAAI,SAAS,MAAA,EAAO;AAAA,EAC/B,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AACR,EAAA,OAAO,QAAA,CAAS,IAAI,CAAC,OAAA,yBAAa,eAAA,EAAA,EAAiC,OAAA,EAAA,EAAZ,OAAA,CAAQ,EAAsB,CAAE,CAAA;AAC3F;AAEA,SAAS,gBAAgB,KAAA,EAA6B;AAClD,EAAA,MAAM,EAAE,SAAQ,GAAI,KAAA;AAEpB,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,SAAA,CAAU,UAAA,EAAW;AAC5C,EAAA,MAAM,UAAU,mBAAA,CAAoB,MAAM,QAAQ,OAAA,EAAS,CAAC,OAAO,CAAC,CAAA;AACpE,EAAA,OAAO,YAAA,CAAa,SAAS,MAAM,CAAA;AACvC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeMapAnchorStyles.js","sources":["computeMapAnchorStyles.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SystemStyleObject } from \"@chakra-ui/react\";\nimport { MapAnchorPosition } from \"./MapAnchor\";\n\nexport function computeMapAnchorStyles(\n position: MapAnchorPosition,\n horizontalGap?: number | undefined,\n verticalGap?: number | undefined\n): SystemStyleObject {\n const horizontal = horizontalGap ?? 0;\n const vertical = verticalGap ?? 0;\n const attributionGap = verticalGap == null ? ATTR_GAP : 0;\n\n const styleProps: SystemStyleObject = {};\n switch (position) {\n case \"top-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"top-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"bottom-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"bottom-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"top-center\":\n styleProps.top = `${vertical}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"bottom-center\":\n styleProps.bottom = `${vertical + attributionGap}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"left-center\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"right-center\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"center\":\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translate(-50%, -50%)\";\n break;\n }\n\n styleProps.maxW = `calc((100%) - ${2 * horizontal}px)`;\n styleProps.maxH = `calc((100%) - ${attributionGap}px - ${2 * vertical}px)`;\n return styleProps;\n}\n\n/**\n * height of the ol attribution component\n * improvement: Get height directly from `Attribution` HTMLDivElement\n */\nconst ATTR_HEIGHT = 20;\n\n/**\n * additional space between attribution and map anchor container\n */\nconst ATTR_SPACE = 10;\nconst ATTR_GAP = ATTR_HEIGHT + ATTR_SPACE;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computeMapAnchorStyles.js","sources":["computeMapAnchorStyles.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SystemStyleObject } from \"@chakra-ui/react\";\nimport { MapAnchorPosition } from \"./MapAnchor\";\n\nexport function computeMapAnchorStyles(\n position: MapAnchorPosition,\n horizontalGap?: number | undefined,\n verticalGap?: number | undefined\n): SystemStyleObject {\n const horizontal = horizontalGap ?? 0;\n const vertical = verticalGap ?? 0;\n const attributionGap = verticalGap == null ? ATTR_GAP : 0;\n\n const styleProps: SystemStyleObject = {};\n switch (position) {\n case \"top-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"top-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"bottom-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"bottom-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"top-center\":\n styleProps.top = `${vertical}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"bottom-center\":\n styleProps.bottom = `${vertical + attributionGap}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"left-center\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"right-center\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"center\":\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translate(-50%, -50%)\";\n break;\n }\n\n styleProps.maxW = `calc((100%) - ${2 * horizontal}px)`;\n styleProps.maxH = `calc((100%) - ${attributionGap}px - ${2 * vertical}px)`;\n return styleProps;\n}\n\n/**\n * height of the ol attribution component\n * improvement: Get height directly from `Attribution` HTMLDivElement\n */\nconst ATTR_HEIGHT = 20;\n\n/**\n * additional space between attribution and map anchor container\n */\nconst ATTR_SPACE = 10;\nconst ATTR_GAP = ATTR_HEIGHT + ATTR_SPACE;\n"],"names":[],"mappings":"AAMO,SAAS,sBAAA,CACZ,QAAA,EACA,aAAA,EACA,WAAA,EACiB;AACjB,EAAA,MAAM,aAAa,aAAA,IAAiB,CAAA;AACpC,EAAA,MAAM,WAAW,WAAA,IAAe,CAAA;AAChC,EAAA,MAAM,cAAA,GAAiB,WAAA,IAAe,IAAA,GAAO,QAAA,GAAW,CAAA;AAExD,EAAA,MAAM,aAAgC,EAAC;AACvC,EAAA,QAAQ,QAAA;AAAU,IACd,KAAK,UAAA;AACD,MAAA,UAAA,CAAW,IAAA,GAAO,GAAG,UAAU,CAAA,EAAA,CAAA;AAC/B,MAAA,UAAA,CAAW,GAAA,GAAM,GAAG,QAAQ,CAAA,EAAA,CAAA;AAC5B,MAAA;AAAA,IACJ,KAAK,WAAA;AACD,MAAA,UAAA,CAAW,KAAA,GAAQ,GAAG,UAAU,CAAA,EAAA,CAAA;AAChC,MAAA,UAAA,CAAW,GAAA,GAAM,GAAG,QAAQ,CAAA,EAAA,CAAA;AAC5B,MAAA;AAAA,IACJ,KAAK,aAAA;AACD,MAAA,UAAA,CAAW,IAAA,GAAO,GAAG,UAAU,CAAA,EAAA,CAAA;AAC/B,MAAA,UAAA,CAAW,MAAA,GAAS,CAAA,EAAG,QAAA,GAAW,cAAc,CAAA,EAAA,CAAA;AAChD,MAAA;AAAA,IACJ,KAAK,cAAA;AACD,MAAA,UAAA,CAAW,KAAA,GAAQ,GAAG,UAAU,CAAA,EAAA,CAAA;AAChC,MAAA,UAAA,CAAW,MAAA,GAAS,CAAA,EAAG,QAAA,GAAW,cAAc,CAAA,EAAA,CAAA;AAChD,MAAA;AAAA,IACJ,KAAK,YAAA;AACD,MAAA,UAAA,CAAW,GAAA,GAAM,GAAG,QAAQ,CAAA,EAAA,CAAA;AAC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AAA;AACX;AAMA,MAAM,WAAA,GAAc,EAAA;AAKpB,MAAM,UAAA,GAAa,EAAA;AACnB,MAAM,WAAW,WAAA,GAAc,UAAA;;;;"}
|
package/ui/hooks/useMapModel.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { createLogger } from '@open-pioneer/core';
|
|
1
2
|
import { useService } from '../../_virtual/hooks.js';
|
|
3
|
+
import { sourceId$4 as sourceId } from '../../_virtual/source-info.js';
|
|
2
4
|
import { useMemo, useEffect } from 'react';
|
|
3
5
|
import { useAsync } from 'react-use';
|
|
4
6
|
import { MapModel } from '../../model/MapModel.js';
|
|
5
7
|
import { useDefaultMap } from '../DefaultMapProvider.js';
|
|
6
|
-
import { createLogger } from '@open-pioneer/core';
|
|
7
|
-
import { sourceId$4 as sourceId } from '../../_virtual/source-info.js';
|
|
8
8
|
|
|
9
9
|
const LOG = createLogger(sourceId);
|
|
10
10
|
function useMapModel(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMapModel.js","sources":["useMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {
|
|
1
|
+
{"version":3,"file":"useMapModel.js","sources":["useMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createLogger } from \"@open-pioneer/core\";\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { useEffect, useMemo } from \"react\";\nimport { useAsync } from \"react-use\";\nimport { MapRegistry } from \"../../MapRegistry\";\nimport { MapModel } from \"../../model/MapModel\";\nimport { useDefaultMap } from \"../DefaultMapProvider\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * Return value of {@link useMapModel}.\n *\n * @group UI Components and Hooks\n **/\nexport type UseMapModelResult = UseMapModelLoading | UseMapModelResolved | UseMapModelRejected;\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelLoading {\n kind: \"loading\";\n map?: undefined;\n error?: undefined;\n}\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelResolved {\n kind: \"resolved\";\n map: MapModel;\n error?: undefined;\n}\n\n/** @group UI Components and Hooks */\nexport interface UseMapModelRejected {\n kind: \"rejected\";\n map?: undefined;\n error: Error;\n}\n\n/**\n * React hook that returns the default map model (if available, see {@link DefaultMapProvider}).\n *\n * @deprecated Use {@link useMapModelValue} instead.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(): UseMapModelResult;\n\n/**\n * React hook that looks up the map with the given id in the `map.MapRegistry` service.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n *\n * An error message will be logged if the map model's creation has failed.\n * Use the option `quiet: true` to suppress this message.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(mapId: string): UseMapModelResult;\n\n/**\n * React hook that resolves a map model specified by the given `props`.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n *\n * An error message will be logged if the map model's creation has failed.\n * Use the option `quiet: true` to suppress this message.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModel(props: { mapId: string; quiet?: boolean }): UseMapModelResult;\n\nexport function useMapModel(\n props?: undefined | string | { mapId: string; quiet?: boolean }\n): UseMapModelResult {\n if (props instanceof MapModel) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModel' (see TypeScript signature).`\n );\n }\n\n const defaultMap = useDefaultMap();\n const mapRegistry = useService<MapRegistry>(\"map.MapRegistry\");\n\n let mapId: string | undefined;\n if (typeof props === \"string\") {\n mapId = props;\n } else if (typeof props === \"object\") {\n mapId = props.mapId;\n }\n\n if (mapId == null && !defaultMap) {\n throw new Error(\n \"No map specified. Either configure a mapId or use the DefaultMapProvider.\"\n );\n }\n\n const state = useAsync(async () => {\n if (mapId == null) {\n // For backwards compatibility\n return defaultMap;\n }\n\n return await mapRegistry.expectMapModel(mapId);\n }, [mapRegistry, mapId]);\n\n const result = useMemo((): UseMapModelResult => {\n if (state.loading) {\n return { kind: \"loading\" };\n }\n if (state.error) {\n return { kind: \"rejected\", error: state.error };\n }\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n return { kind: \"resolved\", map: state.value! };\n }, [state]);\n\n const quiet = (typeof props === \"object\" ? props.quiet : undefined) ?? false;\n useEffect(() => {\n if (!quiet && result.error) {\n LOG.error(\"Failed to construct map\", result.error);\n }\n }, [quiet, result.error]);\n return result;\n}\n\n/**\n * Options that specify which map to use. See {@link useMapModelValue}.\n *\n * When not setting any of these properties on a component, the default map (from the `DefaultMapProvider`) will be used.\n * If that is not available either, an error will be thrown.\n *\n * @see {@link DefaultMapProvider}\n *\n * @group UI Components and Hooks\n */\nexport interface MapModelProps {\n /**\n * The map model to use.\n */\n map?: MapModel | undefined;\n}\n\n/**\n * Returns the configured map model.\n *\n * The map model is either directly configured or specified via a {@link DefaultMapProvider}.\n * If neither has been specified, an error will be thrown.\n *\n * This hook is preferable to {@link useMapModel} because it can return the map model directly, without waiting.\n *\n * @group UI Components and Hooks\n */\nexport function useMapModelValue(props?: MapModelProps): MapModel {\n if (props instanceof MapModel) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModelValue' (see TypeScript signature).`\n );\n }\n\n const localMap = props?.map;\n const defaultMap = useDefaultMap();\n const map = localMap ?? defaultMap;\n if (!map) {\n throw new Error(\n `No map specified. ` +\n `You must either specify the map via a DefaultMapProvider parent or configure it explicitly.`\n );\n }\n return map;\n}\n"],"names":[],"mappings":";;;;;;;;AAYA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAqE1B,SAAS,YACZ,KAAA,EACiB;AACjB,EAAA,I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MAAA,KAAc,KAAA;AACvE,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,IAAI,CAAC,KAAA,IAAS,MAAA,CAAO,KAAA,EAAO;AACxB,MAAA,GAAA,CAAI,KAAA,CAAM,yBAAA,EAA2B,MAAA,CAAO,KAAK,CAAA;AAAA,IACrD;AAAA,EACJ,CAAA,EAAG,CAAC,KAAA,EAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AACxB,EAAA,OAAO,MAAA;AACX;AA6BO,SAAS,iBAAiB,KAAA,EAAiC;AAC9D,EAAA,IAAI,iBAAiB,QAAA,EAAU;AAE3B,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,+FAAA;AAAA,KACJ;AAAA,EACJ;AAEA,EAAA,MAAM,WAAW,KAAA,EAAO,GAAA;AACxB,EAAA,MAAM,aAAa,aAAA,EAAc;AACjC,EAAA,MAAM,MAAM,QAAA,IAAY,UAAA;AACxB,EAAA,IAAI,CAAC,GAAA,EAAK;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,6GAAA;AAAA,KAEJ;AAAA,EACJ;AACA,EAAA,OAAO,GAAA;AACX;;;;"}
|
package/utils/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sources":["fetch.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { HttpService } from \"@open-pioneer/http\";\n\nexport async function fetchText(\n url: string,\n httpService: HttpService,\n signal: AbortSignal\n): Promise<string> {\n const response = await httpService.fetch(url, { signal });\n if (!response.ok) {\n throw new Error(\"Request failed: \" + response.status);\n }\n const result = await response.text();\n return result;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.js","sources":["fetch.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { HttpService } from \"@open-pioneer/http\";\n\nexport async function fetchText(\n url: string,\n httpService: HttpService,\n signal: AbortSignal\n): Promise<string> {\n const response = await httpService.fetch(url, { signal });\n if (!response.ok) {\n throw new Error(\"Request failed: \" + response.status);\n }\n const result = await response.text();\n return result;\n}\n"],"names":[],"mappings":"AAKA,eAAsB,SAAA,CAClB,GAAA,EACA,WAAA,EACA,MAAA,EACe;AACf,EAAA,MAAM,WAAW,MAAM,WAAA,CAAY,MAAM,GAAA,EAAK,EAAE,QAAQ,CAAA;AACxD,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,kBAAA,GAAqB,QAAA,CAAS,MAAM,CAAA;AAAA,EACxD;AACA,EAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,IAAA,EAAK;AACnC,EAAA,OAAO,MAAA;AACX;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-utils.js","sources":["geometry-utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Extent, getHeight, getWidth } from \"ol/extent\";\n\nconst DEFAULT_BUFFER_FACTOR = 1.2;\n\n/**\n * Computes a buffered extent using the given original extent.\n *\n * Use the `factor` (`1.2` by default) to specify the size increase.\n *\n * @group Utilities\n */\nexport function calculateBufferedExtent(extent: Extent, factor = DEFAULT_BUFFER_FACTOR): Extent {\n checkExtent(extent);\n const width = getHeight(extent);\n const height = getWidth(extent);\n const bufferWidth = width * factor;\n const bufferHeight = height * factor;\n const bufferedExtent = [\n extent[0] - (bufferWidth - width) / 2,\n extent[1] - (bufferHeight - height) / 2,\n extent[2] + (bufferWidth - width) / 2,\n extent[3] + (bufferHeight - height) / 2\n ];\n return bufferedExtent;\n}\n\nfunction checkExtent(extent: Extent): asserts extent is [number, number, number, number] {\n if (extent.length !== 4) {\n throw new Error(`Invalid extent (expected length 4, but got length ${extent.length}).`);\n }\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"geometry-utils.js","sources":["geometry-utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Extent, getHeight, getWidth } from \"ol/extent\";\n\nconst DEFAULT_BUFFER_FACTOR = 1.2;\n\n/**\n * Computes a buffered extent using the given original extent.\n *\n * Use the `factor` (`1.2` by default) to specify the size increase.\n *\n * @group Utilities\n */\nexport function calculateBufferedExtent(extent: Extent, factor = DEFAULT_BUFFER_FACTOR): Extent {\n checkExtent(extent);\n const width = getHeight(extent);\n const height = getWidth(extent);\n const bufferWidth = width * factor;\n const bufferHeight = height * factor;\n const bufferedExtent = [\n extent[0] - (bufferWidth - width) / 2,\n extent[1] - (bufferHeight - height) / 2,\n extent[2] + (bufferWidth - width) / 2,\n extent[3] + (bufferHeight - height) / 2\n ];\n return bufferedExtent;\n}\n\nfunction checkExtent(extent: Extent): asserts extent is [number, number, number, number] {\n if (extent.length !== 4) {\n throw new Error(`Invalid extent (expected length 4, but got length ${extent.length}).`);\n }\n}\n"],"names":[],"mappings":";;AAKA,MAAM,qBAAA,GAAwB,GAAA;AASvB,SAAS,uBAAA,CAAwB,MAAA,EAAgB,MAAA,GAAS,qBAAA,EAA+B;AAC5F,EAAA,WAAA,CAAY,MAAM,CAAA;AAClB,EAAA,MAAM,KAAA,GAAQ,UAAU,MAAM,CAAA;AAC9B,EAAA,MAAM,MAAA,GAAS,SAAS,MAAM,CAAA;AAC9B,EAAA,MAAM,cAAc,KAAA,GAAQ,MAAA;AAC5B,EAAA,MAAM,eAAe,MAAA,GAAS,MAAA;AAC9B,EAAA,MAAM,cAAA,GAAiB;AAAA,IACnB,MAAA,CAAO,CAAC,CAAA,GAAA,CAAK,WAAA,GAAc,KAAA,IAAS,CAAA;AAAA,IACpC,MAAA,CAAO,CAAC,CAAA,GAAA,CAAK,YAAA,GAAe,MAAA,IAAU,CAAA;AAAA,IACtC,MAAA,CAAO,CAAC,CAAA,GAAA,CAAK,WAAA,GAAc,KAAA,IAAS,CAAA;AAAA,IACpC,MAAA,CAAO,CAAC,CAAA,GAAA,CAAK,YAAA,GAAe,MAAA,IAAU;AAAA,GAC1C;AACA,EAAA,OAAO,cAAA;AACX;AAEA,SAAS,YAAY,MAAA,EAAoE;AACrF,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kDAAA,EAAqD,MAAA,CAAO,MAAM,CAAA,EAAA,CAAI,CAAA;AAAA,EAC1F;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ol-test-support.js","sources":["ol-test-support.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { equals as extentEquals } from \"ol/extent\";\nimport OlMap from \"ol/Map\";\n\nlet setupDone = false;\n\n/** @internal */\nexport function patchOpenLayersClassesForTesting() {\n if (setupDone) {\n return;\n }\n\n // Test support: OpenLayers relies on div.offsetHeight (and Width)\n // plus getComputedStyle(div), which do not work as expected in happy dom.\n // The following snippet fakes a size so tests can work with the map.\n OlMap.prototype.updateSize = function () {\n const target = this.getTargetElement();\n const height = 500;\n const width = 500;\n const size = target ? [width, height] : undefined;\n const oldSize = this.getSize();\n if (size && (!oldSize || !extentEquals(size, oldSize))) {\n this.setSize(size);\n //
|
|
1
|
+
{"version":3,"file":"ol-test-support.js","sources":["ol-test-support.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { equals as extentEquals } from \"ol/extent\";\nimport OlMap from \"ol/Map\";\n\nlet setupDone = false;\n\n/** @internal */\nexport function patchOpenLayersClassesForTesting() {\n if (setupDone) {\n return;\n }\n\n // Test support: OpenLayers relies on div.offsetHeight (and Width)\n // plus getComputedStyle(div), which do not work as expected in happy dom.\n // The following snippet fakes a size so tests can work with the map.\n OlMap.prototype.updateSize = function () {\n const target = this.getTargetElement();\n const height = 500;\n const width = 500;\n const size = target ? [width, height] : undefined;\n const oldSize = this.getSize();\n if (size && (!oldSize || !extentEquals(size, oldSize))) {\n this.setSize(size);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).updateViewportSize_();\n }\n };\n setupDone = true;\n}\n"],"names":["extentEquals"],"mappings":";;;AAMA,IAAI,SAAA,GAAY,KAAA;AAGT,SAAS,gCAAA,GAAmC;AAC/C,EAAA,IAAI,SAAA,EAAW;AACX,IAAA;AAAA,EACJ;AAKA,EAAA,KAAA,CAAM,SAAA,CAAU,aAAa,WAAY;AACrC,IAAA,MAAM,MAAA,GAAS,KAAK,gBAAA,EAAiB;AACrC,IAAA,MAAM,MAAA,GAAS,GAAA;AACf,IAAA,MAAM,KAAA,GAAQ,GAAA;AACd,IAAA,MAAM,IAAA,GAAO,MAAA,GAAS,CAAC,KAAA,EAAO,MAAM,CAAA,GAAI,MAAA;AACxC,IAAA,MAAM,OAAA,GAAU,KAAK,OAAA,EAAQ;AAC7B,IAAA,IAAI,SAAS,CAAC,OAAA,IAAW,CAACA,MAAA,CAAa,IAAA,EAAM,OAAO,CAAA,CAAA,EAAI;AACpD,MAAA,IAAA,CAAK,QAAQ,IAAI,CAAA;AAEjB,MAAC,KAAa,mBAAA,EAAoB;AAAA,IACtC;AAAA,EACJ,CAAA;AACA,EAAA,SAAA,GAAY,IAAA;AAChB;;;;"}
|
package/utils/projections.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projections.js","sources":["projections.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { register } from \"ol/proj/proj4\";\nimport proj4 from \"proj4\";\n\n// Select return type of (name: string) => ProjectionDefinition overload since ProjectionDefinition is not exported\ntype Proj4ProjectionDefinition = typeof proj4.defs extends infer R\n ? R extends (name: string) => unknown\n ? ReturnType<R>\n : never\n : never;\n\n/** @group Utilities */\nexport type ProjectionDefinition = string | Proj4ProjectionDefinition;\n\n/**\n * Adds new registrations to the global [proj4js](https://github.com/proj4js/proj4js) definition set.\n *\n * See the proj4js documentation for more details.\n *\n * Example:\n *\n * ```ts\n * import { registerProjections } from \"@open-pioneer/map\";\n *\n * registerProjections({\n * \"EPSG:25832\": \"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\",\n * // ... more projections\n * });\n * ```\n *\n * @param projections\n * An object containing (key, definition) pairs. The key must be projection name (such as `\"EPSG:4326\"`).\n * The value can be a string defining the projection or an existing proj4 definition object.\n *\n * @group Utilities\n */\nexport function registerProjections(projections: Record<string, ProjectionDefinition>): void {\n for (const [name, definition] of Object.entries(projections)) {\n proj4.defs(name, definition);\n }\n //
|
|
1
|
+
{"version":3,"file":"projections.js","sources":["projections.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { register } from \"ol/proj/proj4\";\nimport proj4 from \"proj4\";\n\n// Select return type of (name: string) => ProjectionDefinition overload since ProjectionDefinition is not exported\ntype Proj4ProjectionDefinition = typeof proj4.defs extends infer R\n ? R extends (name: string) => unknown\n ? ReturnType<R>\n : never\n : never;\n\n/** @group Utilities */\nexport type ProjectionDefinition = string | Proj4ProjectionDefinition;\n\n/**\n * Adds new registrations to the global [proj4js](https://github.com/proj4js/proj4js) definition set.\n *\n * See the proj4js documentation for more details.\n *\n * Example:\n *\n * ```ts\n * import { registerProjections } from \"@open-pioneer/map\";\n *\n * registerProjections({\n * \"EPSG:25832\": \"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\",\n * // ... more projections\n * });\n * ```\n *\n * @param projections\n * An object containing (key, definition) pairs. The key must be projection name (such as `\"EPSG:4326\"`).\n * The value can be a string defining the projection or an existing proj4 definition object.\n *\n * @group Utilities\n */\nexport function registerProjections(projections: Record<string, ProjectionDefinition>): void {\n for (const [name, definition] of Object.entries(projections)) {\n proj4.defs(name, definition);\n }\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n register(proj4 as any);\n}\n\n/**\n * Searches the global [proj4js](https://github.com/proj4js/proj4js) definition set for a definition with the given name.\n *\n * @group Utilities\n */\nexport function getProjection(name: string): Proj4ProjectionDefinition {\n return proj4.defs(name);\n}\n"],"names":[],"mappings":";;;AAsCO,SAAS,oBAAoB,WAAA,EAAyD;AACzF,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,UAAU,KAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC1D,IAAA,KAAA,CAAM,IAAA,CAAK,MAAM,UAAU,CAAA;AAAA,EAC/B;AAEA,EAAA,QAAA,CAAS,KAAY,CAAA;AACzB;AAOO,SAAS,cAAc,IAAA,EAAyC;AACnE,EAAA,OAAO,KAAA,CAAM,KAAK,IAAI,CAAA;AAC1B;;;;"}
|
package/utils/sanitize.js.map
CHANGED
|
@@ -1 +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\";\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"],"names":[],"mappings":";;
|
|
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\n\nimport { Sanitizer } from \"@esri/arcgis-html-sanitizer\";\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"],"names":[],"mappings":";;AAKA,MAAM,SAAA,GAAY,IAAI,SAAA,EAAU;AAOzB,SAAS,aAAa,OAAA,EAAyB;AAClD,EAAA,OAAO,SAAA,CAAU,SAAS,OAAO,CAAA;AACrC;;;;"}
|