@vcmap/core 5.0.0-rc.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 (146) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +44 -0
  3. package/build/postinstall.js +44 -0
  4. package/index.js +139 -0
  5. package/package.json +92 -0
  6. package/src/cesium/cesium3DTileFeature.js +9 -0
  7. package/src/cesium/cesium3DTilePointFeature.js +9 -0
  8. package/src/cesium/cesiumVcsCameraPrimitive.js +146 -0
  9. package/src/cesium/wallpaperMaterial.js +64 -0
  10. package/src/ol/feature.js +47 -0
  11. package/src/ol/geom/circle.js +24 -0
  12. package/src/ol/geom/geometryCollection.js +33 -0
  13. package/src/ol/render/canvas/canvasTileRenderer.js +179 -0
  14. package/src/ol/source/ClusterEnhancedVectorSource.js +39 -0
  15. package/src/ol/source/VcsCluster.js +37 -0
  16. package/src/vcs/vcm/classRegistry.js +106 -0
  17. package/src/vcs/vcm/event/vcsEvent.js +89 -0
  18. package/src/vcs/vcm/globalCollections.js +11 -0
  19. package/src/vcs/vcm/interaction/abstractInteraction.js +149 -0
  20. package/src/vcs/vcm/interaction/coordinateAtPixel.js +102 -0
  21. package/src/vcs/vcm/interaction/eventHandler.js +425 -0
  22. package/src/vcs/vcm/interaction/featureAtPixelInteraction.js +286 -0
  23. package/src/vcs/vcm/interaction/featureProviderInteraction.js +54 -0
  24. package/src/vcs/vcm/interaction/interactionChain.js +124 -0
  25. package/src/vcs/vcm/interaction/interactionType.js +114 -0
  26. package/src/vcs/vcm/layer/buildings.js +17 -0
  27. package/src/vcs/vcm/layer/cesium/cesiumTilesetCesium.js +359 -0
  28. package/src/vcs/vcm/layer/cesium/clusterContext.js +95 -0
  29. package/src/vcs/vcm/layer/cesium/dataSourceCesium.js +171 -0
  30. package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +29 -0
  31. package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +58 -0
  32. package/src/vcs/vcm/layer/cesium/rasterLayerCesium.js +110 -0
  33. package/src/vcs/vcm/layer/cesium/singleImageCesium.js +49 -0
  34. package/src/vcs/vcm/layer/cesium/terrainCesium.js +80 -0
  35. package/src/vcs/vcm/layer/cesium/tmsCesium.js +54 -0
  36. package/src/vcs/vcm/layer/cesium/vectorCesium.js +255 -0
  37. package/src/vcs/vcm/layer/cesium/vectorContext.js +167 -0
  38. package/src/vcs/vcm/layer/cesium/vectorRasterTileCesium.js +116 -0
  39. package/src/vcs/vcm/layer/cesium/vectorTileImageryProvider.js +246 -0
  40. package/src/vcs/vcm/layer/cesium/wmsCesium.js +71 -0
  41. package/src/vcs/vcm/layer/cesium/wmtsCesium.js +101 -0
  42. package/src/vcs/vcm/layer/cesium/x3dmHelper.js +22 -0
  43. package/src/vcs/vcm/layer/cesiumTileset.js +376 -0
  44. package/src/vcs/vcm/layer/czml.js +141 -0
  45. package/src/vcs/vcm/layer/dataSource.js +259 -0
  46. package/src/vcs/vcm/layer/featureLayer.js +261 -0
  47. package/src/vcs/vcm/layer/featureStore.js +647 -0
  48. package/src/vcs/vcm/layer/featureStoreChanges.js +360 -0
  49. package/src/vcs/vcm/layer/featureStoreState.js +19 -0
  50. package/src/vcs/vcm/layer/featureVisibility.js +435 -0
  51. package/src/vcs/vcm/layer/geojson.js +185 -0
  52. package/src/vcs/vcm/layer/geojsonHelpers.js +450 -0
  53. package/src/vcs/vcm/layer/globalHider.js +157 -0
  54. package/src/vcs/vcm/layer/layer.js +752 -0
  55. package/src/vcs/vcm/layer/layerImplementation.js +102 -0
  56. package/src/vcs/vcm/layer/layerState.js +17 -0
  57. package/src/vcs/vcm/layer/layerSymbols.js +6 -0
  58. package/src/vcs/vcm/layer/oblique/layerOblique.js +76 -0
  59. package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +175 -0
  60. package/src/vcs/vcm/layer/oblique/vectorOblique.js +469 -0
  61. package/src/vcs/vcm/layer/openStreetMap.js +194 -0
  62. package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +79 -0
  63. package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +27 -0
  64. package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +121 -0
  65. package/src/vcs/vcm/layer/openlayers/singleImageOpenlayers.js +49 -0
  66. package/src/vcs/vcm/layer/openlayers/tileDebugOpenlayers.js +39 -0
  67. package/src/vcs/vcm/layer/openlayers/tmsOpenlayers.js +62 -0
  68. package/src/vcs/vcm/layer/openlayers/vectorOpenlayers.js +118 -0
  69. package/src/vcs/vcm/layer/openlayers/vectorTileOpenlayers.js +177 -0
  70. package/src/vcs/vcm/layer/openlayers/wmsOpenlayers.js +55 -0
  71. package/src/vcs/vcm/layer/openlayers/wmtsOpenlayers.js +141 -0
  72. package/src/vcs/vcm/layer/pointCloud.js +162 -0
  73. package/src/vcs/vcm/layer/rasterLayer.js +294 -0
  74. package/src/vcs/vcm/layer/singleImage.js +119 -0
  75. package/src/vcs/vcm/layer/terrain.js +122 -0
  76. package/src/vcs/vcm/layer/terrainHelpers.js +123 -0
  77. package/src/vcs/vcm/layer/tileLoadedHelper.js +72 -0
  78. package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +104 -0
  79. package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +67 -0
  80. package/src/vcs/vcm/layer/tileProvider/tileProvider.js +584 -0
  81. package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +28 -0
  82. package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +106 -0
  83. package/src/vcs/vcm/layer/tms.js +121 -0
  84. package/src/vcs/vcm/layer/vector.js +632 -0
  85. package/src/vcs/vcm/layer/vectorHelpers.js +206 -0
  86. package/src/vcs/vcm/layer/vectorProperties.js +1391 -0
  87. package/src/vcs/vcm/layer/vectorSymbols.js +40 -0
  88. package/src/vcs/vcm/layer/vectorTile.js +480 -0
  89. package/src/vcs/vcm/layer/wfs.js +165 -0
  90. package/src/vcs/vcm/layer/wms.js +270 -0
  91. package/src/vcs/vcm/layer/wmsHelpers.js +65 -0
  92. package/src/vcs/vcm/layer/wmts.js +235 -0
  93. package/src/vcs/vcm/maps/baseOLMap.js +257 -0
  94. package/src/vcs/vcm/maps/cameraLimiter.js +219 -0
  95. package/src/vcs/vcm/maps/cesium.js +1192 -0
  96. package/src/vcs/vcm/maps/map.js +511 -0
  97. package/src/vcs/vcm/maps/mapState.js +17 -0
  98. package/src/vcs/vcm/maps/oblique.js +536 -0
  99. package/src/vcs/vcm/maps/openlayers.js +205 -0
  100. package/src/vcs/vcm/object.js +92 -0
  101. package/src/vcs/vcm/oblique/ObliqueCollection.js +572 -0
  102. package/src/vcs/vcm/oblique/ObliqueDataSet.js +357 -0
  103. package/src/vcs/vcm/oblique/ObliqueImage.js +247 -0
  104. package/src/vcs/vcm/oblique/ObliqueImageMeta.js +126 -0
  105. package/src/vcs/vcm/oblique/ObliqueProvider.js +433 -0
  106. package/src/vcs/vcm/oblique/ObliqueView.js +130 -0
  107. package/src/vcs/vcm/oblique/ObliqueViewDirection.js +40 -0
  108. package/src/vcs/vcm/oblique/helpers.js +483 -0
  109. package/src/vcs/vcm/oblique/parseImageJson.js +248 -0
  110. package/src/vcs/vcm/util/clipping/clippingObject.js +386 -0
  111. package/src/vcs/vcm/util/clipping/clippingObjectManager.js +312 -0
  112. package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +413 -0
  113. package/src/vcs/vcm/util/collection.js +193 -0
  114. package/src/vcs/vcm/util/dateTime.js +60 -0
  115. package/src/vcs/vcm/util/exclusiveManager.js +135 -0
  116. package/src/vcs/vcm/util/extent.js +124 -0
  117. package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +196 -0
  118. package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +51 -0
  119. package/src/vcs/vcm/util/featureProvider/featureProviderSymbols.js +11 -0
  120. package/src/vcs/vcm/util/featureProvider/tileProviderFeatureProvider.js +62 -0
  121. package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +280 -0
  122. package/src/vcs/vcm/util/featureconverter/circleToCesium.js +215 -0
  123. package/src/vcs/vcm/util/featureconverter/convert.js +83 -0
  124. package/src/vcs/vcm/util/featureconverter/extent3d.js +154 -0
  125. package/src/vcs/vcm/util/featureconverter/featureconverterHelper.js +591 -0
  126. package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +171 -0
  127. package/src/vcs/vcm/util/featureconverter/pointToCesium.js +359 -0
  128. package/src/vcs/vcm/util/featureconverter/polygonToCesium.js +229 -0
  129. package/src/vcs/vcm/util/geometryHelpers.js +172 -0
  130. package/src/vcs/vcm/util/indexedCollection.js +158 -0
  131. package/src/vcs/vcm/util/isMobile.js +12 -0
  132. package/src/vcs/vcm/util/layerCollection.js +216 -0
  133. package/src/vcs/vcm/util/locale.js +53 -0
  134. package/src/vcs/vcm/util/mapCollection.js +363 -0
  135. package/src/vcs/vcm/util/math.js +71 -0
  136. package/src/vcs/vcm/util/projection.js +348 -0
  137. package/src/vcs/vcm/util/splitScreen.js +233 -0
  138. package/src/vcs/vcm/util/style/declarativeStyleItem.js +631 -0
  139. package/src/vcs/vcm/util/style/shapesCategory.js +67 -0
  140. package/src/vcs/vcm/util/style/styleFactory.js +48 -0
  141. package/src/vcs/vcm/util/style/styleHelpers.js +555 -0
  142. package/src/vcs/vcm/util/style/styleItem.js +226 -0
  143. package/src/vcs/vcm/util/style/vectorStyleItem.js +927 -0
  144. package/src/vcs/vcm/util/style/writeStyle.js +48 -0
  145. package/src/vcs/vcm/util/urlHelpers.js +16 -0
  146. package/src/vcs/vcm/util/viewpoint.js +333 -0
@@ -0,0 +1,511 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import { check, checkMaybe } from '@vcsuite/check';
3
+ import VcsObject from '../object.js';
4
+ import LayerCollection from '../util/layerCollection.js';
5
+ import MapState from './mapState.js';
6
+ import { vcsLayerName } from '../layer/layerSymbols.js';
7
+ import VcsEvent from '../event/vcsEvent.js';
8
+ import { VcsClassRegistry } from '../classRegistry.js';
9
+
10
+ /**
11
+ * @namespace maps
12
+ * @api stable
13
+ */
14
+
15
+ /**
16
+ * @typedef {VcsObjectOptions} VcsMapOptions
17
+ * @property {string|undefined} fallbackMap - the name of the fallback map to use, e.g. in case there is no oblique image at the activation viewpoint
18
+ * @property {import("@vcmap/core").LayerCollection|undefined} layerCollection - layerCollection to use, if not provided an empty Collection will be created.
19
+ * @property {string|HTMLElement|undefined} target - the HTMLElement to render the map into
20
+ * @api
21
+ */
22
+
23
+ /**
24
+ * @typedef {Object} ClickPosition
25
+ * @property {number} latitude
26
+ * @property {number} longitude
27
+ * @property {number|undefined} height
28
+ * @property {number|undefined} groundLevel
29
+ * @property {ObliqueClickParameters|undefined} obliqueParameters
30
+ * @property {boolean|undefined} exactPosition
31
+ * @api stable
32
+ */
33
+
34
+ /**
35
+ * @type {Object}
36
+ */
37
+ const specificLayerImpl = {};
38
+
39
+ /**
40
+ * Map Base Class, each different map is derived from this abstract base class.
41
+ * @abstract
42
+ * @class
43
+ * @extends {VcsObject}
44
+ * @api stable
45
+ */
46
+ class VcsMap extends VcsObject {
47
+ static get className() { return 'vcs.vcm.maps.VcsMap'; }
48
+
49
+ static get specificLayerImpl() { return specificLayerImpl; }
50
+
51
+ /**
52
+ * @returns {VcsMapOptions}
53
+ */
54
+ static getDefaultOptions() {
55
+ return {
56
+ fallbackMap: undefined,
57
+ };
58
+ }
59
+
60
+ /**
61
+ * @param {VcsMapOptions} options
62
+ */
63
+ constructor(options) {
64
+ super(options);
65
+
66
+ /**
67
+ * @type {HTMLElement}
68
+ * @api
69
+ */
70
+ this.mapElement = document.createElement('div');
71
+ this.mapElement.setAttribute('id', uuidv4());
72
+ this.mapElement.classList.add('mapElement');
73
+ this.mapElement.style.display = 'none';
74
+
75
+ /**
76
+ * @type {HTMLElement}
77
+ * @private
78
+ */
79
+ this._target = null;
80
+ if (options.target) {
81
+ this.setTarget(options.target);
82
+ }
83
+
84
+ /**
85
+ * The layer collection of this map. LayerCollections can be shared among maps.
86
+ * When adding the map to a {@link MapCollection}, the layer collection of the {@link MapCollection} will be set.
87
+ * @type {LayerCollection}
88
+ * @private
89
+ */
90
+ this._layerCollection = options.layerCollection || new LayerCollection();
91
+
92
+ /**
93
+ * Whether to destroy the layerCollection when destroying the map. Defaults to
94
+ * false if passing in a LayerCollection and true if a LayerCollection is created.
95
+ * Is set to false, when setting a different LayerCollection.
96
+ * @type {boolean}
97
+ */
98
+ this.destroyLayerCollection = !options.layerCollection;
99
+
100
+ /**
101
+ * @type {Array<Function>}
102
+ * @private
103
+ */
104
+ this._collectionListeners = [
105
+ this.layerCollection.moved.addEventListener((layer) => {
106
+ this.indexChanged(layer);
107
+ }),
108
+ this.layerCollection.added.addEventListener((layer) => {
109
+ this._layerAdded(layer);
110
+ }),
111
+ this.layerCollection.removed.addEventListener((layer) => {
112
+ this._layerRemoved(layer);
113
+ }),
114
+ ];
115
+
116
+ /** @type {boolean} */
117
+ this.initialized = false;
118
+
119
+ /**
120
+ * if true, no movements should occur
121
+ * @type {boolean}
122
+ * @api
123
+ */
124
+ this.movementDisabled = false;
125
+
126
+ /**
127
+ * The name of a map to fall back on, if this map cant show a viewpoint
128
+ * @type {string|null}
129
+ * @api
130
+ */
131
+ this.fallbackMap = options.fallbackMap || null;
132
+
133
+ /**
134
+ * @type {Map<string, Set<import("@vcmap/cesium").CustomDataSource|import("@vcmap/cesium").CzmlDataSource|import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").Cesium3DTileset|import("@vcmap/cesium").ImageryLayer|import("ol/layer/Layer").default<import("ol/source").Source>>>}
135
+ * @private
136
+ */
137
+ this._visualizations = new Map();
138
+
139
+ /**
140
+ * @type {MapState}
141
+ * @private
142
+ */
143
+ this._state = MapState.INACTIVE;
144
+
145
+ /**
146
+ * Event raised when the maps state changes. Is passed the {@link MapState} as its only argument.
147
+ * @type {VcsEvent<MapState>}
148
+ * @api
149
+ */
150
+ this.stateChanged = new VcsEvent();
151
+ /**
152
+ * Event raised then the map has a pointer interaction. Raises {@link MapEvent}.
153
+ * @type {VcsEvent<MapEvent>}
154
+ * @api
155
+ */
156
+ this.pointerInteractionEvent = new VcsEvent();
157
+ /**
158
+ * If present, the split screen to use on this map. Is set by the mapCollection
159
+ * @type {import("@vcmap/core").SplitScreen|null}
160
+ * @api
161
+ */
162
+ this.splitScreen = null;
163
+ }
164
+
165
+ /**
166
+ * Whether the map is active or not
167
+ * @type {boolean}
168
+ * @api
169
+ * @readonly
170
+ */
171
+ get active() {
172
+ return this._state === MapState.ACTIVE;
173
+ }
174
+
175
+ /**
176
+ * Whether the map is loading or not
177
+ * @type {boolean}
178
+ * @api
179
+ * @readonly
180
+ */
181
+ get loading() {
182
+ return this._state === MapState.LOADING;
183
+ }
184
+
185
+ /**
186
+ * The currently set HTML element in which to render the map
187
+ * @type {HTMLElement|null}
188
+ * @api
189
+ * @readonly
190
+ */
191
+ get target() {
192
+ return this._target;
193
+ }
194
+
195
+ /**
196
+ * The layer collection of this map. LayerCollections can be shared among maps.
197
+ * When adding the map to a {@link MapCollection}, the layer collection of the {@link MapCollection} will be set.
198
+ * When setting the layer colleciton, the destroyLayerCollection flag is automatically set to false.
199
+ * @type {LayerCollection}
200
+ * @api
201
+ */
202
+ get layerCollection() {
203
+ return this._layerCollection;
204
+ }
205
+
206
+ /**
207
+ * @param {LayerCollection} layerCollection
208
+ */
209
+ set layerCollection(layerCollection) {
210
+ check(layerCollection, LayerCollection);
211
+
212
+ this.destroyLayerCollection = false;
213
+
214
+ [...this._layerCollection].forEach((l) => {
215
+ l.removedFromMap(this);
216
+ });
217
+ this._layerCollection = layerCollection;
218
+
219
+ if (this.active) {
220
+ [...this._layerCollection].forEach((l) => {
221
+ l.mapActivated(this);
222
+ });
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Determines whether this map can show this viewpoint. Returns true in any other map then {@link Oblique}
228
+ * @param {import("@vcmap/core").ViewPoint} viewpoint
229
+ * @returns {Promise<boolean>}
230
+ * @api
231
+ */
232
+ // eslint-disable-next-line no-unused-vars,class-methods-use-this
233
+ canShowViewpoint(viewpoint) {
234
+ return Promise.resolve(true);
235
+ }
236
+
237
+ /**
238
+ * Sets the map target.
239
+ * @param {string|HTMLElement|null} target
240
+ * @api
241
+ */
242
+ setTarget(target) {
243
+ checkMaybe(target, [String, HTMLElement]);
244
+
245
+ if (this._target) {
246
+ this._target.removeChild(this.mapElement);
247
+ }
248
+
249
+ this._target = typeof target === 'string' ? document.getElementById(target) : target;
250
+ if (this._target) {
251
+ this._target.appendChild(this.mapElement);
252
+ }
253
+ }
254
+
255
+ /**
256
+ * @returns {Promise<void>}
257
+ */
258
+ // eslint-disable-next-line class-methods-use-this,no-empty-function
259
+ async initialize() {}
260
+
261
+ /**
262
+ * is called if a layer changes its position in the layerCollection.
263
+ * @param {import("@vcmap/core").Layer} layer
264
+ */
265
+ // eslint-disable-next-line no-unused-vars,class-methods-use-this
266
+ indexChanged(layer) {}
267
+
268
+ /**
269
+ * is called if a layer is added to the layerCollection.
270
+ * @param {import("@vcmap/core").Layer} layer
271
+ * @private
272
+ */
273
+ _layerAdded(layer) {
274
+ if (this.active) {
275
+ layer.mapActivated(this);
276
+ }
277
+ }
278
+
279
+ /**
280
+ * is called if a layer is added to the layerCollection.
281
+ * @param {import("@vcmap/core").Layer} layer
282
+ * @private
283
+ */
284
+ _layerRemoved(layer) {
285
+ layer.removedFromMap(this);
286
+ }
287
+
288
+ /**
289
+ * Validates a visualization. A visualization must have the vcsLayeName symbol set and a layer with said name must be
290
+ * part of the maps layerCollection.
291
+ * @param {import("@vcmap/cesium").CustomDataSource|import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").Cesium3DTileset|import("@vcmap/cesium").ImageryLayer|import("ol/layer/Layer").default<import("ol/source").Source>} item
292
+ * @returns {boolean}
293
+ */
294
+ validateVisualization(item) {
295
+ const layerName = item[vcsLayerName];
296
+ if (layerName == null) {
297
+ this.getLogger().warning('item is missing vcsLayerName symbol');
298
+ return false;
299
+ }
300
+
301
+ return this.layerCollection.hasKey(layerName);
302
+ }
303
+
304
+ /**
305
+ * Adds a visualization to the visualizations map for its layer. The visualization must be valid, use validateVisualization first
306
+ * @param {import("@vcmap/cesium").CustomDataSource|import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").Cesium3DTileset|import("@vcmap/cesium").ImageryLayer|import("ol/layer/Layer").default<import("ol/source").Source>} item
307
+ */
308
+ addVisualization(item) {
309
+ if (!this.validateVisualization(item)) {
310
+ throw new Error('Visualization item is not valid, validate before adding');
311
+ }
312
+ const layerName = item[vcsLayerName];
313
+ if (!this._visualizations.has(layerName)) {
314
+ this._visualizations.set(layerName, new Set());
315
+ }
316
+ this._visualizations.get(layerName).add(item);
317
+ }
318
+
319
+ /**
320
+ * Removes a visualization
321
+ * @param {import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").Cesium3DTileset|import("@vcmap/cesium").ImageryLayer|import("ol/layer/Layer").default<import("ol/source").Source>|import("@vcmap/cesium").CustomDataSource} item
322
+ */
323
+ removeVisualization(item) {
324
+ const layerName = item[vcsLayerName];
325
+ const viz = this._visualizations.get(layerName);
326
+ if (viz) {
327
+ viz.delete(item);
328
+ if (viz.size === 0) {
329
+ this._visualizations.delete(layerName);
330
+ }
331
+ }
332
+ }
333
+
334
+ /**
335
+ * Gets the visualizations for a specific layer.
336
+ * @param {import("@vcmap/core").Layer} layer
337
+ * @returns {Set<import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").Cesium3DTileset|import("@vcmap/cesium").ImageryLayer|import("ol/layer/Layer").default<import("ol/source").Source>|import("@vcmap/cesium").CustomDataSource>}
338
+ * @api
339
+ */
340
+ getVisualizationsForLayer(layer) {
341
+ return this._visualizations.get(layer.name);
342
+ }
343
+
344
+ /**
345
+ * Get all visualizations added to this map.
346
+ * @returns {Array<import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").Cesium3DTileset|import("@vcmap/cesium").ImageryLayer|import("ol/layer/Layer").default<import("ol/source").Source>|import("@vcmap/cesium").CustomDataSource>}
347
+ * @api
348
+ */
349
+ getVisualizations() {
350
+ return [...this._visualizations.values()]
351
+ .map(layerVisualizations => [...layerVisualizations])
352
+ .flat();
353
+ }
354
+
355
+ /**
356
+ * activates the map, if necessary initializes the map.
357
+ * Once the promise resolves, the map can still be inactive, if deactivate was called while the map was activating.
358
+ * @returns {Promise<void>}
359
+ * @api stable
360
+ */
361
+ async activate() {
362
+ if (this._state === MapState.INACTIVE) {
363
+ this._state = MapState.LOADING;
364
+ this.stateChanged.raiseEvent(MapState.LOADING);
365
+ this.mapElement.style.display = '';
366
+ await this.initialize();
367
+ if (this._state !== MapState.LOADING) {
368
+ return;
369
+ }
370
+ this._state = MapState.ACTIVE;
371
+ await Promise.all([...this.layerCollection].map(layer => layer.mapActivated(this)));
372
+ if (this._state !== MapState.ACTIVE) {
373
+ return;
374
+ }
375
+ this.stateChanged.raiseEvent(this._state);
376
+ }
377
+ }
378
+
379
+ /**
380
+ * deactivates the map
381
+ * @api stable
382
+ */
383
+ deactivate() {
384
+ if (this._state !== MapState.INACTIVE) {
385
+ this.mapElement.style.display = 'none';
386
+ this._state = MapState.INACTIVE;
387
+ [...this.layerCollection].forEach((layer) => {
388
+ layer.mapDeactivated(this);
389
+ });
390
+ this.stateChanged.raiseEvent(this._state);
391
+ }
392
+ }
393
+
394
+ /**
395
+ * prevent all movement, including navigation controls, gotoViewPoint & setting of oblique images
396
+ * @param {boolean} prevent
397
+ * @api
398
+ */
399
+ disableMovement(prevent) {
400
+ this.movementDisabled = prevent;
401
+ }
402
+
403
+ /**
404
+ * sets the view to the given viewpoint
405
+ * @param {import("@vcmap/core").ViewPoint} viewpoint
406
+ * @param {number=} optMaximumHeight during animation (can be used to get rid of the bunny hop)
407
+ * gotoViewPoint
408
+ * @returns {Promise<void>}
409
+ * @api stable
410
+ */
411
+ // eslint-disable-next-line no-unused-vars,class-methods-use-this
412
+ gotoViewPoint(viewpoint, optMaximumHeight) {
413
+ return Promise.resolve();
414
+ }
415
+
416
+ // eslint-disable-next-line jsdoc/require-returns-check
417
+ /**
418
+ * Returns the most precise viewpoint possible in Oblique.
419
+ * @api
420
+ * @returns {Promise<import("@vcmap/core").ViewPoint|null>}
421
+ */
422
+ // eslint-disable-next-line class-methods-use-this
423
+ async getViewPoint() {
424
+ return null;
425
+ }
426
+
427
+ /**
428
+ * Returns an approximate viewpoint in Oblique, not requesting terrain.
429
+ * @api
430
+ * @returns {import("@vcmap/core").ViewPoint|null}
431
+ */
432
+ // eslint-disable-next-line class-methods-use-this
433
+ getViewPointSync() {
434
+ return null;
435
+ }
436
+
437
+ /**
438
+ * Resolution in meters per pixe
439
+ * @param {import("ol/coordinate").Coordinate} coordinate - coordinate in mercator for which to determine resolution. only required in 3D
440
+ * @returns {number}
441
+ * @api
442
+ */
443
+ // eslint-disable-next-line class-methods-use-this,no-unused-vars
444
+ getCurrentResolution(coordinate) {
445
+ return 1;
446
+ }
447
+
448
+ /**
449
+ * @param {import("ol/coordinate").Coordinate} coords in WGS84 degrees
450
+ * @returns {boolean}
451
+ * @api
452
+ */
453
+ // eslint-disable-next-line no-unused-vars,class-methods-use-this
454
+ pointIsVisible(coords) { return false; }
455
+
456
+ /**
457
+ * Requests this map to render when possible
458
+ * @api
459
+ */
460
+ // eslint-disable-next-line class-methods-use-this
461
+ requestRender() {}
462
+
463
+ /**
464
+ * @returns {VcsMapOptions}
465
+ * @api
466
+ */
467
+ getConfigObject() {
468
+ const config = /** @type {VcsMapOptions} */ (super.getConfigObject());
469
+ if (this.fallbackMap) {
470
+ config.fallbackMap = this.fallbackMap;
471
+ }
472
+ return config;
473
+ }
474
+
475
+ /**
476
+ * disposes the map
477
+ * @api stable
478
+ */
479
+ destroy() {
480
+ super.destroy();
481
+ if (this.mapElement) {
482
+ if (this.mapElement.parentElement) {
483
+ this.mapElement.parentElement.removeChild(this.mapElement);
484
+ }
485
+ this.mapElement = null;
486
+ }
487
+ this._target = null;
488
+
489
+ this._collectionListeners.forEach((cb) => { cb(); });
490
+ this._collectionListeners = [];
491
+
492
+ [...this.layerCollection].forEach((l) => { l.removedFromMap(this); });
493
+ if (this.stateChanged) {
494
+ this.stateChanged.destroy();
495
+ this.stateChanged = null;
496
+ }
497
+
498
+ if (this.destroyLayerCollection) {
499
+ this.layerCollection.destroy();
500
+ }
501
+
502
+ if (this.pointerInteractionEvent) {
503
+ this.pointerInteractionEvent.destroy();
504
+ this.pointerInteractionEvent = null;
505
+ }
506
+ this._layerCollection = null;
507
+ }
508
+ }
509
+
510
+ VcsClassRegistry.registerClass(VcsMap.className, VcsMap);
511
+ export default VcsMap;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The state of a map.
3
+ * State machine: inactive <-> loading -> active -> inactive
4
+ * @enum {number}
5
+ * @export
6
+ * @api
7
+ * @property {number} INACTIVE
8
+ * @property {number} ACTIVE
9
+ * @property {number} LOADING
10
+ */
11
+ const MapState = {
12
+ INACTIVE: 1,
13
+ ACTIVE: 2,
14
+ LOADING: 4,
15
+ };
16
+
17
+ export default MapState;