@open-pioneer/map 0.1.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +202 -0
  3. package/MapRegistryImpl.d.ts +15 -0
  4. package/MapRegistryImpl.js +89 -0
  5. package/MapRegistryImpl.js.map +1 -0
  6. package/README.md +653 -0
  7. package/_virtual/_virtual-pioneer-module_react-hooks.js +7 -0
  8. package/_virtual/_virtual-pioneer-module_react-hooks.js.map +1 -0
  9. package/api/MapConfig.d.ts +111 -0
  10. package/api/MapModel.d.ts +112 -0
  11. package/api/MapRegistry.d.ts +54 -0
  12. package/api/index.d.ts +12 -0
  13. package/api/layers/SimpleLayer.d.ts +24 -0
  14. package/api/layers/SimpleLayer.js +6 -0
  15. package/api/layers/SimpleLayer.js.map +1 -0
  16. package/api/layers/WMSLayer.d.ts +42 -0
  17. package/api/layers/WMSLayer.js +6 -0
  18. package/api/layers/WMSLayer.js.map +1 -0
  19. package/api/layers/base.d.ts +170 -0
  20. package/api/layers/index.d.ts +3 -0
  21. package/api/shared.d.ts +10 -0
  22. package/index.d.ts +1 -0
  23. package/index.js +11 -0
  24. package/index.js.map +1 -0
  25. package/layers/BkgTopPlusOpen.d.ts +21 -0
  26. package/layers/BkgTopPlusOpen.js +61 -0
  27. package/layers/BkgTopPlusOpen.js.map +1 -0
  28. package/model/AbstractLayer.d.ts +24 -0
  29. package/model/AbstractLayer.js +133 -0
  30. package/model/AbstractLayer.js.map +1 -0
  31. package/model/AbstractLayerBase.d.ts +37 -0
  32. package/model/AbstractLayerBase.js +106 -0
  33. package/model/AbstractLayerBase.js.map +1 -0
  34. package/model/LayerCollectionImpl.d.ts +27 -0
  35. package/model/LayerCollectionImpl.js +226 -0
  36. package/model/LayerCollectionImpl.js.map +1 -0
  37. package/model/MapModelImpl.d.ts +19 -0
  38. package/model/MapModelImpl.js +179 -0
  39. package/model/MapModelImpl.js.map +1 -0
  40. package/model/SublayersCollectionImpl.d.ts +15 -0
  41. package/model/SublayersCollectionImpl.js +29 -0
  42. package/model/SublayersCollectionImpl.js.map +1 -0
  43. package/model/createMapModel.d.ts +3 -0
  44. package/model/createMapModel.js +154 -0
  45. package/model/createMapModel.js.map +1 -0
  46. package/model/layers/SimpleLayerImpl.d.ts +9 -0
  47. package/model/layers/SimpleLayerImpl.js +10 -0
  48. package/model/layers/SimpleLayerImpl.js.map +1 -0
  49. package/model/layers/WMSLayerImpl.d.ts +29 -0
  50. package/model/layers/WMSLayerImpl.js +177 -0
  51. package/model/layers/WMSLayerImpl.js.map +1 -0
  52. package/package.json +67 -0
  53. package/projections.d.ts +27 -0
  54. package/projections.js +15 -0
  55. package/projections.js.map +1 -0
  56. package/services.d.ts +1 -0
  57. package/services.js +2 -0
  58. package/services.js.map +1 -0
  59. package/ui/MapAnchor.d.ts +49 -0
  60. package/ui/MapAnchor.js +91 -0
  61. package/ui/MapAnchor.js.map +1 -0
  62. package/ui/MapContainer.d.ts +60 -0
  63. package/ui/MapContainer.js +192 -0
  64. package/ui/MapContainer.js.map +1 -0
  65. package/ui/MapContext.d.ts +11 -0
  66. package/ui/MapContext.js +17 -0
  67. package/ui/MapContext.js.map +1 -0
  68. package/ui/hooks.d.ts +24 -0
  69. package/ui/hooks.js +73 -0
  70. package/ui/hooks.js.map +1 -0
  71. package/ui/styles.css +3 -0
  72. package/ui/styles.css.map +1 -0
  73. package/ui/useMapModel.d.ts +31 -0
  74. package/ui/useMapModel.js +21 -0
  75. package/ui/useMapModel.js.map +1 -0
  76. package/util/defer.d.ts +18 -0
  77. package/util/defer.js +21 -0
  78. package/util/defer.js.map +1 -0
  79. package/util/ol-test-support.d.ts +2 -0
  80. package/util/ol-test-support.js +24 -0
  81. package/util/ol-test-support.js.map +1 -0
@@ -0,0 +1,177 @@
1
+ import { createLogger } from '@open-pioneer/core';
2
+ import ImageLayer from 'ol/layer/Image';
3
+ import ImageWMS from 'ol/source/ImageWMS';
4
+ import { defer } from '../../util/defer.js';
5
+ import { AbstractLayer } from '../AbstractLayer.js';
6
+ import { AbstractLayerBase } from '../AbstractLayerBase.js';
7
+ import { SublayersCollectionImpl } from '../SublayersCollectionImpl.js';
8
+
9
+ const LOG = createLogger("map:WMSLayer");
10
+ class WMSLayerImpl extends AbstractLayer {
11
+ #url;
12
+ #sublayers;
13
+ #deferredSublayerUpdate;
14
+ #layer;
15
+ #source;
16
+ constructor(config) {
17
+ const layer = new ImageLayer();
18
+ super({
19
+ ...config,
20
+ olLayer: layer
21
+ });
22
+ const source = new ImageWMS({
23
+ ...config.sourceOptions,
24
+ url: config.url,
25
+ params: {
26
+ ...config.sourceOptions?.params
27
+ }
28
+ });
29
+ this.#url = config.url;
30
+ this.#source = source;
31
+ this.#layer = layer;
32
+ this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));
33
+ this.#updateLayersParam();
34
+ }
35
+ get url() {
36
+ return this.#url;
37
+ }
38
+ get sublayers() {
39
+ return this.#sublayers;
40
+ }
41
+ __attach(map) {
42
+ super.__attach(map);
43
+ for (const sublayer of this.#sublayers.getSublayers()) {
44
+ sublayer.__attach(map, this, this);
45
+ }
46
+ }
47
+ /** Called by the sublayers when their visibility changed. */
48
+ __updateSublayerVisibility() {
49
+ if (this.#deferredSublayerUpdate?.reschedule()) {
50
+ return;
51
+ }
52
+ this.#deferredSublayerUpdate = defer(() => {
53
+ try {
54
+ this.#updateLayersParam();
55
+ this.#deferredSublayerUpdate = void 0;
56
+ } catch (e) {
57
+ LOG.error(`Failed to update sublayer visibility on WMS layer '${this.id}'.`, e);
58
+ }
59
+ });
60
+ }
61
+ /**
62
+ * Gathers the visibility of _all_ sublayers and assembles the 'layers' WMS parameter.
63
+ * The parameters are then applied to the WMS source.
64
+ */
65
+ #updateLayersParam() {
66
+ const layers = this.#getVisibleLayerNames();
67
+ this.#source.updateParams({
68
+ "LAYERS": layers
69
+ });
70
+ const source = layers.length === 0 ? null : this.#source;
71
+ if (this.#layer.getSource() !== source) {
72
+ this.#layer.setSource(source);
73
+ }
74
+ }
75
+ #getVisibleLayerNames() {
76
+ const layers = [];
77
+ const visitSublayer = (sublayer) => {
78
+ if (!sublayer.visible) {
79
+ return;
80
+ }
81
+ const nestedSublayers = sublayer.sublayers.__getRawSublayers();
82
+ if (nestedSublayers.length) {
83
+ for (const nestedSublayer of nestedSublayers) {
84
+ visitSublayer(nestedSublayer);
85
+ }
86
+ } else {
87
+ layers.push(sublayer.name);
88
+ }
89
+ };
90
+ for (const sublayer of this.sublayers.__getRawSublayers()) {
91
+ visitSublayer(sublayer);
92
+ }
93
+ return layers;
94
+ }
95
+ }
96
+ class WMSSublayerImpl extends AbstractLayerBase {
97
+ #parent;
98
+ #parentLayer;
99
+ #name;
100
+ #sublayers;
101
+ #visible;
102
+ constructor(config) {
103
+ super(config);
104
+ this.#name = config.name;
105
+ this.#visible = config.visible ?? true;
106
+ this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));
107
+ }
108
+ get name() {
109
+ return this.#name;
110
+ }
111
+ get sublayers() {
112
+ return this.#sublayers;
113
+ }
114
+ get parent() {
115
+ const parent = this.#parent;
116
+ if (!parent) {
117
+ throw new Error(`WMS sublayer ${this.id} has not been attached to its parent yet.`);
118
+ }
119
+ return parent;
120
+ }
121
+ get parentLayer() {
122
+ const parentLayer = this.#parentLayer;
123
+ if (!parentLayer) {
124
+ throw new Error(`WMS sublayer ${this.id} has not been attached to its parent yet.`);
125
+ }
126
+ return parentLayer;
127
+ }
128
+ /**
129
+ * Called by the parent layer when it is attached to the map to attach all sublayers.
130
+ */
131
+ __attach(map, parentLayer, parent) {
132
+ super.__attachToMap(map);
133
+ if (this.#parent) {
134
+ throw new Error(
135
+ `WMS sublayer '${this.id}' has already been attached to parent '${this.#parent.id}'`
136
+ );
137
+ }
138
+ this.#parent = parent;
139
+ if (this.#parentLayer) {
140
+ throw new Error(
141
+ `WMS sublayer '${this.id}' has already been attached to parent layer '${this.#parentLayer.id}'`
142
+ );
143
+ }
144
+ this.#parentLayer = parentLayer;
145
+ for (const sublayer of this.sublayers.__getRawSublayers()) {
146
+ sublayer.__attach(map, parentLayer, this);
147
+ }
148
+ }
149
+ get visible() {
150
+ return this.#visible;
151
+ }
152
+ setVisible(newVisibility) {
153
+ if (this.visible !== newVisibility) {
154
+ this.#visible = newVisibility;
155
+ this.#parentLayer?.__updateSublayerVisibility();
156
+ this.__emitChangeEvent("changed:visible");
157
+ }
158
+ }
159
+ }
160
+ function constructSublayers(sublayerConfigs = []) {
161
+ const sublayers = [];
162
+ try {
163
+ for (const sublayerConfig of sublayerConfigs) {
164
+ sublayers.push(new WMSSublayerImpl(sublayerConfig));
165
+ }
166
+ return sublayers;
167
+ } catch (e) {
168
+ while (sublayers.length) {
169
+ const layer = sublayers.pop();
170
+ layer?.destroy();
171
+ }
172
+ throw new Error("Failed to construct sublayers.", { cause: e });
173
+ }
174
+ }
175
+
176
+ export { WMSLayerImpl };
177
+ //# sourceMappingURL=WMSLayerImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WMSLayerImpl.js","sources":["WMSLayerImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport ImageLayer from \"ol/layer/Image\";\nimport type ImageSource from \"ol/source/Image\";\nimport ImageWMS from \"ol/source/ImageWMS\";\nimport { Sublayer, WMSLayerConfig, WMSLayer, WMSSublayerConfig } from \"../../api\";\nimport { DeferredExecution, defer } from \"../../util/defer\";\nimport { AbstractLayer } from \"../AbstractLayer\";\nimport { AbstractLayerBase } from \"../AbstractLayerBase\";\nimport { MapModelImpl } from \"../MapModelImpl\";\nimport { SublayersCollectionImpl } from \"../SublayersCollectionImpl\";\n\nconst LOG = createLogger(\"map:WMSLayer\");\n\nexport class WMSLayerImpl extends AbstractLayer implements WMSLayer {\n #url: string;\n #sublayers: SublayersCollectionImpl<WMSSublayerImpl>;\n #deferredSublayerUpdate: DeferredExecution | undefined;\n #layer: ImageLayer<ImageSource>;\n #source: ImageWMS;\n\n constructor(config: WMSLayerConfig) {\n const layer = new ImageLayer();\n super({\n ...config,\n olLayer: layer\n });\n const source = new ImageWMS({\n ...config.sourceOptions,\n url: config.url,\n params: {\n ...config.sourceOptions?.params\n }\n });\n this.#url = config.url;\n this.#source = source;\n this.#layer = layer;\n this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));\n this.#updateLayersParam();\n }\n\n get url(): string {\n return this.#url;\n }\n\n get sublayers(): SublayersCollectionImpl<WMSSublayerImpl> {\n return this.#sublayers;\n }\n\n __attach(map: MapModelImpl): void {\n super.__attach(map);\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer.__attach(map, this, this);\n }\n }\n\n /** Called by the sublayers when their visibility changed. */\n __updateSublayerVisibility() {\n if (this.#deferredSublayerUpdate?.reschedule()) {\n return;\n }\n this.#deferredSublayerUpdate = defer(() => {\n try {\n this.#updateLayersParam();\n this.#deferredSublayerUpdate = undefined;\n } catch (e) {\n LOG.error(`Failed to update sublayer visibility on WMS layer '${this.id}'.`, e);\n }\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() {\n const layers = this.#getVisibleLayerNames();\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: WMSSublayerImpl) => {\n if (!sublayer.visible) {\n return;\n }\n\n const nestedSublayers = sublayer.sublayers.__getRawSublayers();\n if (nestedSublayers.length) {\n for (const nestedSublayer of nestedSublayers) {\n visitSublayer(nestedSublayer);\n }\n } else {\n layers.push(sublayer.name);\n }\n };\n\n for (const sublayer of this.sublayers.__getRawSublayers()) {\n visitSublayer(sublayer);\n }\n return layers;\n }\n}\n\nclass WMSSublayerImpl extends AbstractLayerBase implements Sublayer {\n #parent: WMSSublayerImpl | WMSLayerImpl | undefined;\n #parentLayer: WMSLayerImpl | undefined;\n #name: string;\n #sublayers: SublayersCollectionImpl<WMSSublayerImpl>;\n #visible: boolean;\n\n constructor(config: WMSSublayerConfig) {\n super(config);\n this.#name = config.name;\n this.#visible = config.visible ?? true;\n this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));\n }\n\n get name(): string {\n return this.#name;\n }\n\n get sublayers(): SublayersCollectionImpl<WMSSublayerImpl> {\n return this.#sublayers;\n }\n\n get parent(): WMSSublayerImpl | WMSLayerImpl {\n const parent = this.#parent;\n if (!parent) {\n throw new Error(`WMS sublayer ${this.id} has not been attached to its parent yet.`);\n }\n return parent;\n }\n\n get parentLayer(): WMSLayerImpl {\n const parentLayer = this.#parentLayer;\n if (!parentLayer) {\n throw new Error(`WMS sublayer ${this.id} has not been attached to its parent yet.`);\n }\n return parentLayer;\n }\n\n /**\n * Called by the parent layer when it is attached to the map to attach all sublayers.\n */\n __attach(\n map: MapModelImpl,\n parentLayer: WMSLayerImpl,\n parent: WMSLayerImpl | WMSSublayerImpl\n ): void {\n super.__attachToMap(map);\n if (this.#parent) {\n throw new Error(\n `WMS sublayer '${this.id}' has already been attached to parent '${this.#parent.id}'`\n );\n }\n this.#parent = parent;\n if (this.#parentLayer) {\n throw new Error(\n `WMS sublayer '${this.id}' has already been attached to parent layer '${\n this.#parentLayer.id\n }'`\n );\n }\n this.#parentLayer = parentLayer;\n\n // Recurse into nested sublayers\n for (const sublayer of this.sublayers.__getRawSublayers()) {\n sublayer.__attach(map, parentLayer, this);\n }\n }\n\n get visible(): boolean {\n return this.#visible;\n }\n\n setVisible(newVisibility: boolean): void {\n if (this.visible !== newVisibility) {\n this.#visible = newVisibility;\n this.#parentLayer?.__updateSublayerVisibility();\n this.__emitChangeEvent(\"changed:visible\");\n }\n }\n}\n\nfunction constructSublayers(sublayerConfigs: WMSSublayerConfig[] = []): WMSSublayerImpl[] {\n const sublayers: WMSSublayerImpl[] = [];\n try {\n for (const sublayerConfig of sublayerConfigs) {\n sublayers.push(new WMSSublayerImpl(sublayerConfig));\n }\n return sublayers;\n } catch (e) {\n // Ensure previous sublayers are destroyed if a single constructor throws\n while (sublayers.length) {\n const layer = sublayers.pop()!;\n layer?.destroy();\n }\n throw new Error(\"Failed to construct sublayers.\", { cause: e });\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAaA,MAAM,GAAA,GAAM,aAAa,cAAc,CAAA,CAAA;AAEhC,MAAM,qBAAqB,aAAkC,CAAA;AAAA,EAChE,IAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EACA,uBAAA,CAAA;AAAA,EACA,MAAA,CAAA;AAAA,EACA,OAAA,CAAA;AAAA,EAEA,YAAY,MAAwB,EAAA;AAChC,IAAM,MAAA,KAAA,GAAQ,IAAI,UAAW,EAAA,CAAA;AAC7B,IAAM,KAAA,CAAA;AAAA,MACF,GAAG,MAAA;AAAA,MACH,OAAS,EAAA,KAAA;AAAA,KACZ,CAAA,CAAA;AACD,IAAM,MAAA,MAAA,GAAS,IAAI,QAAS,CAAA;AAAA,MACxB,GAAG,MAAO,CAAA,aAAA;AAAA,MACV,KAAK,MAAO,CAAA,GAAA;AAAA,MACZ,MAAQ,EAAA;AAAA,QACJ,GAAG,OAAO,aAAe,EAAA,MAAA;AAAA,OAC7B;AAAA,KACH,CAAA,CAAA;AACD,IAAA,IAAA,CAAK,OAAO,MAAO,CAAA,GAAA,CAAA;AACnB,IAAA,IAAA,CAAK,OAAU,GAAA,MAAA,CAAA;AACf,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA,CAAA;AACd,IAAA,IAAA,CAAK,aAAa,IAAI,uBAAA,CAAwB,kBAAmB,CAAA,MAAA,CAAO,SAAS,CAAC,CAAA,CAAA;AAClF,I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AAO,GAAG,CAAA,CAAA;AAAA,GAClE;AACJ;;;;"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "type": "module",
3
+ "name": "@open-pioneer/map",
4
+ "version": "0.1.0",
5
+ "license": "Apache-2.0",
6
+ "dependencies": {
7
+ "uuid": "^9.0.0"
8
+ },
9
+ "peerDependencies": {
10
+ "@open-pioneer/chakra-integration": "^1.1.0",
11
+ "@open-pioneer/core": "^1.1.0",
12
+ "@open-pioneer/runtime": "^1.1.0",
13
+ "@types/proj4": "^2.5.2",
14
+ "ol": "^8.2.0",
15
+ "proj4": "^2.9.0",
16
+ "react": "^18.2.0",
17
+ "react-dom": "^18.2.0",
18
+ "react-use": "^17.4.0",
19
+ "@open-pioneer/react-utils": "^0.1.0"
20
+ },
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": {
24
+ "import": "./index.js",
25
+ "types": "./index.d.ts"
26
+ },
27
+ "./services": {
28
+ "import": "./services.js",
29
+ "types": "./services.d.ts"
30
+ },
31
+ "./ui/styles.css": "./ui/styles.css"
32
+ },
33
+ "openPioneerFramework": {
34
+ "styles": "./ui/styles.css",
35
+ "services": [
36
+ {
37
+ "serviceName": "MapRegistryImpl",
38
+ "provides": [
39
+ {
40
+ "interfaceName": "map.MapRegistry"
41
+ }
42
+ ],
43
+ "references": [
44
+ {
45
+ "referenceName": "providers",
46
+ "type": "all",
47
+ "interfaceName": "map.MapConfigProvider"
48
+ }
49
+ ]
50
+ }
51
+ ],
52
+ "servicesModule": "./services",
53
+ "i18n": {
54
+ "languages": []
55
+ },
56
+ "ui": {
57
+ "references": [
58
+ {
59
+ "type": "unique",
60
+ "interfaceName": "map.MapRegistry"
61
+ }
62
+ ]
63
+ },
64
+ "properties": [],
65
+ "packageFormatVersion": "1.0.0"
66
+ }
67
+ }
@@ -0,0 +1,27 @@
1
+ import { ProjectionDefinition as Proj4ProjectionDefinition } from "proj4";
2
+ export type ProjectionDefinition = string | Proj4ProjectionDefinition;
3
+ /**
4
+ * Adds new registrations to the global [proj4js](https://github.com/proj4js/proj4js) definition set.
5
+ *
6
+ * See the proj4js documentation for more details.
7
+ *
8
+ * Example:
9
+ *
10
+ * ```ts
11
+ * import { registerProjections } from "@open-pioneer/map";
12
+ *
13
+ * registerProjections({
14
+ * "EPSG:25832": "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs",
15
+ * // ... more projections
16
+ * });
17
+ * ```
18
+ *
19
+ * @param projections
20
+ * An object containing (key, definition) pairs. The key must be projection name (such as `"EPSG:4326"`).
21
+ * The value can be a string defining the projection or an existing proj4 definition object.
22
+ */
23
+ export declare function registerProjections(projections: Record<string, ProjectionDefinition>): void;
24
+ /**
25
+ * Searches the global [proj4js](https://github.com/proj4js/proj4js) definition set for a definition with the given name.
26
+ */
27
+ export declare function getProjection(name: string): Proj4ProjectionDefinition;
package/projections.js ADDED
@@ -0,0 +1,15 @@
1
+ import { register } from 'ol/proj/proj4';
2
+ import proj4 from 'proj4';
3
+
4
+ function registerProjections(projections) {
5
+ for (const [name, definition] of Object.entries(projections)) {
6
+ proj4.defs(name, definition);
7
+ }
8
+ register(proj4);
9
+ }
10
+ function getProjection(name) {
11
+ return proj4.defs(name);
12
+ }
13
+
14
+ export { getProjection, registerProjections };
15
+ //# sourceMappingURL=projections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projections.js","sources":["projections.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { register } from \"ol/proj/proj4\";\nimport proj4, { ProjectionDefinition as Proj4ProjectionDefinition } from \"proj4\";\n\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 */\nexport function registerProjections(projections: Record<string, ProjectionDefinition>): void {\n for (const [name, definition] of Object.entries(projections)) {\n proj4.defs(name, definition);\n }\n register(proj4);\n}\n\n/**\n * Searches the global [proj4js](https://github.com/proj4js/proj4js) definition set for a definition with the given name.\n */\nexport function getProjection(name: string): Proj4ProjectionDefinition {\n return proj4.defs(name);\n}\n"],"names":[],"mappings":";;;AA2BO,SAAS,oBAAoB,WAAyD,EAAA;AACzF,EAAA,KAAA,MAAW,CAAC,IAAM,EAAA,UAAU,KAAK,MAAO,CAAA,OAAA,CAAQ,WAAW,CAAG,EAAA;AAC1D,IAAM,KAAA,CAAA,IAAA,CAAK,MAAM,UAAU,CAAA,CAAA;AAAA,GAC/B;AACA,EAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAClB,CAAA;AAKO,SAAS,cAAc,IAAyC,EAAA;AACnE,EAAO,OAAA,KAAA,CAAM,KAAK,IAAI,CAAA,CAAA;AAC1B;;;;"}
package/services.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { MapRegistryImpl } from "./MapRegistryImpl";
package/services.js ADDED
@@ -0,0 +1,2 @@
1
+ export { MapRegistryImpl } from './MapRegistryImpl.js';
2
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,49 @@
1
+ import { StyleProps } from "@open-pioneer/chakra-integration";
2
+ import { CommonComponentProps } from "@open-pioneer/react-utils";
3
+ import { ReactNode } from "react";
4
+ import { MapPadding } from "./MapContainer";
5
+ export type MapAnchorPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
6
+ export interface MapAnchorProps extends CommonComponentProps {
7
+ /**
8
+ * The position of the anchor container above the map.
9
+ * @default "top-right"
10
+ */
11
+ position?: MapAnchorPosition;
12
+ /**
13
+ * Horizontal gap in pixel applied to anchor container.
14
+ *
15
+ * Applied:
16
+ * - left, if position `*-left`
17
+ * - right, if position `*-right`
18
+ *
19
+ * @default 0
20
+ */
21
+ horizontalGap?: number;
22
+ /**
23
+ * Vertical gap in pixel applied to anchor container.
24
+ *
25
+ * Applied:
26
+ * - top, if position `top-*`
27
+ * - bottom, if position `bottom-*`
28
+ *
29
+ * @default 0 (If position `bottom-*`, default verticalGap == `30`)
30
+ */
31
+ verticalGap?: number;
32
+ /**
33
+ * Prevent some events from the map anchor's children from bubbling towards the map, effectively hiding them from map interactions.
34
+ * Defaults to `true`.
35
+ *
36
+ * If this value is enabled, events such as `pointer-down` are hidden from the map when they occur
37
+ * within the map anchor.
38
+ * This is essential when the user wants to select text, or open the browser context menu within the anchor.
39
+ * If that is not required, set `stopEvents` to `false` instead.
40
+ */
41
+ stopEvents?: boolean;
42
+ children?: ReactNode;
43
+ }
44
+ export declare function MapAnchor(props: MapAnchorProps): JSX.Element;
45
+ export declare function computeAttributionGap(verticalGap?: number): {
46
+ gap: number;
47
+ space: number;
48
+ };
49
+ export declare function computePositionStyles(position: MapAnchorPosition, padding: Required<MapPadding>, horizontalGap?: number | undefined, verticalGap?: number | undefined): StyleProps;
@@ -0,0 +1,91 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Box } from '@open-pioneer/chakra-integration';
3
+ import { useCommonComponentProps } from '@open-pioneer/react-utils';
4
+ import { useMemo } from 'react';
5
+ import { createPortal } from 'react-dom';
6
+ import { useMapContext } from './MapContext.js';
7
+
8
+ const defaultPosition = "top-right";
9
+ function MapAnchor(props) {
10
+ const {
11
+ position = defaultPosition,
12
+ stopEvents = true,
13
+ children,
14
+ horizontalGap,
15
+ verticalGap
16
+ } = props;
17
+ const { containerProps } = useCommonComponentProps("map-anchor", props);
18
+ const { padding, mapAnchorsHost } = useMapContext();
19
+ const eventHandlers = useMemo(() => {
20
+ const stopHandler = stopEvents ? stopPropagation : void 0;
21
+ return {
22
+ onPointerDown: stopHandler,
23
+ onPointerUp: stopHandler,
24
+ onContextMenu: stopHandler
25
+ };
26
+ }, [stopEvents]);
27
+ return createPortal(
28
+ /* @__PURE__ */ jsx(
29
+ Box,
30
+ {
31
+ ...containerProps,
32
+ pointerEvents: "auto",
33
+ userSelect: "text",
34
+ ...eventHandlers,
35
+ ...computePositionStyles(position, padding, horizontalGap, verticalGap),
36
+ children
37
+ }
38
+ ),
39
+ mapAnchorsHost
40
+ );
41
+ }
42
+ function computeAttributionGap(verticalGap) {
43
+ const height = 20;
44
+ const space = 10;
45
+ return {
46
+ gap: verticalGap === void 0 ? height + space : 0,
47
+ space
48
+ };
49
+ }
50
+ function computePositionStyles(position, padding, horizontalGap, verticalGap) {
51
+ const props = {
52
+ position: "absolute",
53
+ transitionProperty: "left, right, top, bottom",
54
+ transitionDuration: "200ms",
55
+ transitionTimingFunction: "ease-out"
56
+ };
57
+ const defaultHorizontalGap = 0;
58
+ const horizontal = horizontalGap ?? defaultHorizontalGap;
59
+ const defaultVerticalGap = 0;
60
+ const vertical = verticalGap ?? defaultVerticalGap;
61
+ const attribution = computeAttributionGap(verticalGap);
62
+ const gap = (n) => `${n}px`;
63
+ switch (position) {
64
+ case "top-left":
65
+ props.left = gap(padding.left + horizontal);
66
+ props.top = gap(padding.top + vertical);
67
+ break;
68
+ case "top-right":
69
+ props.right = gap(padding.right + horizontal);
70
+ props.top = gap(padding.top + vertical);
71
+ break;
72
+ case "bottom-left":
73
+ props.left = gap(padding.left + horizontal);
74
+ props.bottom = gap(padding.bottom + vertical + attribution.gap);
75
+ break;
76
+ case "bottom-right":
77
+ props.right = gap(padding.right + horizontal);
78
+ props.bottom = gap(padding.bottom + vertical + attribution.gap);
79
+ break;
80
+ }
81
+ props.maxH = `calc((100%) - ${props.top ?? "0px"} - ${props.bottom ?? attribution.gap + "px"} - ${vertical + "px"} - ${attribution.space + "px"})`;
82
+ props.maxW = `calc((100%) - ${props.left ?? "0px"} - ${props.right ?? "0px"} - ${horizontal + "px"})`;
83
+ props.overflow = "hidden";
84
+ return props;
85
+ }
86
+ function stopPropagation(e) {
87
+ e.stopPropagation();
88
+ }
89
+
90
+ export { MapAnchor, computeAttributionGap, computePositionStyles };
91
+ //# sourceMappingURL=MapAnchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapAnchor.js","sources":["MapAnchor.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, BoxProps, StyleProps } from \"@open-pioneer/chakra-integration\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { BaseSyntheticEvent, ReactNode, useMemo } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { MapPadding } from \"./MapContainer\";\nimport { useMapContext } from \"./MapContext\";\n\nexport type MapAnchorPosition = \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n\nconst defaultPosition: MapAnchorPosition = \"top-right\";\n\nexport interface MapAnchorProps extends CommonComponentProps {\n /**\n * The position of the anchor container above the map.\n * @default \"top-right\"\n */\n position?: MapAnchorPosition;\n\n /**\n * Horizontal gap in pixel applied to anchor container.\n *\n * Applied:\n * - left, if position `*-left`\n * - right, if position `*-right`\n *\n * @default 0\n */\n horizontalGap?: number;\n\n /**\n * Vertical gap in pixel applied to anchor container.\n *\n * Applied:\n * - top, if position `top-*`\n * - bottom, if position `bottom-*`\n *\n * @default 0 (If position `bottom-*`, default verticalGap == `30`)\n */\n verticalGap?: number;\n\n /**\n * Prevent some events from the map anchor's children from bubbling towards the map, effectively hiding them from map interactions.\n * Defaults to `true`.\n *\n * If this value is enabled, events such as `pointer-down` are hidden from the map when they occur\n * within the map anchor.\n * This is essential when the user wants to select text, or open the browser context menu within the anchor.\n * If that is not required, set `stopEvents` to `false` instead.\n */\n stopEvents?: boolean;\n\n children?: ReactNode;\n}\n\nexport function MapAnchor(props: MapAnchorProps): JSX.Element {\n const {\n position = defaultPosition,\n stopEvents = true,\n children,\n horizontalGap,\n verticalGap\n } = props;\n const { containerProps } = useCommonComponentProps(\"map-anchor\", props);\n const { padding, mapAnchorsHost } = useMapContext();\n\n const eventHandlers: Partial<BoxProps> = useMemo(() => {\n const stopHandler = stopEvents ? stopPropagation : undefined;\n return {\n onPointerDown: stopHandler,\n onPointerUp: stopHandler,\n onContextMenu: stopHandler\n };\n }, [stopEvents]);\n\n return createPortal(\n <Box\n {...containerProps}\n /* Overlay container uses pointer-events: none, this restores interactivity */\n pointerEvents=\"auto\"\n /* Restore user-select: none set by ol-viewport parent */\n userSelect=\"text\"\n /** Hide pointer up/down and context menu events from the map parent. */\n {...eventHandlers}\n {...computePositionStyles(position, padding, horizontalGap, verticalGap)}\n >\n {children}\n </Box>,\n mapAnchorsHost\n );\n}\n\nexport function computeAttributionGap(verticalGap?: number): {\n gap: number;\n space: number;\n} {\n /**\n * height of the ol attribution component\n * improvement: Get height directly from `Attribution` HTMLDivElement\n */\n const height = 20;\n\n /**\n * additional space between attribution and map anchor container\n */\n const space = 10;\n\n return {\n gap: verticalGap === undefined ? height + space : 0,\n space\n };\n}\n\nexport function computePositionStyles(\n position: MapAnchorPosition,\n padding: Required<MapPadding>,\n horizontalGap?: number | undefined,\n verticalGap?: number | undefined\n): StyleProps {\n const props: StyleProps = {\n position: \"absolute\",\n transitionProperty: \"left, right, top, bottom\",\n transitionDuration: \"200ms\",\n transitionTimingFunction: \"ease-out\"\n };\n\n const defaultHorizontalGap = 0;\n const horizontal = horizontalGap ?? defaultHorizontalGap;\n\n const defaultVerticalGap = 0;\n const vertical = verticalGap ?? defaultVerticalGap;\n\n const attribution = computeAttributionGap(verticalGap);\n const gap = (n: number) => `${n}px`;\n\n switch (position) {\n case \"top-left\":\n props.left = gap(padding.left + horizontal);\n props.top = gap(padding.top + vertical);\n break;\n case \"top-right\":\n props.right = gap(padding.right + horizontal);\n props.top = gap(padding.top + vertical);\n break;\n case \"bottom-left\":\n props.left = gap(padding.left + horizontal);\n props.bottom = gap(padding.bottom + vertical + attribution.gap);\n break;\n case \"bottom-right\":\n props.right = gap(padding.right + horizontal);\n props.bottom = gap(padding.bottom + vertical + attribution.gap);\n break;\n }\n\n /**\n * Apply max-height and max-width to MapAnchor to avoid content overflow\n */\n props.maxH = `calc((100%) - ${props.top ?? \"0px\"} - ${\n props.bottom ?? attribution.gap + \"px\"\n } - ${vertical + \"px\"} - ${attribution.space + \"px\"})`;\n\n props.maxW = `calc((100%) - ${props.left ?? \"0px\"} - ${props.right ?? \"0px\"} - ${\n horizontal + \"px\"\n })`;\n props.overflow = \"hidden\";\n\n return props;\n}\n\nfunction stopPropagation(e: BaseSyntheticEvent) {\n e.stopPropagation();\n}\n"],"names":[],"mappings":";;;;;;;AAWA,MAAM,eAAqC,GAAA,WAAA,CAAA;AA6CpC,SAAS,UAAU,KAAoC,EAAA;AAC1D,EAAM,MAAA;AAAA,IACF,QAAW,GAAA,eAAA;AAAA,IACX,UAAa,GAAA,IAAA;AAAA,IACb,QAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA;AAAA,GACA,GAAA,KAAA,CAAA;AACJ,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,cAAc,KAAK,CAAA,CAAA;AACtE,EAAA,MAAM,EAAE,OAAA,EAAS,cAAe,EAAA,GAAI,aAAc,EAAA,CAAA;AAElD,EAAM,MAAA,aAAA,GAAmC,QAAQ,MAAM;AACnD,IAAM,MAAA,WAAA,GAAc,aAAa,eAAkB,GAAA,KAAA,CAAA,CAAA;AACnD,IAAO,OAAA;AAAA,MACH,aAAe,EAAA,WAAA;AAAA,MACf,WAAa,EAAA,WAAA;AAAA,MACb,aAAe,EAAA,WAAA;AAAA,KACnB,CAAA;AAAA,GACJ,EAAG,CAAC,UA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A,GAAO,CAAiB,cAAA,EAAA,KAAA,CAAM,IAAQ,IAAA,KAAK,CAAM,GAAA,EAAA,KAAA,CAAM,KAAS,IAAA,KAAK,CACvE,GAAA,EAAA,UAAA,GAAa,IACjB,CAAA,CAAA,CAAA,CAAA;AACA,EAAA,KAAA,CAAM,QAAW,GAAA,QAAA,CAAA;AAEjB,EAAO,OAAA,KAAA,CAAA;AACX,CAAA;AAEA,SAAS,gBAAgB,CAAuB,EAAA;AAC5C,EAAA,CAAA,CAAE,eAAgB,EAAA,CAAA;AACtB;;;;"}
@@ -0,0 +1,60 @@
1
+ import { CommonComponentProps } from "@open-pioneer/react-utils";
2
+ import { ReactNode } from "react";
3
+ /**
4
+ * Map padding, all values are pixels.
5
+ *
6
+ * See https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding
7
+ */
8
+ export interface MapPadding {
9
+ left?: number;
10
+ right?: number;
11
+ top?: number;
12
+ bottom?: number;
13
+ }
14
+ export interface MapContainerProps extends CommonComponentProps {
15
+ /** The id of the map to display. */
16
+ mapId: string;
17
+ /**
18
+ * Sets the map's padding directly.
19
+ *
20
+ * See: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)
21
+ */
22
+ viewPadding?: MapPadding | undefined;
23
+ /**
24
+ * Behavior performed by the map when the view padding changes.
25
+ *
26
+ * - `none`: Do nothing.
27
+ * - `preserve-center`: Ensures that the center point remains the same by animating the view.
28
+ * - `preserve-extent`: Ensures that the extent remains the same by zooming.
29
+ *
30
+ * @default "preserve-center"
31
+ */
32
+ viewPaddingChangeBehavior?: "none" | "preserve-center" | "preserve-extent";
33
+ children?: ReactNode;
34
+ /**
35
+ * Optional role property.
36
+ *
37
+ * This property is directly applied to the map's container div element.
38
+ */
39
+ role?: string;
40
+ /**
41
+ * Optional aria-labelledby property.
42
+ * Do not use together with aria-label.
43
+ *
44
+ * This property is directly applied to the map's container div element.
45
+ */
46
+ "aria-labelledby"?: string;
47
+ /**
48
+ * Optional aria-label property.
49
+ * Do not use together with aria-label.
50
+ *
51
+ * This property is directly applied to the map's container div element.
52
+ */
53
+ "aria-label"?: string;
54
+ }
55
+ /**
56
+ * Displays the map with the given id.
57
+ *
58
+ * There can only be at most one MapContainer for every map.
59
+ */
60
+ export declare function MapContainer(props: MapContainerProps): import("react/jsx-runtime").JSX.Element;