@vcmap/core 6.2.2 → 6.3.0-rc.1

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 (293) hide show
  1. package/dist/index.d.ts +3 -1
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/category/category.d.ts +1 -1
  5. package/dist/src/category/category.js +3 -4
  6. package/dist/src/category/category.js.map +1 -1
  7. package/dist/src/featureProvider/abstractFeatureProvider.d.ts +1 -1
  8. package/dist/src/featureProvider/abstractFeatureProvider.js +3 -4
  9. package/dist/src/featureProvider/abstractFeatureProvider.js.map +1 -1
  10. package/dist/src/featureProvider/wmsFeatureProvider.d.ts +3 -1
  11. package/dist/src/featureProvider/wmsFeatureProvider.js +37 -9
  12. package/dist/src/featureProvider/wmsFeatureProvider.js.map +1 -1
  13. package/dist/src/interaction/coordinateAtPixel.js +4 -6
  14. package/dist/src/interaction/coordinateAtPixel.js.map +1 -1
  15. package/dist/src/interaction/ensurePositionInteraction.d.ts +14 -0
  16. package/dist/src/interaction/ensurePositionInteraction.js +42 -0
  17. package/dist/src/interaction/ensurePositionInteraction.js.map +1 -0
  18. package/dist/src/interaction/eventHandler.d.ts +3 -0
  19. package/dist/src/interaction/eventHandler.js +10 -1
  20. package/dist/src/interaction/eventHandler.js.map +1 -1
  21. package/dist/src/interaction/featureAtPixelInteraction.js +29 -17
  22. package/dist/src/interaction/featureAtPixelInteraction.js.map +1 -1
  23. package/dist/src/interaction/panoramaImageSelection.js +2 -2
  24. package/dist/src/interaction/panoramaImageSelection.js.map +1 -1
  25. package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.d.ts +3 -3
  26. package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js.map +1 -1
  27. package/dist/src/layer/cesium/cogImageryProvider.d.ts +2 -2
  28. package/dist/src/layer/cesium/cogImageryProvider.js +6 -26
  29. package/dist/src/layer/cesium/cogImageryProvider.js.map +1 -1
  30. package/dist/src/layer/cesium/rasterLayerCesiumImpl.d.ts +3 -3
  31. package/dist/src/layer/cesium/rasterLayerCesiumImpl.js.map +1 -1
  32. package/dist/src/layer/cesium/terrainCesiumImpl.d.ts +3 -3
  33. package/dist/src/layer/cesium/terrainCesiumImpl.js.map +1 -1
  34. package/dist/src/layer/cesium/vectorContext.js +1 -1
  35. package/dist/src/layer/cesium/vectorContext.js.map +1 -1
  36. package/dist/src/layer/cesiumTilesetLayer.d.ts +1 -1
  37. package/dist/src/layer/cesiumTilesetLayer.js +7 -7
  38. package/dist/src/layer/cesiumTilesetLayer.js.map +1 -1
  39. package/dist/src/layer/cogLayer.d.ts +7 -2
  40. package/dist/src/layer/cogLayer.js +10 -4
  41. package/dist/src/layer/cogLayer.js.map +1 -1
  42. package/dist/src/layer/czmlLayer.d.ts +1 -1
  43. package/dist/src/layer/czmlLayer.js +4 -4
  44. package/dist/src/layer/czmlLayer.js.map +1 -1
  45. package/dist/src/layer/featureLayer.d.ts +1 -6
  46. package/dist/src/layer/featureLayer.js +3 -10
  47. package/dist/src/layer/featureLayer.js.map +1 -1
  48. package/dist/src/layer/featureStoreLayer.d.ts +3 -2
  49. package/dist/src/layer/featureStoreLayer.js +5 -5
  50. package/dist/src/layer/featureStoreLayer.js.map +1 -1
  51. package/dist/src/layer/flatGeobufLayer.d.ts +2 -0
  52. package/dist/src/layer/flatGeobufLayer.js +8 -0
  53. package/dist/src/layer/flatGeobufLayer.js.map +1 -1
  54. package/dist/src/layer/geojsonLayer.d.ts +1 -1
  55. package/dist/src/layer/geojsonLayer.js +5 -12
  56. package/dist/src/layer/geojsonLayer.js.map +1 -1
  57. package/dist/src/layer/layer.d.ts +21 -7
  58. package/dist/src/layer/layer.js +107 -33
  59. package/dist/src/layer/layer.js.map +1 -1
  60. package/dist/src/layer/openStreetMapLayer.d.ts +1 -1
  61. package/dist/src/layer/openStreetMapLayer.js +11 -6
  62. package/dist/src/layer/openStreetMapLayer.js.map +1 -1
  63. package/dist/src/layer/panorama/vectorPanoramaImpl.d.ts +38 -0
  64. package/dist/src/layer/panorama/vectorPanoramaImpl.js +164 -0
  65. package/dist/src/layer/panorama/vectorPanoramaImpl.js.map +1 -0
  66. package/dist/src/layer/panoramaDatasetLayer.d.ts +5 -3
  67. package/dist/src/layer/panoramaDatasetLayer.js +13 -7
  68. package/dist/src/layer/panoramaDatasetLayer.js.map +1 -1
  69. package/dist/src/layer/pointCloudLayer.d.ts +1 -5
  70. package/dist/src/layer/pointCloudLayer.js +3 -15
  71. package/dist/src/layer/pointCloudLayer.js.map +1 -1
  72. package/dist/src/layer/rasterLayer.d.ts +1 -1
  73. package/dist/src/layer/rasterLayer.js +4 -4
  74. package/dist/src/layer/rasterLayer.js.map +1 -1
  75. package/dist/src/layer/singleImageLayer.d.ts +1 -1
  76. package/dist/src/layer/singleImageLayer.js +3 -3
  77. package/dist/src/layer/singleImageLayer.js.map +1 -1
  78. package/dist/src/layer/terrainLayer.d.ts +1 -1
  79. package/dist/src/layer/terrainLayer.js +8 -6
  80. package/dist/src/layer/terrainLayer.js.map +1 -1
  81. package/dist/src/layer/tileProvider/flatGeobufTileProvider.d.ts +1 -1
  82. package/dist/src/layer/tileProvider/flatGeobufTileProvider.js +4 -3
  83. package/dist/src/layer/tileProvider/flatGeobufTileProvider.js.map +1 -1
  84. package/dist/src/layer/tileProvider/mvtTileProvider.d.ts +1 -1
  85. package/dist/src/layer/tileProvider/mvtTileProvider.js +3 -3
  86. package/dist/src/layer/tileProvider/mvtTileProvider.js.map +1 -1
  87. package/dist/src/layer/tileProvider/staticFeatureTileProvider.d.ts +1 -1
  88. package/dist/src/layer/tileProvider/staticFeatureTileProvider.js +3 -3
  89. package/dist/src/layer/tileProvider/staticFeatureTileProvider.js.map +1 -1
  90. package/dist/src/layer/tileProvider/staticGeojsonTileProvider.d.ts +1 -1
  91. package/dist/src/layer/tileProvider/staticGeojsonTileProvider.js +7 -4
  92. package/dist/src/layer/tileProvider/staticGeojsonTileProvider.js.map +1 -1
  93. package/dist/src/layer/tileProvider/tileProvider.d.ts +1 -1
  94. package/dist/src/layer/tileProvider/tileProvider.js +3 -4
  95. package/dist/src/layer/tileProvider/tileProvider.js.map +1 -1
  96. package/dist/src/layer/tileProvider/urlTemplateTileProvider.d.ts +1 -1
  97. package/dist/src/layer/tileProvider/urlTemplateTileProvider.js +3 -3
  98. package/dist/src/layer/tileProvider/urlTemplateTileProvider.js.map +1 -1
  99. package/dist/src/layer/tmsLayer.d.ts +1 -1
  100. package/dist/src/layer/tmsLayer.js +3 -10
  101. package/dist/src/layer/tmsLayer.js.map +1 -1
  102. package/dist/src/layer/vectorLayer.d.ts +11 -5
  103. package/dist/src/layer/vectorLayer.js +19 -8
  104. package/dist/src/layer/vectorLayer.js.map +1 -1
  105. package/dist/src/layer/vectorTileLayer.d.ts +1 -1
  106. package/dist/src/layer/vectorTileLayer.js +4 -5
  107. package/dist/src/layer/vectorTileLayer.js.map +1 -1
  108. package/dist/src/layer/wfsLayer.d.ts +1 -1
  109. package/dist/src/layer/wfsLayer.js +5 -4
  110. package/dist/src/layer/wfsLayer.js.map +1 -1
  111. package/dist/src/layer/wmsLayer.d.ts +1 -1
  112. package/dist/src/layer/wmsLayer.js +3 -4
  113. package/dist/src/layer/wmsLayer.js.map +1 -1
  114. package/dist/src/layer/wmtsLayer.d.ts +1 -1
  115. package/dist/src/layer/wmtsLayer.js +3 -10
  116. package/dist/src/layer/wmtsLayer.js.map +1 -1
  117. package/dist/src/map/baseCesiumMap.d.ts +69 -0
  118. package/dist/src/map/baseCesiumMap.js +381 -0
  119. package/dist/src/map/baseCesiumMap.js.map +1 -0
  120. package/dist/src/map/cesiumMap.d.ts +6 -98
  121. package/dist/src/map/cesiumMap.js +32 -258
  122. package/dist/src/map/cesiumMap.js.map +1 -1
  123. package/dist/src/map/obliqueMap.d.ts +1 -1
  124. package/dist/src/map/obliqueMap.js +3 -4
  125. package/dist/src/map/obliqueMap.js.map +1 -1
  126. package/dist/src/map/openlayersMap.d.ts +1 -1
  127. package/dist/src/map/openlayersMap.js +3 -4
  128. package/dist/src/map/openlayersMap.js.map +1 -1
  129. package/dist/src/map/panoramaMap.d.ts +17 -29
  130. package/dist/src/map/panoramaMap.js +56 -100
  131. package/dist/src/map/panoramaMap.js.map +1 -1
  132. package/dist/src/map/vcsMap.d.ts +15 -2
  133. package/dist/src/map/vcsMap.js +26 -3
  134. package/dist/src/map/vcsMap.js.map +1 -1
  135. package/dist/src/oblique/obliqueCollection.d.ts +1 -1
  136. package/dist/src/oblique/obliqueCollection.js +3 -4
  137. package/dist/src/oblique/obliqueCollection.js.map +1 -1
  138. package/dist/src/panorama/panoramaCameraController.d.ts +4 -0
  139. package/dist/src/panorama/panoramaCameraController.js +8 -0
  140. package/dist/src/panorama/panoramaCameraController.js.map +1 -1
  141. package/dist/src/panorama/panoramaImage.d.ts +10 -1
  142. package/dist/src/panorama/panoramaImage.js +9 -4
  143. package/dist/src/panorama/panoramaImage.js.map +1 -1
  144. package/dist/src/panorama/panoramaImageView.d.ts +6 -1
  145. package/dist/src/panorama/panoramaImageView.js +11 -2
  146. package/dist/src/panorama/panoramaImageView.js.map +1 -1
  147. package/dist/src/panorama/panoramaTileMaterial.d.ts +6 -0
  148. package/dist/src/panorama/panoramaTileMaterial.js +14 -0
  149. package/dist/src/panorama/panoramaTileMaterial.js.map +1 -1
  150. package/dist/src/panorama/panoramaTileMaterialFS.shader.d.ts +1 -1
  151. package/dist/src/panorama/panoramaTileMaterialFS.shader.js +16 -1
  152. package/dist/src/panorama/panoramaTileMaterialFS.shader.js.map +1 -1
  153. package/dist/src/panorama/panoramaTilePrimitiveCollection.d.ts +6 -0
  154. package/dist/src/panorama/panoramaTilePrimitiveCollection.js +28 -0
  155. package/dist/src/panorama/panoramaTilePrimitiveCollection.js.map +1 -1
  156. package/dist/src/util/clipping/clippingPolygonObject.d.ts +1 -1
  157. package/dist/src/util/clipping/clippingPolygonObject.js +3 -4
  158. package/dist/src/util/clipping/clippingPolygonObject.js.map +1 -1
  159. package/dist/src/util/displayQuality/displayQuality.js +4 -4
  160. package/dist/src/util/displayQuality/displayQuality.js.map +1 -1
  161. package/dist/src/util/editor/createFeatureSession.js +3 -1
  162. package/dist/src/util/editor/createFeatureSession.js.map +1 -1
  163. package/dist/src/util/editor/editFeaturesSession.js +9 -2
  164. package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
  165. package/dist/src/util/editor/editGeometrySession.js +3 -1
  166. package/dist/src/util/editor/editGeometrySession.js.map +1 -1
  167. package/dist/src/util/editor/editorSessionHelpers.d.ts +3 -3
  168. package/dist/src/util/editor/editorSessionHelpers.js +4 -2
  169. package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
  170. package/dist/src/util/editor/interactions/creationSnapping.js +4 -1
  171. package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -1
  172. package/dist/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +2 -2
  173. package/dist/src/util/editor/interactions/ensureHandlerSelectionInteraction.js.map +1 -1
  174. package/dist/src/util/editor/interactions/layerSnapping.js +4 -1
  175. package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -1
  176. package/dist/src/util/editor/interactions/mapInteractionController.js +12 -1
  177. package/dist/src/util/editor/interactions/mapInteractionController.js.map +1 -1
  178. package/dist/src/util/editor/interactions/translationSnapping.js +4 -2
  179. package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -1
  180. package/dist/src/util/editor/selectFeaturesSession.js +1 -1
  181. package/dist/src/util/editor/selectFeaturesSession.js.map +1 -1
  182. package/dist/src/util/editor/transformation/create3DHandlers.d.ts +2 -2
  183. package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
  184. package/dist/src/util/editor/transformation/transformationHandler.js +5 -2
  185. package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
  186. package/dist/src/util/editor/transformation/translateInteraction.js +2 -2
  187. package/dist/src/util/editor/transformation/translateInteraction.js.map +1 -1
  188. package/dist/src/util/flight/flightInstance.d.ts +1 -1
  189. package/dist/src/util/flight/flightInstance.js +3 -4
  190. package/dist/src/util/flight/flightInstance.js.map +1 -1
  191. package/dist/src/util/mapCollection.d.ts +5 -0
  192. package/dist/src/util/mapCollection.js +14 -0
  193. package/dist/src/util/mapCollection.js.map +1 -1
  194. package/dist/src/util/renderScreenshot.js +2 -3
  195. package/dist/src/util/renderScreenshot.js.map +1 -1
  196. package/dist/src/util/viewpoint.js +1 -1
  197. package/dist/src/util/viewpoint.js.map +1 -1
  198. package/dist/src/vcsObject.d.ts +2 -1
  199. package/dist/src/vcsObject.js +9 -1
  200. package/dist/src/vcsObject.js.map +1 -1
  201. package/dist/src/vectorCluster/vectorClusterGroup.d.ts +1 -1
  202. package/dist/src/vectorCluster/vectorClusterGroup.js +3 -4
  203. package/dist/src/vectorCluster/vectorClusterGroup.js.map +1 -1
  204. package/dist/src/vectorCluster/vectorClusterStyleItem.d.ts +1 -1
  205. package/dist/src/vectorCluster/vectorClusterStyleItem.js +3 -4
  206. package/dist/src/vectorCluster/vectorClusterStyleItem.js.map +1 -1
  207. package/dist/tests/unit/helpers/cesiumHelpers.d.ts +11 -1
  208. package/dist/tests/unit/helpers/cesiumHelpers.js +19 -2
  209. package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
  210. package/dist/tests/unit/helpers/panoramaHelpers.js +1 -1
  211. package/dist/tests/unit/helpers/panoramaHelpers.js.map +1 -1
  212. package/index.ts +3 -5
  213. package/package.json +2 -2
  214. package/src/category/category.ts +3 -4
  215. package/src/featureProvider/abstractFeatureProvider.ts +5 -4
  216. package/src/featureProvider/wmsFeatureProvider.ts +52 -14
  217. package/src/global.d.ts +0 -1
  218. package/src/interaction/coordinateAtPixel.ts +4 -6
  219. package/src/interaction/ensurePositionInteraction.ts +50 -0
  220. package/src/interaction/eventHandler.ts +12 -1
  221. package/src/interaction/featureAtPixelInteraction.ts +39 -29
  222. package/src/interaction/panoramaImageSelection.ts +4 -2
  223. package/src/layer/cesium/cesiumTilesetCesiumImpl.ts +3 -3
  224. package/src/layer/cesium/cogImageryProvider.ts +9 -26
  225. package/src/layer/cesium/rasterLayerCesiumImpl.ts +3 -3
  226. package/src/layer/cesium/terrainCesiumImpl.ts +3 -3
  227. package/src/layer/cesium/vectorContext.ts +1 -1
  228. package/src/layer/cesiumTilesetLayer.ts +9 -7
  229. package/src/layer/cogLayer.ts +22 -6
  230. package/src/layer/czmlLayer.ts +4 -4
  231. package/src/layer/featureLayer.ts +5 -16
  232. package/src/layer/featureStoreLayer.ts +11 -5
  233. package/src/layer/flatGeobufLayer.ts +12 -0
  234. package/src/layer/geojsonLayer.ts +5 -12
  235. package/src/layer/layer.ts +148 -36
  236. package/src/layer/openStreetMapLayer.ts +13 -6
  237. package/src/layer/panorama/vectorPanoramaImpl.ts +238 -0
  238. package/src/layer/panoramaDatasetLayer.ts +25 -10
  239. package/src/layer/pointCloudLayer.ts +5 -20
  240. package/src/layer/rasterLayer.ts +4 -4
  241. package/src/layer/singleImageLayer.ts +5 -3
  242. package/src/layer/terrainLayer.ts +9 -6
  243. package/src/layer/tileProvider/flatGeobufTileProvider.ts +6 -3
  244. package/src/layer/tileProvider/mvtTileProvider.ts +7 -3
  245. package/src/layer/tileProvider/staticFeatureTileProvider.ts +5 -3
  246. package/src/layer/tileProvider/staticGeojsonTileProvider.ts +11 -4
  247. package/src/layer/tileProvider/tileProvider.ts +5 -4
  248. package/src/layer/tileProvider/urlTemplateTileProvider.ts +7 -3
  249. package/src/layer/tmsLayer.ts +3 -10
  250. package/src/layer/vectorLayer.ts +25 -9
  251. package/src/layer/vectorTileLayer.ts +6 -6
  252. package/src/layer/wfsLayer.ts +7 -4
  253. package/src/layer/wmsLayer.ts +3 -4
  254. package/src/layer/wmtsLayer.ts +3 -10
  255. package/src/map/baseCesiumMap.ts +576 -0
  256. package/src/map/cesiumMap.ts +103 -446
  257. package/src/map/obliqueMap.ts +3 -4
  258. package/src/map/openlayersMap.ts +5 -5
  259. package/src/map/panoramaMap.ts +74 -139
  260. package/src/map/vcsMap.ts +44 -4
  261. package/src/oblique/obliqueCollection.ts +5 -4
  262. package/src/panorama/panoramaCameraController.ts +13 -1
  263. package/src/panorama/panoramaImage.ts +17 -3
  264. package/src/panorama/panoramaImageView.ts +29 -3
  265. package/src/panorama/panoramaTileMaterial.ts +20 -0
  266. package/src/panorama/panoramaTileMaterialFS.glsl +16 -1
  267. package/src/panorama/panoramaTilePrimitiveCollection.ts +34 -0
  268. package/src/util/clipping/clippingPolygonObject.ts +5 -4
  269. package/src/util/displayQuality/displayQuality.ts +4 -4
  270. package/src/util/editor/createFeatureSession.ts +4 -1
  271. package/src/util/editor/editFeaturesSession.ts +14 -4
  272. package/src/util/editor/editGeometrySession.ts +3 -1
  273. package/src/util/editor/editorSessionHelpers.ts +5 -3
  274. package/src/util/editor/interactions/creationSnapping.ts +7 -1
  275. package/src/util/editor/interactions/ensureHandlerSelectionInteraction.ts +2 -2
  276. package/src/util/editor/interactions/layerSnapping.ts +7 -1
  277. package/src/util/editor/interactions/mapInteractionController.ts +12 -2
  278. package/src/util/editor/interactions/translationSnapping.ts +6 -4
  279. package/src/util/editor/selectFeaturesSession.ts +1 -1
  280. package/src/util/editor/transformation/create3DHandlers.ts +2 -2
  281. package/src/util/editor/transformation/transformationHandler.ts +5 -3
  282. package/src/util/editor/transformation/translateInteraction.ts +4 -4
  283. package/src/util/flight/flightInstance.ts +6 -5
  284. package/src/util/mapCollection.ts +18 -0
  285. package/src/util/renderScreenshot.ts +4 -8
  286. package/src/util/viewpoint.ts +2 -2
  287. package/src/vcsObject.ts +10 -1
  288. package/src/vectorCluster/vectorClusterGroup.ts +7 -4
  289. package/src/vectorCluster/vectorClusterStyleItem.ts +8 -4
  290. package/dist/src/map/cesiumMapHelpers.d.ts +0 -7
  291. package/dist/src/map/cesiumMapHelpers.js +0 -144
  292. package/dist/src/map/cesiumMapHelpers.js.map +0 -1
  293. package/src/map/cesiumMapHelpers.ts +0 -219
@@ -58,6 +58,10 @@ export type LayerOptions = VcsObjectOptions & {
58
58
  * Optional Request Headers which will be sent with each request.
59
59
  */
60
60
  headers?: Record<string, string>;
61
+ /**
62
+ * if true, the layer types of the map will be ignored when checking if the layer is supported
63
+ */
64
+ ignoreMapLayerTypes?: boolean;
61
65
  };
62
66
 
63
67
  export type LayerImplementationOptions = {
@@ -92,6 +96,7 @@ class Layer<
92
96
  copyright: undefined,
93
97
  datasourceId: undefined,
94
98
  headers: undefined,
99
+ ignoreMapLayerTypes: false,
95
100
  zIndex: 0,
96
101
  };
97
102
  }
@@ -108,12 +113,9 @@ class Layer<
108
113
 
109
114
  private _initialized: boolean;
110
115
 
111
- /**
112
- * if provided, the layer will only be shown in the given MapNames.
113
- * An empty array will show the layer in all configured maps.
114
- * Changes require calling layer.redraw() to take effect.
115
- */
116
- mapNames: string[];
116
+ private _mapNames: string[];
117
+
118
+ readonly mapNamesChanged = new VcsEvent<string[]>();
117
119
 
118
120
  /**
119
121
  * The class names of the supported maps.
@@ -145,9 +147,12 @@ class Layer<
145
147
 
146
148
  copyright: CopyrightOptions | undefined;
147
149
 
148
- private _implementations: Map<VcsMap, I[]>;
150
+ private _implementations = new Map<
151
+ VcsMap,
152
+ { implementations: I[]; destroy: () => void }
153
+ >();
149
154
 
150
- private _activeMaps: Set<VcsMap>;
155
+ private _activeMaps = new Set<VcsMap>();
151
156
 
152
157
  /**
153
158
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -169,9 +174,11 @@ class Layer<
169
174
  */
170
175
  datasourceId?: string;
171
176
 
177
+ private _ignoreMapLayerTypes: boolean;
178
+
172
179
  constructor(options: LayerOptions) {
173
- super(options);
174
180
  const defaultOptions = Layer.getDefaultOptions();
181
+ super({ ...defaultOptions, ...options });
175
182
 
176
183
  this.extent = options.extent ? new Extent(options.extent) : null;
177
184
 
@@ -191,7 +198,8 @@ class Layer<
191
198
 
192
199
  this._initialized = false;
193
200
 
194
- this.mapNames = options.mapNames ?? (defaultOptions.mapNames as string[]);
201
+ this._mapNames =
202
+ options.mapNames?.slice() ?? (defaultOptions.mapNames as string[]);
195
203
 
196
204
  this._supportedMaps = [];
197
205
 
@@ -215,19 +223,18 @@ class Layer<
215
223
 
216
224
  this.copyright = options.copyright || defaultOptions.copyright;
217
225
 
218
- this._implementations = new Map();
219
-
220
- this._activeMaps = new Set();
221
-
222
226
  this.stateChanged = new VcsEvent();
223
227
 
224
- this.featureProvider = undefined;
225
-
226
228
  this._locale = 'en';
227
229
 
228
230
  this.datasourceId = options.datasourceId || defaultOptions.datasourceId;
229
231
 
230
232
  this._headers = structuredClone(options.headers);
233
+
234
+ this._ignoreMapLayerTypes = parseBoolean(
235
+ options.ignoreMapLayerTypes,
236
+ defaultOptions.ignoreMapLayerTypes,
237
+ );
231
238
  }
232
239
 
233
240
  /**
@@ -304,6 +311,31 @@ class Layer<
304
311
  return this._globalHider;
305
312
  }
306
313
 
314
+ get mapNames(): string[] {
315
+ return this._mapNames.slice();
316
+ }
317
+
318
+ /**
319
+ * if provided, the layer will only be shown in the given MapNames.
320
+ * An empty array will show the layer in all configured maps.
321
+ * Changes will call reload on the layer.
322
+ */
323
+ set mapNames(mapNames: string[]) {
324
+ check(mapNames, [String]);
325
+
326
+ if (
327
+ mapNames.length !== this._mapNames.length ||
328
+ !mapNames.every((m) => this._mapNames.includes(m))
329
+ ) {
330
+ this._mapNames = mapNames.slice();
331
+ this.mapNamesChanged.raiseEvent(this._mapNames.slice());
332
+ this.forceRedraw().catch((err: unknown) => {
333
+ this.getLogger().error('failed to reload after mapNames setting');
334
+ this.getLogger().error(String(err));
335
+ });
336
+ }
337
+ }
338
+
307
339
  setGlobalHider(globalHider?: GlobalHider): void {
308
340
  check(globalHider, maybe(GlobalHider));
309
341
 
@@ -400,6 +432,28 @@ class Layer<
400
432
  }
401
433
  }
402
434
 
435
+ get ignoreMapLayerTypes(): boolean {
436
+ return this._ignoreMapLayerTypes;
437
+ }
438
+
439
+ /**
440
+ * if set to true, the layer types of the map will be ignored when checking if the layer is supported.
441
+ * Changes will call reload on the layer.
442
+ */
443
+ set ignoreMapLayerTypes(value: boolean) {
444
+ check(value, Boolean);
445
+
446
+ if (this._ignoreMapLayerTypes !== value) {
447
+ this._ignoreMapLayerTypes = value;
448
+ this.reload().catch((err: unknown) => {
449
+ this.getLogger().error(
450
+ 'failed to reload after setting ignoreMapLayerTypes',
451
+ );
452
+ this.getLogger().error(String(err));
453
+ });
454
+ }
455
+ }
456
+
403
457
  /**
404
458
  * creates an array of layer implementations for the given map.
405
459
  * @param _map Map
@@ -417,20 +471,61 @@ class Layer<
417
471
  */
418
472
  getImplementationsForMap(map: VcsMap): I[] {
419
473
  if (!this._implementations.has(map)) {
474
+ let currentlySupported = this.isSupported(map);
475
+ let destroy: () => void;
476
+ const layerTypesChangedListener = map.layerTypesChanged.addEventListener(
477
+ () => {
478
+ const nowSupported = this.isSupported(map);
479
+ if (currentlySupported !== nowSupported) {
480
+ currentlySupported = nowSupported;
481
+ // either destroy current implementation or remove the empty array for unsupported layers.
482
+ // either way we have to reset this map if the inclusion changes
483
+ destroy();
484
+
485
+ if (
486
+ this.initialized &&
487
+ map.active &&
488
+ (this.active || this.loading)
489
+ ) {
490
+ this.getImplementationsForMap(map);
491
+ if (nowSupported) {
492
+ this._activateImplsForMap(map).catch(() => {
493
+ this.getLogger().error(
494
+ `Layer ${this.name} could not activate impl for map ${map.name} after layerTypesChanged`,
495
+ );
496
+ });
497
+ }
498
+ }
499
+ }
500
+ },
501
+ );
502
+ destroy = (): void => {
503
+ layerTypesChangedListener();
504
+ this._implementations.get(map)?.implementations?.forEach((i) => {
505
+ i.destroy();
506
+ });
507
+ this._implementations.delete(map);
508
+ };
509
+
420
510
  if (this.isSupported(map)) {
421
- this._implementations.set(map, this.createImplementationsForMap(map));
511
+ this._implementations.set(map, {
512
+ implementations: this.createImplementationsForMap(map),
513
+ destroy,
514
+ });
422
515
  } else {
423
- this._implementations.set(map, []);
516
+ this._implementations.set(map, { implementations: [], destroy });
424
517
  }
425
518
  }
426
- return this._implementations.get(map)!;
519
+ return this._implementations.get(map)!.implementations;
427
520
  }
428
521
 
429
522
  /**
430
523
  * Returns all implementation of this layer for all maps
431
524
  */
432
525
  getImplementations(): I[] {
433
- return [...this._implementations.values()].flat();
526
+ return [...this._implementations.values()].flatMap(
527
+ (i) => i.implementations,
528
+ );
434
529
  }
435
530
 
436
531
  getImplementationOptions(): LayerImplementationOptions {
@@ -529,10 +624,7 @@ class Layer<
529
624
  */
530
625
  removedFromMap(map: VcsMap): void {
531
626
  this._activeMaps.delete(map);
532
- this.getImplementationsForMap(map).forEach((impl) => {
533
- impl.destroy();
534
- });
535
- this._implementations.delete(map);
627
+ this._implementations.get(map)?.destroy();
536
628
  }
537
629
 
538
630
  /**
@@ -540,10 +632,23 @@ class Layer<
540
632
  * @param map
541
633
  */
542
634
  isSupported(map: VcsMap): boolean {
635
+ if (!map) {
636
+ return false;
637
+ }
638
+
639
+ const isSupportedMap = (): boolean =>
640
+ this._supportedMaps.includes(map.className);
641
+
642
+ const isAllowedMapName = (): boolean =>
643
+ this._mapNames.length === 0 || this._mapNames.includes(map.name);
644
+
645
+ const isAllowedLayerType = (): boolean =>
646
+ this._ignoreMapLayerTypes ||
647
+ map.layerTypes.length === 0 ||
648
+ map.layerTypes.includes(this.className);
649
+
543
650
  return (
544
- map &&
545
- this._supportedMaps.includes(map.className) &&
546
- (this.mapNames.length === 0 || this.mapNames.indexOf(map.name) >= 0)
651
+ !!map && isSupportedMap() && isAllowedMapName() && isAllowedLayerType()
547
652
  );
548
653
  }
549
654
 
@@ -556,9 +661,12 @@ class Layer<
556
661
  `Layer ${this.name} could not activate impl for map ${map.name}`,
557
662
  );
558
663
  this.getLogger().error(String(err));
559
- this._implementations.set(map, []);
560
- impls.forEach((i) => {
561
- i.destroy();
664
+ this._implementations.get(map)?.destroy();
665
+ this._implementations.set(map, {
666
+ implementations: [],
667
+ destroy: () => {
668
+ this._implementations.delete(map);
669
+ },
562
670
  });
563
671
  }
564
672
  }
@@ -580,7 +688,7 @@ class Layer<
580
688
  }
581
689
 
582
690
  await Promise.all(
583
- [...this._activeMaps].map((m) => this._activateImplsForMap(m)),
691
+ [...this._activeMaps.keys()].map((m) => this._activateImplsForMap(m)),
584
692
  );
585
693
  if (this._state !== LayerState.LOADING) {
586
694
  return;
@@ -653,9 +761,8 @@ class Layer<
653
761
  }
654
762
  }
655
763
 
656
- toJSON(): LayerOptions {
657
- const config: LayerOptions = super.toJSON();
658
- const defaultOptions = Layer.getDefaultOptions();
764
+ toJSON(defaultOptions = Layer.getDefaultOptions()): LayerOptions {
765
+ const config: LayerOptions = super.toJSON(defaultOptions);
659
766
 
660
767
  if (this.activeOnStartup !== defaultOptions.activeOnStartup) {
661
768
  config.activeOnStartup = this.activeOnStartup;
@@ -665,8 +772,8 @@ class Layer<
665
772
  config.allowPicking = this.allowPicking;
666
773
  }
667
774
 
668
- if (this.mapNames.length > 0) {
669
- config.mapNames = this.mapNames.slice();
775
+ if (this._mapNames.length > 0) {
776
+ config.mapNames = this._mapNames.slice();
670
777
  }
671
778
 
672
779
  if (this.hiddenObjectIds.length > 0) {
@@ -701,6 +808,10 @@ class Layer<
701
808
  config.zIndex = this._zIndex;
702
809
  }
703
810
 
811
+ if (this._ignoreMapLayerTypes !== defaultOptions.ignoreMapLayerTypes) {
812
+ config.ignoreMapLayerTypes = this._ignoreMapLayerTypes;
813
+ }
814
+
704
815
  return config;
705
816
  }
706
817
 
@@ -723,6 +834,7 @@ class Layer<
723
834
  this.stateChanged.destroy();
724
835
  this.zIndexChanged.destroy();
725
836
  this.exclusiveGroupsChanged.destroy();
837
+ this.mapNamesChanged.destroy();
726
838
  }
727
839
  }
728
840
 
@@ -12,6 +12,8 @@ import { layerClassRegistry } from '../classRegistry.js';
12
12
  import type { RasterLayerImplementationOptions } from './rasterLayer.js';
13
13
  import { TilingScheme } from './rasterLayer.js';
14
14
  import type VcsMap from '../map/vcsMap.js';
15
+ import PanoramaMap from '../map/panoramaMap.js';
16
+ import BaseCesiumMap from '../map/baseCesiumMap.js';
15
17
 
16
18
  export type OpenStreetMapOptions = LayerOptions & {
17
19
  /**
@@ -102,11 +104,15 @@ class OpenStreetMapLayer
102
104
  */
103
105
  imageryLayerOptions: ImageryLayer.ConstructorOptions | undefined;
104
106
 
105
- protected _supportedMaps = [CesiumMap.className, OpenlayersMap.className];
107
+ protected _supportedMaps = [
108
+ CesiumMap.className,
109
+ OpenlayersMap.className,
110
+ PanoramaMap.className,
111
+ ];
106
112
 
107
113
  constructor(options: OpenStreetMapOptions) {
108
- super(options);
109
114
  const defaultOptions = OpenStreetMapLayer.getDefaultOptions();
115
+ super({ ...defaultOptions, ...options });
110
116
  this._splitDirection = SplitDirection.NONE;
111
117
 
112
118
  if (options.splitDirection) {
@@ -188,7 +194,7 @@ class OpenStreetMapLayer
188
194
  ];
189
195
  }
190
196
 
191
- if (map instanceof CesiumMap) {
197
+ if (map instanceof BaseCesiumMap) {
192
198
  return [
193
199
  new OpenStreetMapCesiumImpl(map, this.getImplementationOptions()),
194
200
  ];
@@ -196,9 +202,10 @@ class OpenStreetMapLayer
196
202
  return [];
197
203
  }
198
204
 
199
- toJSON(): OpenStreetMapOptions {
200
- const config: OpenStreetMapOptions = super.toJSON();
201
- const defaultOptions = OpenStreetMapLayer.getDefaultOptions();
205
+ toJSON(
206
+ defaultOptions = OpenStreetMapLayer.getDefaultOptions(),
207
+ ): OpenStreetMapOptions {
208
+ const config: OpenStreetMapOptions = super.toJSON(defaultOptions);
202
209
 
203
210
  if (this._splitDirection !== SplitDirection.NONE) {
204
211
  config.splitDirection =
@@ -0,0 +1,238 @@
1
+ import { PrimitiveCollection, type SplitDirection } from '@vcmap-cesium/engine';
2
+ import VectorSource from 'ol/source/Vector.js';
3
+ import { unByKey } from 'ol/Observable.js';
4
+ import type { Feature } from 'ol/index.js';
5
+ import { vcsLayerName } from '../layerSymbols.js';
6
+ import LayerImplementation from '../layerImplementation.js';
7
+ import { synchronizeFeatureVisibilityWithSource } from '../vectorHelpers.js';
8
+ import type { FeatureLayerImplementation } from '../featureLayer.js';
9
+ import type { VectorImplementationOptions } from '../vectorLayer.js';
10
+ import type VectorProperties from '../vectorProperties.js';
11
+ import type StyleItem from '../../style/styleItem.js';
12
+ import type FeatureVisibility from '../featureVisibility.js';
13
+ import type GlobalHider from '../globalHider.js';
14
+ import VectorContext from '../cesium/vectorContext.js';
15
+ import {
16
+ createSourceVectorContextSync,
17
+ type SourceVectorContextSync,
18
+ } from '../cesium/sourceVectorContextSync.js';
19
+ import type PanoramaMap from '../../map/panoramaMap.js';
20
+ import type { PanoramaImage } from '../../panorama/panoramaImage.js';
21
+ import { cartesianToMercator } from '../../util/math.js';
22
+
23
+ type PanoramaSourceSync = {
24
+ paused: boolean;
25
+ destroy: () => void;
26
+ };
27
+
28
+ function getImageExtent(
29
+ image: PanoramaImage,
30
+ ): [number, number, number, number] {
31
+ const center = cartesianToMercator(image.position);
32
+ const depth = image.maxDepth ?? 50;
33
+ return [
34
+ center[0] - depth,
35
+ center[1] - depth,
36
+ center[0] + depth,
37
+ center[1] + depth,
38
+ ];
39
+ }
40
+
41
+ function featureWithinImage(feature?: Feature, image?: PanoramaImage): boolean {
42
+ if (feature && image) {
43
+ const extent = getImageExtent(image);
44
+ return feature.getGeometry()?.intersectsExtent(extent) ?? false;
45
+ }
46
+ return false;
47
+ }
48
+
49
+ function setupMapSourceListeners(
50
+ map: PanoramaMap,
51
+ originalSource: VectorSource,
52
+ panoramaSource: VectorSource,
53
+ ): PanoramaSourceSync {
54
+ let paused = false;
55
+ const sourceListeners = [
56
+ originalSource.on('addfeature', (event) => {
57
+ if (
58
+ !paused &&
59
+ featureWithinImage(event.feature, map.currentPanoramaImage)
60
+ ) {
61
+ panoramaSource.addFeature(event.feature as Feature);
62
+ }
63
+ }),
64
+ originalSource.on('removefeature', (event) => {
65
+ panoramaSource.removeFeature(event.feature as Feature);
66
+ }),
67
+ ];
68
+
69
+ const setFeatures = (): void => {
70
+ panoramaSource.clear();
71
+ if (map.currentPanoramaImage) {
72
+ const extent = getImageExtent(map.currentPanoramaImage);
73
+ originalSource.getFeaturesInExtent(extent).forEach((f) => {
74
+ panoramaSource.addFeature(f);
75
+ });
76
+ }
77
+ };
78
+ const panoramaImageListener =
79
+ map.currentImageChanged.addEventListener(setFeatures);
80
+
81
+ return {
82
+ get paused(): boolean {
83
+ return paused;
84
+ },
85
+ set paused(p: boolean) {
86
+ paused = p;
87
+ if (!paused) {
88
+ setFeatures();
89
+ }
90
+ },
91
+ destroy: (): void => {
92
+ unByKey(sourceListeners);
93
+ panoramaImageListener();
94
+ },
95
+ };
96
+ }
97
+
98
+ /**
99
+ * represents a specific vector layer for cesium.
100
+ */
101
+ export default class VectorPanoramaImpl
102
+ extends LayerImplementation<PanoramaMap>
103
+ implements FeatureLayerImplementation
104
+ {
105
+ static get className(): string {
106
+ return 'VectorPanoramaImpl';
107
+ }
108
+
109
+ vectorProperties: VectorProperties;
110
+
111
+ source: VectorSource;
112
+
113
+ splitDirection: SplitDirection;
114
+
115
+ style: StyleItem;
116
+
117
+ featureVisibility: FeatureVisibility;
118
+
119
+ private _featureVisibilityListeners: (() => void)[] = [];
120
+
121
+ private _rootCollection: PrimitiveCollection;
122
+
123
+ private _context: VectorContext | null = null;
124
+
125
+ private _sourceVectorContextSync: SourceVectorContextSync | undefined;
126
+
127
+ private _sourceSync: PanoramaSourceSync;
128
+
129
+ globalHider: GlobalHider | undefined;
130
+
131
+ constructor(map: PanoramaMap, options: VectorImplementationOptions) {
132
+ super(map, options);
133
+
134
+ this.vectorProperties = options.vectorProperties;
135
+ this.source = new VectorSource();
136
+
137
+ this.splitDirection = options.splitDirection;
138
+ this.style = options.style;
139
+ this.featureVisibility = options.featureVisibility;
140
+
141
+ this._rootCollection = new PrimitiveCollection();
142
+ this._rootCollection[vcsLayerName] = options.name;
143
+ this.globalHider = options.globalHider;
144
+ this._sourceSync = setupMapSourceListeners(
145
+ map,
146
+ options.source,
147
+ this.source,
148
+ );
149
+ this._sourceSync.paused = true;
150
+ }
151
+
152
+ async initialize(): Promise<void> {
153
+ if (!this.initialized) {
154
+ this._context = new VectorContext(
155
+ this.map,
156
+ this._rootCollection,
157
+ this.splitDirection,
158
+ );
159
+ this.map.addPrimitiveCollection(this._rootCollection);
160
+ this._sourceVectorContextSync = createSourceVectorContextSync(
161
+ this.source,
162
+ this._context,
163
+ this.map.getCesiumWidget().scene,
164
+ this.style.style,
165
+ this.vectorProperties,
166
+ );
167
+ }
168
+ await super.initialize();
169
+ if (this.splitDirection) {
170
+ this.updateSplitDirection(this.splitDirection);
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Forces a complete re-render of all features.
176
+ */
177
+ refresh(): void {
178
+ this._sourceVectorContextSync?.refresh();
179
+ }
180
+
181
+ async activate(): Promise<void> {
182
+ if (!this.active) {
183
+ await super.activate();
184
+ if (this.active) {
185
+ this._sourceVectorContextSync?.activate();
186
+ this._rootCollection.show = true;
187
+ if (this._featureVisibilityListeners.length === 0) {
188
+ this._featureVisibilityListeners =
189
+ synchronizeFeatureVisibilityWithSource(
190
+ this.featureVisibility,
191
+ this.source,
192
+ this.globalHider as GlobalHider,
193
+ );
194
+ }
195
+ this._sourceSync.paused = false;
196
+ }
197
+ }
198
+ }
199
+
200
+ deactivate(): void {
201
+ super.deactivate();
202
+ this._sourceVectorContextSync?.deactivate();
203
+ this._rootCollection.show = false;
204
+ this._featureVisibilityListeners.forEach((cb) => {
205
+ cb();
206
+ });
207
+ this._featureVisibilityListeners = [];
208
+ this._sourceSync.paused = true;
209
+ }
210
+
211
+ updateStyle(style: StyleItem, silent?: boolean): void {
212
+ this.style = style;
213
+ this._sourceVectorContextSync?.setStyle(style.style, silent);
214
+ }
215
+
216
+ updateSplitDirection(splitDirection: SplitDirection): void {
217
+ this.splitDirection = splitDirection;
218
+ if (this.initialized) {
219
+ this._context?.updateSplitDirection(splitDirection);
220
+ }
221
+ }
222
+
223
+ destroy(): void {
224
+ if (this.initialized) {
225
+ this._sourceVectorContextSync?.destroy();
226
+ this._context?.destroy();
227
+ this.map.removePrimitiveCollection(this._rootCollection);
228
+ this._rootCollection.destroy();
229
+ }
230
+ this._context = null;
231
+ this._featureVisibilityListeners.forEach((cb) => {
232
+ cb();
233
+ });
234
+ this._featureVisibilityListeners = [];
235
+ this._sourceSync.destroy();
236
+ super.destroy();
237
+ }
238
+ }