@vcmap/core 5.0.0-rc.10 → 5.0.0-rc.13

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 (129) hide show
  1. package/index.d.ts +201 -125
  2. package/index.js +2 -3
  3. package/package.json +6 -2
  4. package/src/category/category.js +21 -5
  5. package/src/classRegistry.js +0 -6
  6. package/src/context.js +0 -1
  7. package/src/featureProvider/abstractFeatureProvider.js +0 -1
  8. package/src/featureProvider/wmsFeatureProvider.js +0 -1
  9. package/src/interaction/abstractInteraction.js +0 -1
  10. package/src/interaction/interactionChain.js +0 -1
  11. package/src/interaction/interactionType.js +1 -5
  12. package/src/layer/cesium/cesiumTilesetCesiumImpl.js +2 -3
  13. package/src/layer/cesium/dataSourceCesiumImpl.js +0 -1
  14. package/src/layer/cesium/openStreetMapCesiumImpl.js +0 -1
  15. package/src/layer/cesium/rasterLayerCesiumImpl.js +0 -1
  16. package/src/layer/cesium/singleImageCesiumImpl.js +0 -1
  17. package/src/layer/cesium/terrainCesiumImpl.js +0 -1
  18. package/src/layer/cesium/tmsCesiumImpl.js +0 -1
  19. package/src/layer/cesium/vectorCesiumImpl.js +3 -4
  20. package/src/layer/cesium/vectorRasterTileCesiumImpl.js +0 -1
  21. package/src/layer/cesium/vectorTileImageryProvider.js +0 -1
  22. package/src/layer/cesium/wmsCesiumImpl.js +0 -1
  23. package/src/layer/cesium/wmtsCesiumImpl.js +0 -1
  24. package/src/layer/cesiumTilesetLayer.js +0 -1
  25. package/src/layer/czmlLayer.js +0 -1
  26. package/src/layer/dataSourceLayer.js +25 -16
  27. package/src/layer/featureLayer.js +10 -1
  28. package/src/layer/featureStoreLayer.js +1 -1
  29. package/src/layer/featureStoreLayerState.js +0 -1
  30. package/src/layer/featureVisibility.js +3 -1
  31. package/src/layer/geojsonHelpers.js +0 -4
  32. package/src/layer/geojsonLayer.js +0 -1
  33. package/src/layer/globalHider.js +7 -21
  34. package/src/layer/layer.js +84 -38
  35. package/src/layer/layerImplementation.js +0 -1
  36. package/src/layer/layerState.js +0 -1
  37. package/src/layer/oblique/vectorObliqueImpl.js +1 -3
  38. package/src/layer/openStreetMapLayer.js +0 -1
  39. package/src/layer/openlayers/layerOpenlayersImpl.js +0 -1
  40. package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +0 -1
  41. package/src/layer/openlayers/singleImageOpenlayersImpl.js +0 -1
  42. package/src/layer/openlayers/tileDebugOpenlayersImpl.js +0 -1
  43. package/src/layer/openlayers/tmsOpenlayersImpl.js +0 -1
  44. package/src/layer/openlayers/vectorOpenlayersImpl.js +2 -3
  45. package/src/layer/openlayers/vectorTileOpenlayersImpl.js +0 -1
  46. package/src/layer/openlayers/wmsOpenlayersImpl.js +0 -1
  47. package/src/layer/openlayers/wmtsOpenlayersImpl.js +0 -1
  48. package/src/layer/pointCloudLayer.js +0 -1
  49. package/src/layer/rasterLayer.js +0 -2
  50. package/src/layer/singleImageLayer.js +0 -1
  51. package/src/layer/terrainLayer.js +0 -1
  52. package/src/layer/tileProvider/mvtTileProvider.js +21 -2
  53. package/src/layer/tileProvider/staticGeojsonTileProvider.js +0 -1
  54. package/src/layer/tileProvider/tileProvider.js +27 -1
  55. package/src/layer/tileProvider/urlTemplateTileProvider.js +26 -6
  56. package/src/layer/tmsLayer.js +0 -1
  57. package/src/layer/vectorLayer.js +0 -1
  58. package/src/layer/vectorProperties.js +0 -1
  59. package/src/layer/vectorTileLayer.js +45 -13
  60. package/src/layer/wfsLayer.js +0 -1
  61. package/src/layer/wmsLayer.js +0 -1
  62. package/src/layer/wmtsLayer.js +0 -1
  63. package/src/map/baseOLMap.js +0 -1
  64. package/src/map/cameraLimiter.js +0 -1
  65. package/src/map/cesiumMap.js +0 -1
  66. package/src/map/mapState.js +0 -1
  67. package/src/map/obliqueMap.js +0 -1
  68. package/src/map/openlayersMap.js +0 -1
  69. package/src/map/vcsMap.js +6 -2
  70. package/src/oblique/helpers.js +0 -3
  71. package/src/oblique/obliqueCollection.js +0 -1
  72. package/src/oblique/obliqueDataSet.js +0 -2
  73. package/src/oblique/obliqueImage.js +0 -1
  74. package/src/oblique/obliqueImageMeta.js +0 -1
  75. package/src/oblique/obliqueProvider.js +0 -1
  76. package/src/oblique/obliqueView.js +0 -1
  77. package/src/oblique/obliqueViewDirection.js +0 -3
  78. package/src/ol/render/canvas/canvasTileRenderer.js +0 -1
  79. package/src/style/declarativeStyleItem.js +0 -1
  80. package/src/style/shapesCategory.js +0 -2
  81. package/src/style/styleHelpers.js +0 -11
  82. package/src/style/styleItem.js +0 -1
  83. package/src/style/vectorStyleItem.js +0 -4
  84. package/src/util/clipping/clippingObject.js +0 -2
  85. package/src/util/clipping/clippingObjectManager.js +0 -1
  86. package/src/util/clipping/clippingPlaneHelper.js +0 -4
  87. package/src/util/collection.js +15 -3
  88. package/src/util/extent.js +0 -1
  89. package/src/util/indexedCollection.js +0 -1
  90. package/src/util/layerCollection.js +71 -6
  91. package/src/util/locale.js +1 -42
  92. package/src/util/mapCollection.js +29 -14
  93. package/src/util/overrideCollection.js +8 -9
  94. package/src/util/projection.js +0 -5
  95. package/src/util/viewpoint.js +0 -4
  96. package/src/vcsApp.js +53 -0
  97. package/src/vcsEvent.js +0 -1
  98. package/tests/data/buildings/tileset.json +428 -0
  99. package/tests/data/dynamicPointCzml.json +64 -0
  100. package/tests/data/oblique/imageData/imagev34.json +352 -0
  101. package/tests/data/oblique/imageData/imagev35.json +54 -0
  102. package/tests/data/oblique/imageData/imagev35PerImageSize.json +53 -0
  103. package/tests/data/oblique/tiledImageData/12/2199/1342.json +1 -0
  104. package/tests/data/oblique/tiledImageData/12/2199/1343.json +1 -0
  105. package/tests/data/oblique/tiledImageData/12/2199/1344.json +1 -0
  106. package/tests/data/oblique/tiledImageData/12/2200/1342.json +1 -0
  107. package/tests/data/oblique/tiledImageData/12/2200/1343.json +1 -0
  108. package/tests/data/oblique/tiledImageData/12/2200/1344.json +1 -0
  109. package/tests/data/oblique/tiledImageData/12/2201/1342.json +1 -0
  110. package/tests/data/oblique/tiledImageData/12/2201/1343.json +1 -0
  111. package/tests/data/oblique/tiledImageData/12/2201/1344.json +1 -0
  112. package/tests/data/oblique/tiledImageData/image.json +1 -0
  113. package/tests/data/terrain/13/8800/6485.terrain +0 -0
  114. package/tests/data/terrain/13/8800/6486.terrain +0 -0
  115. package/tests/data/terrain/13/8801/6485.terrain +0 -0
  116. package/tests/data/terrain/13/8801/6486.terrain +0 -0
  117. package/tests/data/terrain/layer.json +136 -0
  118. package/tests/data/testGeoJSON.json +161 -0
  119. package/tests/data/tile.pbf +0 -0
  120. package/tests/unit/helpers/cesiumHelpers.js +272 -0
  121. package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
  122. package/tests/unit/helpers/helpers.js +11 -0
  123. package/tests/unit/helpers/imageHelpers.js +20 -0
  124. package/tests/unit/helpers/importJSON.js +15 -0
  125. package/tests/unit/helpers/obliqueData.js +76 -0
  126. package/tests/unit/helpers/obliqueHelpers.js +112 -0
  127. package/tests/unit/helpers/openlayersHelpers.js +22 -0
  128. package/tests/unit/helpers/terrain/terrainData.js +46 -0
  129. package/src/util/dateTime.js +0 -60
@@ -1,13 +1,14 @@
1
+ import { check } from '@vcsuite/check';
1
2
  import IndexedCollection from './indexedCollection.js';
2
3
  import ExclusiveManager from './exclusiveManager.js';
3
4
  import LayerState from '../layer/layerState.js';
4
5
  import VcsEvent from '../vcsEvent.js';
6
+ import GlobalHider from '../layer/globalHider.js';
5
7
 
6
8
  /**
7
9
  * A collection of layers. Manages rendering order and layer exclusivity. Emits state changes for convenience. Passed to
8
10
  * {@link Map} for layers available to said map. Layers must have unique names.
9
11
  * @class
10
- * @export
11
12
  * @api
12
13
  * @extends {IndexedCollection<import("@vcmap/core").Layer>}}
13
14
  */
@@ -62,6 +63,22 @@ class LayerCollection extends IndexedCollection {
62
63
  * @api
63
64
  */
64
65
  this.exclusiveManager = new ExclusiveManager();
66
+
67
+ /**
68
+ * The global hider for this collection.
69
+ * @type {GlobalHider}
70
+ * @private
71
+ */
72
+ this._globalHider = new GlobalHider();
73
+
74
+ /**
75
+ * Locale for this layerCollection, will be synchronized by the vcsApp, if part of an vcsApp.
76
+ * This Locale will be set on all Member Layers. On setting the Locale this will trigger a reload of all locale
77
+ * aware layers.
78
+ * @type {string}
79
+ * @private
80
+ */
81
+ this._locale = 'en';
65
82
  }
66
83
 
67
84
  /**
@@ -73,6 +90,48 @@ class LayerCollection extends IndexedCollection {
73
90
  */
74
91
  get zIndexSymbol() { return this._zIndexSymbol; }
75
92
 
93
+ /**
94
+ * The current global hider
95
+ * @type {GlobalHider}
96
+ */
97
+ get globalHider() {
98
+ return this._globalHider;
99
+ }
100
+
101
+ /**
102
+ * Set global hider for these maps.
103
+ * @param {GlobalHider} globalHider
104
+ */
105
+ set globalHider(globalHider) {
106
+ check(globalHider, GlobalHider);
107
+
108
+ this._globalHider = globalHider;
109
+ this._array.forEach((layer) => {
110
+ layer.setGlobalHider(this._globalHider);
111
+ });
112
+ }
113
+
114
+ /**
115
+ * @type {string}
116
+ */
117
+ get locale() {
118
+ return this._locale;
119
+ }
120
+
121
+ /**
122
+ * @param {string} value
123
+ */
124
+ set locale(value) {
125
+ check(value, String);
126
+
127
+ if (this._locale !== value) {
128
+ this._locale = value;
129
+ [...this].forEach((layer) => {
130
+ layer.locale = this._locale;
131
+ });
132
+ }
133
+ }
134
+
76
135
  /**
77
136
  * @param {import("@vcmap/core").Layer} layer
78
137
  * @private
@@ -134,7 +193,7 @@ class LayerCollection extends IndexedCollection {
134
193
  }
135
194
 
136
195
  /**
137
- * Ensures the local z index is consisten with the neighbours of a given layer.
196
+ * Ensures the local z index is consistent with the neighbours of a given layer.
138
197
  * e.g. the layer on elower must have a lower or equal zIndex
139
198
  * and the one higher a higher or equal zIndex.
140
199
  * @param {import("@vcmap/core").Layer} layer
@@ -159,6 +218,8 @@ class LayerCollection extends IndexedCollection {
159
218
 
160
219
  /**
161
220
  * Adds a layer to the collection. Can optionally be passed an index at which to insert the layer.
221
+ * The layer locale will be set to the same locale of the layerCollection. This will trigger a forceRedraw
222
+ * of the layer if the layer locale is different and the layer is locale aware.
162
223
  * @param {import("@vcmap/core").Layer} layer
163
224
  * @param {number=} index
164
225
  * @returns {number|null} returns the layer index or null, if the layers name is not unique
@@ -172,6 +233,8 @@ class LayerCollection extends IndexedCollection {
172
233
  const insertedAt = super.add(layer, usedIndex);
173
234
  if (insertedAt != null) {
174
235
  layer[this._zIndexSymbol] = layer.zIndex;
236
+ layer.setGlobalHider(this._globalHider);
237
+ layer.locale = this.locale;
175
238
  this._ensureLocalZIndex(layer);
176
239
  this._listenToLayerEvents(layer);
177
240
  this.exclusiveManager.registerLayer(layer);
@@ -180,18 +243,19 @@ class LayerCollection extends IndexedCollection {
180
243
  }
181
244
 
182
245
  /**
183
- * Removes a layer from the collection.
184
246
  * @param {import("@vcmap/core").Layer} layer
185
- * @api
247
+ * @returns {number}
248
+ * @protected
186
249
  */
187
- remove(layer) {
250
+ _remove(layer) {
188
251
  if (this._layerEventListeners[layer.name]) {
189
252
  this._layerEventListeners[layer.name].forEach((cb) => { cb(); });
190
253
  delete this._layerEventListeners[layer.name];
191
254
  }
192
255
  delete layer[this._zIndexSymbol];
256
+ layer.setGlobalHider(null);
193
257
  this.exclusiveManager.unregisterLayer(layer);
194
- super.remove(layer);
258
+ return super._remove(layer);
195
259
  }
196
260
 
197
261
  clear() {
@@ -214,6 +278,7 @@ class LayerCollection extends IndexedCollection {
214
278
 
215
279
  this._layerEventListeners = {};
216
280
  this.exclusiveManager.destroy();
281
+ this._globalHider.destroy();
217
282
  super.destroy();
218
283
  }
219
284
  }
@@ -1,20 +1,4 @@
1
- import VcsEvent from '../vcsEvent.js';
2
-
3
- /**
4
- * @type {VcsEvent<string>}
5
- */
6
- let localeChangedEvent;
7
-
8
- /**
9
- * @returns {VcsEvent<string>}
10
- */
11
- export function getLocaleChangedEvent() {
12
- if (!localeChangedEvent) {
13
- localeChangedEvent = new VcsEvent();
14
- }
15
- return localeChangedEvent;
16
- }
17
-
1
+ /* eslint-disable import/prefer-default-export */
18
2
  /**
19
3
  * returns the default browserLocale, if not possible 'en'
20
4
  * @returns {string}
@@ -26,28 +10,3 @@ export function detectBrowserLocale() {
26
10
  }
27
11
  return 'en';
28
12
  }
29
-
30
- /**
31
- * @type {string}
32
- */
33
- let currentLocale;
34
-
35
- /**
36
- * @returns {string}
37
- */
38
- export function getCurrentLocale() {
39
- if (!currentLocale) {
40
- currentLocale = detectBrowserLocale();
41
- }
42
- return currentLocale;
43
- }
44
-
45
- /**
46
- * @param {string} value
47
- */
48
- export function setCurrentLocale(value) {
49
- if (typeof value === 'string') {
50
- currentLocale = value;
51
- getLocaleChangedEvent().raiseEvent(value);
52
- }
53
- }
@@ -42,7 +42,6 @@ async function setCesiumToOLViewpoint(cesiumMap, olMap) {
42
42
 
43
43
  /**
44
44
  * @class
45
- * @export
46
45
  * @extends {Collection<import("@vcmap/core").VcsMap>}}
47
46
  */
48
47
  // ignored do to static issues, see https://github.com/microsoft/TypeScript/issues/4628
@@ -83,6 +82,13 @@ class MapCollection extends Collection {
83
82
  */
84
83
  this._target = null;
85
84
 
85
+ /**
86
+ * if the active map is removed the last viewpoint is cached for the next mapActivation.
87
+ * @type {import("@vcmap/core").ViewPoint}
88
+ * @private
89
+ */
90
+ this._cachedViewpoint = null;
91
+
86
92
  /**
87
93
  * The map pointer event handler. The EventHandler is shared amongst all maps within the collection.
88
94
  * @type {EventHandler}
@@ -219,20 +225,25 @@ class MapCollection extends Collection {
219
225
  }
220
226
 
221
227
  /**
222
- * Removes the map from the collection. Will also set _splitScreen & target to null and an empty _layerCollection on the map,
223
- * if the map is currently part of the collection.
224
228
  * @param {import("@vcmap/core").VcsMap} map
229
+ * @returns {number}
230
+ * @protected
225
231
  */
226
- remove(map) {
232
+ _remove(map) {
233
+ if (this._activeMap === map) {
234
+ this._cachedViewpoint = map.getViewPointSync();
235
+ if (this._target) {
236
+ const mapClassName = this._activeMap.className.split('.').pop();
237
+ this._target.classList.remove(mapClassName);
238
+ }
239
+ this._activeMap = null;
240
+ }
227
241
  if (this.has(map)) {
228
242
  map.setTarget(null);
229
243
  map.splitScreen = null;
230
244
  map.layerCollection = new LayerCollection();
231
245
  }
232
- super.remove(map);
233
- if (this._activeMap === map) {
234
- this._activeMap = null;
235
- }
246
+ return super._remove(map);
236
247
  }
237
248
 
238
249
  /**
@@ -334,12 +345,13 @@ class MapCollection extends Collection {
334
345
  }
335
346
 
336
347
  let viewpoint;
337
- if (this._activeMap) {
348
+ if (this._activeMap || this._cachedViewpoint) {
338
349
  if (this._activeMap === map) {
339
350
  return map.activate();
340
351
  }
341
352
 
342
- viewpoint = await this._activeMap.getViewPoint();
353
+ viewpoint = this._activeMap ? await this._activeMap.getViewPoint() : this._cachedViewpoint;
354
+
343
355
  const canShow = await map.canShowViewpoint(viewpoint);
344
356
  if (!canShow) {
345
357
  const fallbackMap = this._getFallbackMap(map);
@@ -348,10 +360,13 @@ class MapCollection extends Collection {
348
360
  return this.setActiveMap(fallbackMap.name);
349
361
  }
350
362
  }
351
- this._activeMap.deactivate();
352
- if (this._target) {
353
- const mapClassName = this._activeMap.className.split('.').pop();
354
- this._target.classList.remove(mapClassName);
363
+ this._cachedViewpoint = null;
364
+ if (this._activeMap) {
365
+ this._activeMap.deactivate();
366
+ if (this._target) {
367
+ const mapClassName = this._activeMap.className.split('.').pop();
368
+ this._target.classList.remove(mapClassName);
369
+ }
355
370
  }
356
371
  }
357
372
 
@@ -38,7 +38,7 @@ export const isOverrideCollection = Symbol('OverrideCollection');
38
38
  * @param {Collection<T>} collection
39
39
  * @param {function():string} getDynamicContextId - function to get the current dynamic context id
40
40
  * @param {(function(T):Object)=} serializeItem - optional function to serialize an item, defaults to returning item.toJSON or item: i => (i.toJSON || i)
41
- * @param {(function(Object):(T|Promise<T>))=} deserializeItem - optional desirialization function. defaults to returning the passed object: i => i
41
+ * @param {(function(Object):(T|Promise<T>))=} deserializeItem - optional deserialization function. defaults to returning the passed object: i => i
42
42
  * @param {*=} ctor - optional constructor to validate deserialized items against. if passed, deserializeItem must be an instance of ctor.
43
43
  * @param {(function(T, (T|null|undefined), (number|undefined)):number|null)=} determineShadowIndex - return the index where a shadow should be inserted. only has relevance, if the collection is indexed. previous and current index may be null.
44
44
  * @template {*} T
@@ -81,12 +81,11 @@ function makeOverrideCollection(
81
81
 
82
82
  if (overrideCollection.hasKey(itemId)) {
83
83
  shadow = overrideCollection.getByKey(itemId);
84
+
84
85
  // @ts-ignore
85
- index = overrideCollection._array.indexOf(shadow); // faking remove to not call removed
86
- if (index > -1) {
87
- // @ts-ignore
88
- overrideCollection._array.splice(index, 1);
89
- }
86
+ // eslint-disable-next-line no-underscore-dangle
87
+ index = overrideCollection._remove(shadow);
88
+
90
89
  if (!overrideCollection.shadowMap.has(itemId)) {
91
90
  overrideCollection.shadowMap.set(itemId, []);
92
91
  }
@@ -102,11 +101,11 @@ function makeOverrideCollection(
102
101
  }
103
102
 
104
103
  const usedIndex = shadow ? getShadowIndex(shadow, item, index) : null;
104
+ if (shadow) {
105
+ overrideCollection.replaced.raiseEvent(item);
106
+ }
105
107
  // @ts-ignore
106
108
  if (overrideCollection.add(item, usedIndex) >= 0) {
107
- if (shadow) {
108
- overrideCollection.replaced.raiseEvent(item);
109
- }
110
109
  return item;
111
110
  }
112
111
  return null;
@@ -98,7 +98,6 @@ function registerProjection(options) {
98
98
  * projection created prior to this functions call.
99
99
  * @param {ProjectionOptions} options
100
100
  * @api
101
- * @export
102
101
  */
103
102
  export function setDefaultProjectionOptions(options) {
104
103
  check(options, { epsg: [String, Number], proj4: [String, undefined, null] });
@@ -111,7 +110,6 @@ export function setDefaultProjectionOptions(options) {
111
110
  /**
112
111
  * Projection Class, if no valid options are given, the Projection will initialize with the Framework default Projection
113
112
  * @class
114
- * @export
115
113
  * For example:
116
114
  * <pre><code>
117
115
  * {
@@ -341,7 +339,6 @@ export default Projection;
341
339
  * Returns the default Projection.
342
340
  * @api stable
343
341
  * @returns {Projection}
344
- * @export
345
342
  */
346
343
  export function getDefaultProjection() {
347
344
  return new Projection(defaultProjectionOption);
@@ -351,13 +348,11 @@ export function getDefaultProjection() {
351
348
  * wgs84 Projection EPSG Code: 4326
352
349
  * @api stable
353
350
  * @type {Projection}
354
- * @export
355
351
  */
356
352
  export const wgs84Projection = new Projection({ epsg: 4326 });
357
353
  /**
358
354
  * mercator Projection EPSG Code: 3857
359
355
  * @api stable
360
356
  * @type {Projection}
361
- * @export
362
357
  */
363
358
  export const mercatorProjection = new Projection({ epsg: 3857 });
@@ -10,7 +10,6 @@ import Extent from './extent.js';
10
10
  * @param {number} right
11
11
  * @param {number} epsilon
12
12
  * @returns {boolean}
13
- * @export
14
13
  */
15
14
  export function propertyEqualsEpsilon(left, right, epsilon) {
16
15
  return Math.abs(left - right) <= epsilon;
@@ -22,7 +21,6 @@ export function propertyEqualsEpsilon(left, right, epsilon) {
22
21
  * @param {number} right angle in degree
23
22
  * @param {number} epsilon in degree
24
23
  * @returns {boolean}
25
- * @export
26
24
  */
27
25
  export function angleEqualsEpsilon(left, right, epsilon) {
28
26
  const diff = (left - right) - Math.trunc((left - right) / 360) * 360;
@@ -36,7 +34,6 @@ export function angleEqualsEpsilon(left, right, epsilon) {
36
34
  * @param {import("ol/coordinate").Coordinate} right
37
35
  * @param {number} epsilon
38
36
  * @returns {boolean}
39
- * @export
40
37
  */
41
38
  export function coordinateEqualsEpsilon(left, right, epsilon) {
42
39
  return left !== null && right !== null &&
@@ -60,7 +57,6 @@ export function coordinateEqualsEpsilon(left, right, epsilon) {
60
57
  /**
61
58
  * A Viewpoint Object
62
59
  * @class
63
- * @export
64
60
  * @extends {VcsObject}
65
61
  * @api stable
66
62
  */
package/src/vcsApp.js CHANGED
@@ -33,6 +33,7 @@ import ClassRegistry, {
33
33
  styleClassRegistry,
34
34
  tileProviderClassRegistry,
35
35
  } from './classRegistry.js';
36
+ import { detectBrowserLocale } from './util/locale.js';
36
37
 
37
38
  /**
38
39
  * @returns {import("@vcsuite/logger").Logger}
@@ -69,6 +70,20 @@ class VcsApp {
69
70
 
70
71
  const getDynamicContextId = () => this._dynamicContext.id;
71
72
 
73
+ /**
74
+ * represents the current Locale.
75
+ * @type {string}
76
+ * @private
77
+ */
78
+ this._locale = detectBrowserLocale();
79
+
80
+ /**
81
+ * fires if the current Locale changes.
82
+ * @type {VcsEvent<string>}
83
+ * @private
84
+ */
85
+ this._localeChanged = new VcsEvent();
86
+
72
87
  /**
73
88
  * @type {OverrideClassRegistry<VcsMap>}
74
89
  * @private
@@ -104,6 +119,8 @@ class VcsApp {
104
119
  Layer,
105
120
  getLayerIndex,
106
121
  );
122
+ this._layers.locale = this.locale;
123
+
107
124
  /**
108
125
  * @type {OverrideCollection<import("@vcmap/core").ObliqueCollection>}
109
126
  * @private
@@ -184,6 +201,7 @@ class VcsApp {
184
201
  * @private
185
202
  */
186
203
  this._featureProviderClassRegsitry = new OverrideClassRegistry(featureProviderClassRegistry);
204
+
187
205
  vcsApps.set(this._id, this);
188
206
  }
189
207
 
@@ -193,6 +211,40 @@ class VcsApp {
193
211
  */
194
212
  get id() { return this._id; }
195
213
 
214
+ /**
215
+ * @returns {string}
216
+ */
217
+ get locale() {
218
+ return this._locale;
219
+ }
220
+
221
+ /**
222
+ * sets the locale of the vcsApp and the linked layerCollection.
223
+ * This will trigger the localeChanged Event.
224
+ * @param {string} value new locale with 2 letters
225
+ */
226
+ set locale(value) {
227
+ check(value, String);
228
+
229
+ if (value.length !== 2) {
230
+ getLogger().warning('Provide a valid locale, for example "en", "de" with max. 2 letters');
231
+ return;
232
+ }
233
+ if (this._locale !== value) {
234
+ this._locale = value;
235
+ this.layers.locale = value;
236
+ this._localeChanged.raiseEvent(value);
237
+ }
238
+ }
239
+
240
+ /**
241
+ * @type {VcsEvent<string>}
242
+ * @readonly
243
+ */
244
+ get localeChanged() {
245
+ return this._localeChanged;
246
+ }
247
+
196
248
  /**
197
249
  * @type {OverrideMapCollection}
198
250
  * @readonly
@@ -454,6 +506,7 @@ class VcsApp {
454
506
  this._featureProviderClassRegsitry.destroy();
455
507
  this.destroyed.raiseEvent();
456
508
  this.destroyed.destroy();
509
+ this.localeChanged.destroy();
457
510
  }
458
511
  }
459
512
 
package/src/vcsEvent.js CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * @class
3
3
  * @template {*} T
4
- * @export
5
4
  * @api
6
5
  */
7
6
  class VcsEvent {