@vcmap/core 5.0.0-rc.11 → 5.0.0-rc.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export interface CategoryOptions extends VcsObjectOptions {
20
20
  /**
21
21
  * the class registry name on the current app to provide classes for this category. if provided, parseItems will deserialize using this class registry. See: {@link getObjectFromClassRegistry}.
22
22
  */
23
- classRegistryName?: string;
23
+ classRegistryName?: string | symbol;
24
24
  featureProperty?: string | undefined;
25
25
  layerOptions?: VectorOptions;
26
26
  /**
@@ -44,11 +44,15 @@ export class Category<T extends Object|VcsObject> extends VcsObject {
44
44
  };
45
45
  protected _app: VcsApp;
46
46
  protected _layer: VectorLayer;
47
- readonly classRegistryName: string;
47
+ readonly classRegistryName: string | symbol;
48
48
  /**
49
49
  * The collection of this category.
50
50
  */
51
51
  readonly collection: OverrideCollection<T>;
52
+ /**
53
+ * Event raised if the collection is reset
54
+ */
55
+ readonly collectionChanged: VcsEvent<void>;
52
56
  /**
53
57
  * Returns the layer of this collection. Caution, do not use the layer API to add or remove items.
54
58
  * When adding items to the collection, the features are added to the layer async (timeout of 0), since there is weird behavior
@@ -65,7 +69,7 @@ export class Category<T extends Object|VcsObject> extends VcsObject {
65
69
  */
66
70
  mergeOptions(options: CategoryOptions): void;
67
71
  /**
68
- * When setting the category, it MUST use the same unqiueKey as the previous collection (default is "name").
72
+ * When setting the category, it MUST use the same uniqueKey as the previous collection (default is "name").
69
73
  * All items in the current collection _will be destroyed_ and the current collection will be destroyed. The category will take
70
74
  * complete ownership of the collection and destroy it once the category is destroyed. The collection will
71
75
  * be turned into an {@see OverrideCollection}.
@@ -749,6 +753,7 @@ export class CesiumTilesetCesiumImpl extends LayerImplementation<CesiumMap> impl
749
753
  splitDirection: import("@vcmap/cesium").SplitDirection;
750
754
  style: StyleItem;
751
755
  featureVisibility: FeatureVisibility;
756
+ globalHider: GlobalHider;
752
757
  tilesetProperties: CesiumTilesetTilesetProperties[];
753
758
  modelMatrix: import("@vcmap/cesium").Matrix4;
754
759
  offset: import("ol/coordinate").Coordinate;
@@ -878,6 +883,7 @@ export class VectorCesiumImpl extends LayerImplementation<CesiumMap> implements
878
883
  featureVisibility: FeatureVisibility;
879
884
 
880
885
  protected _context: VectorContext | ClusterContext | null;
886
+ globalHider: GlobalHider;
881
887
  protected _setupContext(cesiumMap: CesiumMap): Promise<void>;
882
888
  initialize(): Promise<void>;
883
889
  /**
@@ -1151,15 +1157,10 @@ export class CesiumTilesetLayer extends FeatureLayer implements SplitLayer {
1151
1157
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
1152
1158
  */
1153
1159
  zIndexChanged: VcsEvent<number>;
1154
- /**
1155
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
1156
- */
1157
- hiddenObjectIds: string[];
1158
1160
  /**
1159
1161
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
1160
1162
  */
1161
1163
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
1162
- globalHider: GlobalHider;
1163
1164
  copyright: CopyrightOptions | undefined;
1164
1165
  /**
1165
1166
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -1181,6 +1182,8 @@ export class CesiumTilesetLayer extends FeatureLayer implements SplitLayer {
1181
1182
  * A layers url, should on be configured, else an empty string
1182
1183
  */
1183
1184
  url: string;
1185
+ hiddenObjectIds: string[];
1186
+ readonly globalHider: GlobalHider | null;
1184
1187
  /**
1185
1188
  * Indicates, that this layer is part of an exclusiveGroup
1186
1189
  */
@@ -1242,15 +1245,10 @@ export class CzmlLayer extends DataSourceLayer {
1242
1245
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
1243
1246
  */
1244
1247
  zIndexChanged: VcsEvent<number>;
1245
- /**
1246
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
1247
- */
1248
- hiddenObjectIds: string[];
1249
1248
  /**
1250
1249
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
1251
1250
  */
1252
1251
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
1253
- globalHider: GlobalHider;
1254
1252
  copyright: CopyrightOptions | undefined;
1255
1253
  /**
1256
1254
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -1272,6 +1270,8 @@ export class CzmlLayer extends DataSourceLayer {
1272
1270
  * A layers url, should on be configured, else an empty string
1273
1271
  */
1274
1272
  url: string;
1273
+ hiddenObjectIds: string[];
1274
+ readonly globalHider: GlobalHider | null;
1275
1275
  /**
1276
1276
  * Indicates, that this layer is part of an exclusiveGroup
1277
1277
  */
@@ -1358,15 +1358,10 @@ export class DataSourceLayer extends Layer {
1358
1358
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
1359
1359
  */
1360
1360
  zIndexChanged: VcsEvent<number>;
1361
- /**
1362
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
1363
- */
1364
- hiddenObjectIds: string[];
1365
1361
  /**
1366
1362
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
1367
1363
  */
1368
1364
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
1369
- globalHider: GlobalHider;
1370
1365
  copyright: CopyrightOptions | undefined;
1371
1366
  /**
1372
1367
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -1388,6 +1383,8 @@ export class DataSourceLayer extends Layer {
1388
1383
  * A layers url, should on be configured, else an empty string
1389
1384
  */
1390
1385
  url: string;
1386
+ hiddenObjectIds: string[];
1387
+ readonly globalHider: GlobalHider | null;
1391
1388
  /**
1392
1389
  * Indicates, that this layer is part of an exclusiveGroup
1393
1390
  */
@@ -1421,6 +1418,7 @@ export interface FeatureLayerOptions extends LayerOptions {
1421
1418
  }
1422
1419
 
1423
1420
  export interface FeatureLayerImplementationOptions extends LayerImplementationOptions {
1421
+ globalHider: GlobalHider;
1424
1422
  featureVisibility: FeatureVisibility;
1425
1423
  style: StyleItem;
1426
1424
  }
@@ -1500,15 +1498,10 @@ export class FeatureLayer extends Layer {
1500
1498
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
1501
1499
  */
1502
1500
  zIndexChanged: VcsEvent<number>;
1503
- /**
1504
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
1505
- */
1506
- hiddenObjectIds: string[];
1507
1501
  /**
1508
1502
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
1509
1503
  */
1510
1504
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
1511
- globalHider: GlobalHider;
1512
1505
  copyright: CopyrightOptions | undefined;
1513
1506
  /**
1514
1507
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -1530,6 +1523,8 @@ export class FeatureLayer extends Layer {
1530
1523
  * A layers url, should on be configured, else an empty string
1531
1524
  */
1532
1525
  url: string;
1526
+ hiddenObjectIds: string[];
1527
+ readonly globalHider: GlobalHider | null;
1533
1528
  /**
1534
1529
  * Indicates, that this layer is part of an exclusiveGroup
1535
1530
  */
@@ -1717,15 +1712,10 @@ export class FeatureStoreLayer extends VectorLayer {
1717
1712
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
1718
1713
  */
1719
1714
  zIndexChanged: VcsEvent<number>;
1720
- /**
1721
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
1722
- */
1723
- hiddenObjectIds: string[];
1724
1715
  /**
1725
1716
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
1726
1717
  */
1727
1718
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
1728
- globalHider: GlobalHider;
1729
1719
  copyright: CopyrightOptions | undefined;
1730
1720
  /**
1731
1721
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -1746,6 +1736,8 @@ export class FeatureStoreLayer extends VectorLayer {
1746
1736
  * A layers url, should on be configured, else an empty string
1747
1737
  */
1748
1738
  url: string;
1739
+ hiddenObjectIds: string[];
1740
+ readonly globalHider: GlobalHider | null;
1749
1741
  /**
1750
1742
  * Indicates, that this layer is part of an exclusiveGroup
1751
1743
  */
@@ -1904,6 +1896,11 @@ export const enum FeatureVisibilityAction {
1904
1896
 
1905
1897
  export function synchronizeFeatureVisibility(source: FeatureVisibility, destination: FeatureVisibility): (...params: any[]) => any;
1906
1898
 
1899
+ /**
1900
+ * FeatureVisibility handles the visibility and highlighting of features of a specific {@link FeatureLayer} or {@link DataSourceLayer}
1901
+ * and its {@link FeatureLayerImplementation} resp. {@link DataSourceCesiumImpl}.
1902
+ * The visibility is being synchronized with the {@link GlobalHider}.
1903
+ */
1907
1904
  export class FeatureVisibility {
1908
1905
  hiddenObjects: {
1909
1906
  [key: string]: Set<import("@vcmap/cesium").Cesium3DTileFeature | import("ol").Feature<import("ol/geom/Geometry").default> | import("@vcmap/cesium").Entity>;
@@ -2121,15 +2118,10 @@ export class GeoJSONLayer extends VectorLayer {
2121
2118
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
2122
2119
  */
2123
2120
  zIndexChanged: VcsEvent<number>;
2124
- /**
2125
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
2126
- */
2127
- hiddenObjectIds: string[];
2128
2121
  /**
2129
2122
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
2130
2123
  */
2131
2124
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
2132
- globalHider: GlobalHider;
2133
2125
  copyright: CopyrightOptions | undefined;
2134
2126
  /**
2135
2127
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -2150,6 +2142,8 @@ export class GeoJSONLayer extends VectorLayer {
2150
2142
  * A layers url, should on be configured, else an empty string
2151
2143
  */
2152
2144
  url: string;
2145
+ hiddenObjectIds: string[];
2146
+ readonly globalHider: GlobalHider | null;
2153
2147
  /**
2154
2148
  * Indicates, that this layer is part of an exclusiveGroup
2155
2149
  */
@@ -2167,6 +2161,17 @@ export class GeoJSONLayer extends VectorLayer {
2167
2161
  readonly className: string;
2168
2162
  }
2169
2163
 
2164
+ export interface HiddenObject {
2165
+ id: string;
2166
+ }
2167
+
2168
+ /**
2169
+ * GlobalHider globally hides features existing within a layer of a {@link LayerCollection}.
2170
+ * Features can be defined as hidden by {@link VcsAppConfig} or {@link LayerOptions}.
2171
+ * Hiding will be performed, when a {@link Context} is loaded, a {@link Layer} is activated or GlobalHider API is called.
2172
+ * A feature can be hidden multiple times by different actors, e.g. contexts, layers, which is handled by this class.
2173
+ * A feature will be shown again, when a {@link Context} is removed, a {@link Layer} is deactivated or GlobalHider API is called.
2174
+ */
2170
2175
  export class GlobalHider {
2171
2176
  hiddenObjects: {
2172
2177
  [key: string]: number;
@@ -2189,8 +2194,6 @@ export class GlobalHider {
2189
2194
  hasFeature(uuid: string | number, feature: import("ol").Feature<import("ol/geom/Geometry").default> | import("@vcmap/cesium").Cesium3DTileFeature | import("@vcmap/cesium").Cesium3DTilePointFeature | import("@vcmap/cesium").Entity): boolean;
2190
2195
  }
2191
2196
 
2192
- export function getGlobalHider(): GlobalHider;
2193
-
2194
2197
  export interface GenericFeature {
2195
2198
  longitude: number;
2196
2199
  latitude: number;
@@ -2315,15 +2318,10 @@ export class Layer extends VcsObject {
2315
2318
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
2316
2319
  */
2317
2320
  zIndexChanged: VcsEvent<number>;
2318
- /**
2319
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
2320
- */
2321
- hiddenObjectIds: string[];
2322
2321
  /**
2323
2322
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
2324
2323
  */
2325
2324
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
2326
- globalHider: GlobalHider;
2327
2325
  copyright: CopyrightOptions | undefined;
2328
2326
  /**
2329
2327
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -2342,6 +2340,9 @@ export class Layer extends VcsObject {
2342
2340
  readonly state: LayerState;
2343
2341
  allowPicking: any;
2344
2342
  url: any;
2343
+ hiddenObjectIds: any;
2344
+ readonly globalHider: GlobalHider | null;
2345
+ setGlobalHider(globalHider: GlobalHider): void;
2345
2346
  /**
2346
2347
  * Indicates, that this layer is part of an exclusiveGroup
2347
2348
  */
@@ -2612,15 +2613,10 @@ export class OpenStreetMapLayer extends Layer implements SplitLayer {
2612
2613
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
2613
2614
  */
2614
2615
  zIndexChanged: VcsEvent<number>;
2615
- /**
2616
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
2617
- */
2618
- hiddenObjectIds: string[];
2619
2616
  /**
2620
2617
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
2621
2618
  */
2622
2619
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
2623
- globalHider: GlobalHider;
2624
2620
  copyright: CopyrightOptions | undefined;
2625
2621
  /**
2626
2622
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -2642,6 +2638,8 @@ export class OpenStreetMapLayer extends Layer implements SplitLayer {
2642
2638
  * A layers url, should on be configured, else an empty string
2643
2639
  */
2644
2640
  url: string;
2641
+ hiddenObjectIds: string[];
2642
+ readonly globalHider: GlobalHider | null;
2645
2643
  /**
2646
2644
  * Indicates, that this layer is part of an exclusiveGroup
2647
2645
  */
@@ -2753,6 +2751,7 @@ export class VectorOpenlayersImpl extends LayerOpenlayersImpl implements Feature
2753
2751
  minResolution: number;
2754
2752
  featureVisibility: FeatureVisibility;
2755
2753
  olLayer: import("ol/layer/Vector").default<import("ol/source").Vector<import("ol/geom/Geometry").default>> | null;
2754
+ globalHider: GlobalHider;
2756
2755
  updateStyle(style: StyleItem, silent?: boolean): void;
2757
2756
  setVisibility(visibility: boolean): void;
2758
2757
  }
@@ -2921,15 +2920,10 @@ export class PointCloudLayer extends CesiumTilesetLayer {
2921
2920
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
2922
2921
  */
2923
2922
  zIndexChanged: VcsEvent<number>;
2924
- /**
2925
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
2926
- */
2927
- hiddenObjectIds: string[];
2928
2923
  /**
2929
2924
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
2930
2925
  */
2931
2926
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
2932
- globalHider: GlobalHider;
2933
2927
  copyright: CopyrightOptions | undefined;
2934
2928
  /**
2935
2929
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -2951,6 +2945,8 @@ export class PointCloudLayer extends CesiumTilesetLayer {
2951
2945
  * A layers url, should on be configured, else an empty string
2952
2946
  */
2953
2947
  url: string;
2948
+ hiddenObjectIds: string[];
2949
+ readonly globalHider: GlobalHider | null;
2954
2950
  /**
2955
2951
  * Indicates, that this layer is part of an exclusiveGroup
2956
2952
  */
@@ -3065,15 +3061,10 @@ export class RasterLayer extends Layer implements SplitLayer {
3065
3061
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
3066
3062
  */
3067
3063
  zIndexChanged: VcsEvent<number>;
3068
- /**
3069
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
3070
- */
3071
- hiddenObjectIds: string[];
3072
3064
  /**
3073
3065
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
3074
3066
  */
3075
3067
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
3076
- globalHider: GlobalHider;
3077
3068
  copyright: CopyrightOptions | undefined;
3078
3069
  /**
3079
3070
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -3095,6 +3086,8 @@ export class RasterLayer extends Layer implements SplitLayer {
3095
3086
  * A layers url, should on be configured, else an empty string
3096
3087
  */
3097
3088
  url: string;
3089
+ hiddenObjectIds: string[];
3090
+ readonly globalHider: GlobalHider | null;
3098
3091
  /**
3099
3092
  * Indicates, that this layer is part of an exclusiveGroup
3100
3093
  */
@@ -3176,15 +3169,10 @@ export class SingleImageLayer extends RasterLayer {
3176
3169
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
3177
3170
  */
3178
3171
  zIndexChanged: VcsEvent<number>;
3179
- /**
3180
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
3181
- */
3182
- hiddenObjectIds: string[];
3183
3172
  /**
3184
3173
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
3185
3174
  */
3186
3175
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
3187
- globalHider: GlobalHider;
3188
3176
  copyright: CopyrightOptions | undefined;
3189
3177
  /**
3190
3178
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -3206,6 +3194,8 @@ export class SingleImageLayer extends RasterLayer {
3206
3194
  * A layers url, should on be configured, else an empty string
3207
3195
  */
3208
3196
  url: string;
3197
+ hiddenObjectIds: string[];
3198
+ readonly globalHider: GlobalHider | null;
3209
3199
  /**
3210
3200
  * Indicates, that this layer is part of an exclusiveGroup
3211
3201
  */
@@ -3294,15 +3284,10 @@ export class TerrainLayer extends Layer {
3294
3284
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
3295
3285
  */
3296
3286
  zIndexChanged: VcsEvent<number>;
3297
- /**
3298
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
3299
- */
3300
- hiddenObjectIds: string[];
3301
3287
  /**
3302
3288
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
3303
3289
  */
3304
3290
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
3305
- globalHider: GlobalHider;
3306
3291
  copyright: CopyrightOptions | undefined;
3307
3292
  /**
3308
3293
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -3324,6 +3309,8 @@ export class TerrainLayer extends Layer {
3324
3309
  * A layers url, should on be configured, else an empty string
3325
3310
  */
3326
3311
  url: string;
3312
+ hiddenObjectIds: string[];
3313
+ readonly globalHider: GlobalHider | null;
3327
3314
  /**
3328
3315
  * Indicates, that this layer is part of an exclusiveGroup
3329
3316
  */
@@ -3742,15 +3729,10 @@ export class TMSLayer extends RasterLayer {
3742
3729
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
3743
3730
  */
3744
3731
  zIndexChanged: VcsEvent<number>;
3745
- /**
3746
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
3747
- */
3748
- hiddenObjectIds: string[];
3749
3732
  /**
3750
3733
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
3751
3734
  */
3752
3735
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
3753
- globalHider: GlobalHider;
3754
3736
  copyright: CopyrightOptions | undefined;
3755
3737
  /**
3756
3738
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -3772,6 +3754,8 @@ export class TMSLayer extends RasterLayer {
3772
3754
  * A layers url, should on be configured, else an empty string
3773
3755
  */
3774
3756
  url: string;
3757
+ hiddenObjectIds: string[];
3758
+ readonly globalHider: GlobalHider | null;
3775
3759
  /**
3776
3760
  * Indicates, that this layer is part of an exclusiveGroup
3777
3761
  */
@@ -4001,15 +3985,10 @@ export class VectorLayer extends FeatureLayer {
4001
3985
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
4002
3986
  */
4003
3987
  zIndexChanged: VcsEvent<number>;
4004
- /**
4005
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
4006
- */
4007
- hiddenObjectIds: string[];
4008
3988
  /**
4009
3989
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
4010
3990
  */
4011
3991
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
4012
- globalHider: GlobalHider;
4013
3992
  copyright: CopyrightOptions | undefined;
4014
3993
  /**
4015
3994
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -4030,6 +4009,8 @@ export class VectorLayer extends FeatureLayer {
4030
4009
  * A layers url, should on be configured, else an empty string
4031
4010
  */
4032
4011
  url: string;
4012
+ hiddenObjectIds: string[];
4013
+ readonly globalHider: GlobalHider | null;
4033
4014
  /**
4034
4015
  * Indicates, that this layer is part of an exclusiveGroup
4035
4016
  */
@@ -4365,15 +4346,10 @@ export class VectorTileLayer extends FeatureLayer {
4365
4346
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
4366
4347
  */
4367
4348
  zIndexChanged: VcsEvent<number>;
4368
- /**
4369
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
4370
- */
4371
- hiddenObjectIds: string[];
4372
4349
  /**
4373
4350
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
4374
4351
  */
4375
4352
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
4376
- globalHider: GlobalHider;
4377
4353
  copyright: CopyrightOptions | undefined;
4378
4354
  /**
4379
4355
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -4395,6 +4371,8 @@ export class VectorTileLayer extends FeatureLayer {
4395
4371
  * A layers url, should on be configured, else an empty string
4396
4372
  */
4397
4373
  url: string;
4374
+ hiddenObjectIds: string[];
4375
+ readonly globalHider: GlobalHider | null;
4398
4376
  /**
4399
4377
  * Indicates, that this layer is part of an exclusiveGroup
4400
4378
  */
@@ -4511,15 +4489,10 @@ export class WFSLayer extends VectorLayer {
4511
4489
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
4512
4490
  */
4513
4491
  zIndexChanged: VcsEvent<number>;
4514
- /**
4515
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
4516
- */
4517
- hiddenObjectIds: string[];
4518
4492
  /**
4519
4493
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
4520
4494
  */
4521
4495
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
4522
- globalHider: GlobalHider;
4523
4496
  copyright: CopyrightOptions | undefined;
4524
4497
  /**
4525
4498
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -4540,6 +4513,8 @@ export class WFSLayer extends VectorLayer {
4540
4513
  * A layers url, should on be configured, else an empty string
4541
4514
  */
4542
4515
  url: string;
4516
+ hiddenObjectIds: string[];
4517
+ readonly globalHider: GlobalHider | null;
4543
4518
  /**
4544
4519
  * Indicates, that this layer is part of an exclusiveGroup
4545
4520
  */
@@ -4675,15 +4650,10 @@ export class WMSLayer extends RasterLayer {
4675
4650
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
4676
4651
  */
4677
4652
  zIndexChanged: VcsEvent<number>;
4678
- /**
4679
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
4680
- */
4681
- hiddenObjectIds: string[];
4682
4653
  /**
4683
4654
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
4684
4655
  */
4685
4656
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
4686
- globalHider: GlobalHider;
4687
4657
  copyright: CopyrightOptions | undefined;
4688
4658
  /**
4689
4659
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -4705,6 +4675,8 @@ export class WMSLayer extends RasterLayer {
4705
4675
  * A layers url, should on be configured, else an empty string
4706
4676
  */
4707
4677
  url: string;
4678
+ hiddenObjectIds: string[];
4679
+ readonly globalHider: GlobalHider | null;
4708
4680
  /**
4709
4681
  * Indicates, that this layer is part of an exclusiveGroup
4710
4682
  */
@@ -4803,15 +4775,10 @@ export class WMTSLayer extends RasterLayer {
4803
4775
  * Called when the zIndex of this layer is changed. Is passed the new zIndex as its only argument.
4804
4776
  */
4805
4777
  zIndexChanged: VcsEvent<number>;
4806
- /**
4807
- * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
4808
- */
4809
- hiddenObjectIds: string[];
4810
4778
  /**
4811
4779
  * event raised if the exclusives group of the layer changes. is passed the array of exclusive groups as its only argument
4812
4780
  */
4813
4781
  exclusiveGroupsChanged: VcsEvent<(string | symbol)[]>;
4814
- globalHider: GlobalHider;
4815
4782
  copyright: CopyrightOptions | undefined;
4816
4783
  /**
4817
4784
  * Event raised, if the layers state changes. Is passed the LayerState as its only parameter
@@ -4833,6 +4800,8 @@ export class WMTSLayer extends RasterLayer {
4833
4800
  * A layers url, should on be configured, else an empty string
4834
4801
  */
4835
4802
  url: string;
4803
+ hiddenObjectIds: string[];
4804
+ readonly globalHider: GlobalHider | null;
4836
4805
  /**
4837
4806
  * Indicates, that this layer is part of an exclusiveGroup
4838
4807
  */
@@ -7034,6 +7003,10 @@ export class LayerCollection extends IndexedCollection<Layer> {
7034
7003
  * ensures consistency by setting a new local z index if needed.
7035
7004
  */
7036
7005
  readonly zIndexSymbol: symbol;
7006
+ /**
7007
+ * Set global hider for these maps.
7008
+ */
7009
+ globalHider: any;
7037
7010
  /**
7038
7011
  * Adds a layer to the collection. Can optionally be passed an index at which to insert the layer.
7039
7012
  * @returns returns the layer index or null, if the layers name is not unique
package/index.js CHANGED
@@ -48,7 +48,7 @@ export { featureStoreStateSymbol, FeatureStoreLayerState } from './src/layer/fea
48
48
  export { originalStyle, highlighted, hidden, globalHidden, featureExists, FeatureVisibilityAction, synchronizeFeatureVisibility, default as FeatureVisibility } from './src/layer/featureVisibility.js';
49
49
  export { getEPSGCodeFromGeojson, updateLegacyFeature, parseGeoJSON, writeGeoJSONFeature, writeGeoJSON } from './src/layer/geojsonHelpers.js';
50
50
  export { featureFromOptions, default as GeoJSONLayer } from './src/layer/geojsonLayer.js';
51
- export { getGlobalHider, default as GlobalHider } from './src/layer/globalHider.js';
51
+ export { default as GlobalHider } from './src/layer/globalHider.js';
52
52
  export { vcsMetaVersion, default as Layer } from './src/layer/layer.js';
53
53
  export { default as LayerImplementation } from './src/layer/layerImplementation.js';
54
54
  export { default as LayerState } from './src/layer/layerState.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/core",
3
- "version": "5.0.0-rc.11",
3
+ "version": "5.0.0-rc.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -11,11 +11,12 @@ import Collection from '../util/collection.js';
11
11
  import { getStyleOrDefaultStyle } from '../style/styleFactory.js';
12
12
  import { categoryClassRegistry, getObjectFromClassRegistry } from '../classRegistry.js';
13
13
  import OverrideClassRegistry from '../overrideClassRegistry.js';
14
+ import VcsEvent from '../vcsEvent.js';
14
15
 
15
16
  /**
16
17
  * @typedef {VcsObjectOptions} CategoryOptions
17
18
  * @property {string|Object<string, string>} [title]
18
- * @property {string} [classRegistryName=''] - the class registry name on the current app to provide classes for this category. if provided, parseItems will deserialize using this class registry. See: {@link getObjectFromClassRegistry}.
19
+ * @property {string|symbol} [classRegistryName] - the class registry name on the current app to provide classes for this category. if provided, parseItems will deserialize using this class registry. See: {@link getObjectFromClassRegistry}.
19
20
  * @property {string|undefined} [featureProperty]
20
21
  * @property {VectorOptions} [layerOptions={}]
21
22
  * @property {Array<Object>} [items] - items are not evaluated by the constructor but passed to parseItem during deserialization.
@@ -56,7 +57,7 @@ function assignLayerOptions(layer, options) {
56
57
  * @param {T} value
57
58
  * @param {T} defaultOption
58
59
  * @param {T=} option
59
- * @template {number|boolean|string} T
60
+ * @template {number|boolean|string|symbol} T
60
61
  * @returns {void}
61
62
  */
62
63
  function checkMergeOptionOverride(key, value, defaultOption, option) {
@@ -113,7 +114,7 @@ class Category extends VcsObject {
113
114
  */
114
115
  this._featureProperty = options.featureProperty || defaultOptions.featureProperty;
115
116
  /**
116
- * @type {string}
117
+ * @type {string|symbol}
117
118
  * @private
118
119
  */
119
120
  this._classRegistryName = options.classRegistryName;
@@ -136,6 +137,12 @@ class Category extends VcsObject {
136
137
  * @private
137
138
  */
138
139
  this._keyProperty = options.keyProperty || defaultOptions.keyProperty;
140
+ /**
141
+ * Event raised if the collection is reset
142
+ * @type {VcsEvent<void>}
143
+ * @private
144
+ */
145
+ this._collectionChanged = new VcsEvent();
139
146
  /**
140
147
  * @type {Array<function():void>}
141
148
  * @private
@@ -155,7 +162,7 @@ class Category extends VcsObject {
155
162
  }
156
163
 
157
164
  /**
158
- * @type {string}
165
+ * @type {string|symbol}
159
166
  * @readonly
160
167
  */
161
168
  get classRegistryName() { return this._classRegistryName; }
@@ -169,6 +176,13 @@ class Category extends VcsObject {
169
176
  return this._collection;
170
177
  }
171
178
 
179
+ /**
180
+ * Event raised if the collection is reset
181
+ * @type {VcsEvent<void>}
182
+ * @readonly
183
+ */
184
+ get collectionChanged() { return this._collectionChanged; }
185
+
172
186
  /**
173
187
  * Returns the layer of this collection. Caution, do not use the layer API to add or remove items.
174
188
  * When adding items to the collection, the features are added to the layer async (timeout of 0), since there is weird behavior
@@ -268,7 +282,7 @@ class Category extends VcsObject {
268
282
  }
269
283
 
270
284
  /**
271
- * When setting the category, it MUST use the same unqiueKey as the previous collection (default is "name").
285
+ * When setting the category, it MUST use the same uniqueKey as the previous collection (default is "name").
272
286
  * All items in the current collection _will be destroyed_ and the current collection will be destroyed. The category will take
273
287
  * complete ownership of the collection and destroy it once the category is destroyed. The collection will
274
288
  * be turned into an {@see OverrideCollection}.
@@ -314,6 +328,7 @@ class Category extends VcsObject {
314
328
  // @ts-ignore
315
329
  this._collectionListeners.push(this._collection.moved.addEventListener(this._itemMoved.bind(this)));
316
330
  }
331
+ this.collectionChanged.raiseEvent();
317
332
  }
318
333
 
319
334
  /**
@@ -393,6 +408,7 @@ class Category extends VcsObject {
393
408
  this._contextRemovedListener();
394
409
  this._contextRemovedListener = () => {};
395
410
  destroyCollection(this._collection);
411
+ this._collectionChanged.destroy();
396
412
  this._app = null;
397
413
  }
398
414
  }
@@ -11,7 +11,6 @@ import {
11
11
  import { createEmpty } from 'ol/extent.js';
12
12
  import LayerImplementation from '../layerImplementation.js';
13
13
  import { vcsLayerName } from '../layerSymbols.js';
14
- import { getGlobalHider } from '../globalHider.js';
15
14
  import { originalStyle, updateOriginalStyle } from '../featureVisibility.js';
16
15
  import Projection from '../../util/projection.js';
17
16
  import { circleFromCenterRadius } from '../../util/geometryHelpers.js';
@@ -84,6 +83,8 @@ class CesiumTilesetCesiumImpl extends LayerImplementation {
84
83
  this.style = options.style;
85
84
  /** @type {import("@vcmap/core").FeatureVisibility} */
86
85
  this.featureVisibility = options.featureVisibility;
86
+ /** @type {import("@vcmap/core").GlobalHider} */
87
+ this.globalHider = options.globalHider;
87
88
  /** @type {Array<CesiumTilesetTilesetProperties>} */
88
89
  this.tilesetProperties = options.tilesetProperties;
89
90
  /** @type {import("@vcmap/cesium").Matrix4} */
@@ -105,7 +106,6 @@ class CesiumTilesetCesiumImpl extends LayerImplementation {
105
106
  * @private
106
107
  */
107
108
  this._styleLastUpdated = Date.now();
108
- this.globalHider = getGlobalHider();
109
109
  }
110
110
 
111
111
  /**
@@ -5,7 +5,6 @@ import convert from '../../util/featureconverter/convert.js';
5
5
  import VectorContext from './vectorContext.js';
6
6
  import { vcsLayerName } from '../layerSymbols.js';
7
7
  import LayerImplementation from '../layerImplementation.js';
8
- import { getGlobalHider } from '../globalHider.js';
9
8
  import { synchronizeFeatureVisibilityWithSource } from '../vectorHelpers.js';
10
9
 
11
10
  /**
@@ -71,7 +70,8 @@ class VectorCesiumImpl extends LayerImplementation {
71
70
  * @private
72
71
  */
73
72
  this._scene = null;
74
- this.globalHider = getGlobalHider();
73
+ /** @type {import("@vcmap/core").GlobalHider} */
74
+ this.globalHider = options.globalHider;
75
75
  }
76
76
 
77
77
  /**
@@ -115,9 +115,9 @@ class VectorCesiumImpl extends LayerImplementation {
115
115
  async initialize() {
116
116
  if (!this.initialized) {
117
117
  this._scene = this.map.getScene();
118
- await this._setupContext(this.map);
119
118
  this._addListeners();
120
119
  this._addFeatures(this.source.getFeatures());
120
+ await this._setupContext(this.map);
121
121
  }
122
122
  await super.initialize();
123
123
  }
@@ -4,7 +4,6 @@ import CesiumMap from '../map/cesiumMap.js';
4
4
  import DataSourceCesiumImpl from './cesium/dataSourceCesiumImpl.js';
5
5
  import { vcsLayerName } from './layerSymbols.js';
6
6
  import FeatureVisibility, { FeatureVisibilityAction } from './featureVisibility.js';
7
- import { getGlobalHider } from './globalHider.js';
8
7
  import { layerClassRegistry } from '../classRegistry.js';
9
8
 
10
9
  /**
@@ -85,12 +84,21 @@ class DataSourceLayer extends Layer {
85
84
  ];
86
85
  }
87
86
 
87
+ /**
88
+ * @param {import("@vcmap/core").GlobalHider} globalHider
89
+ */
90
+ setGlobalHider(globalHider) {
91
+ super.setGlobalHider(globalHider);
92
+ this._setUpFeatureVisibility();
93
+ }
94
+
88
95
  /**
89
96
  * Sets up listeners for featureVisibility and global hider
90
97
  * @private
91
98
  */
92
99
  _setUpFeatureVisibility() {
93
- const globalHider = getGlobalHider();
100
+ this._featureVisibilityListeners.forEach((cb) => { cb(); });
101
+
94
102
  this._featureVisibilityListeners = [
95
103
  this.featureVisibility.changed.addEventListener(({ action, ids }) => {
96
104
  if (action === FeatureVisibilityAction.HIDE) {
@@ -102,28 +110,30 @@ class DataSourceLayer extends Layer {
102
110
  });
103
111
  } // highlight is _possible_ but very tricky with all the possible entity values with potential materials
104
112
  }),
105
- globalHider.changed.addEventListener(({ action, ids }) => {
106
- if (action === FeatureVisibilityAction.HIDE) {
107
- ids.forEach((id) => {
108
- const entity = this.entities.getById(id);
109
- if (entity) {
110
- globalHider.addFeature(id, entity);
111
- }
112
- });
113
- }
114
- }),
115
113
  this.entities.collectionChanged.addEventListener((c, added) => {
116
114
  added.forEach((entity) => {
117
115
  if (this.featureVisibility.hiddenObjects[entity.id]) {
118
116
  this.featureVisibility.addHiddenFeature(entity.id, entity);
119
117
  }
120
-
121
- if (globalHider.hiddenObjects[entity.id]) {
122
- globalHider.addFeature(entity.id, entity);
118
+ if (this.globalHider && this.globalHider.hiddenObjects[entity.id]) {
119
+ this.globalHider.addFeature(entity.id, entity);
123
120
  }
124
121
  });
125
122
  }),
126
123
  ];
124
+
125
+ if (this.globalHider) {
126
+ this._featureVisibilityListeners.push(this.globalHider.changed.addEventListener(({ action, ids }) => {
127
+ if (action === FeatureVisibilityAction.HIDE) {
128
+ ids.forEach((id) => {
129
+ const entity = this.entities.getById(id);
130
+ if (entity) {
131
+ this.globalHider.addFeature(id, entity);
132
+ }
133
+ });
134
+ }
135
+ }));
136
+ }
127
137
  }
128
138
 
129
139
  /**
@@ -21,6 +21,7 @@ import { layerClassRegistry } from '../classRegistry.js';
21
21
 
22
22
  /**
23
23
  * @typedef {LayerImplementationOptions} FeatureLayerImplementationOptions
24
+ * @property {GlobalHider} globalHider
24
25
  * @property {FeatureVisibility} featureVisibility
25
26
  * @property {import("@vcmap/core").StyleItem} style
26
27
  * @api
@@ -140,11 +141,20 @@ class FeatureLayer extends Layer {
140
141
  getImplementationOptions() {
141
142
  return {
142
143
  ...super.getImplementationOptions(),
144
+ globalHider: this.globalHider,
143
145
  featureVisibility: this.featureVisibility,
144
146
  style: this.style,
145
147
  };
146
148
  }
147
149
 
150
+ /**
151
+ * @param {import("@vcmap/core").GlobalHider} globalHider
152
+ */
153
+ setGlobalHider(globalHider) {
154
+ super.setGlobalHider(globalHider);
155
+ this.forceRedraw();
156
+ }
157
+
148
158
  /**
149
159
  * @param {Object|import("ol").Feature<import("ol/geom/Geometry").default>|import("@vcmap/cesium").Cesium3DTilePointFeature|import("@vcmap/cesium").Cesium3DTileFeature|DataSourcePickedObject} object
150
160
  * @returns {?Object}
@@ -309,6 +309,7 @@ class FeatureStoreLayer extends VectorLayer {
309
309
  name: this.name,
310
310
  style: this.style,
311
311
  featureVisibility: this._staticFeatureVisibility,
312
+ globalHider: this.globalHider,
312
313
  splitDirection: SplitDirection.NONE,
313
314
  jumpToLocation: false,
314
315
  })));
@@ -231,6 +231,9 @@ export function synchronizeFeatureVisibility(source, destination) {
231
231
  }
232
232
 
233
233
  /**
234
+ * FeatureVisibility handles the visibility and highlighting of features of a specific {@link FeatureLayer} or {@link DataSourceLayer}
235
+ * and its {@link FeatureLayerImplementation} resp. {@link DataSourceCesiumImpl}.
236
+ * The visibility is being synchronized with the {@link GlobalHider}.
234
237
  * @class
235
238
  */
236
239
  class FeatureVisibility {
@@ -9,11 +9,16 @@ import {
9
9
  import VcsEvent from '../vcsEvent.js';
10
10
 
11
11
  /**
12
- * @type {GlobalHider}
12
+ * @typedef {Object} HiddenObject
13
+ * @property {string} id
13
14
  */
14
- let instance;
15
15
 
16
16
  /**
17
+ * GlobalHider globally hides features existing within a layer of a {@link LayerCollection}.
18
+ * Features can be defined as hidden by {@link VcsAppConfig} or {@link LayerOptions}.
19
+ * Hiding will be performed, when a {@link Context} is loaded, a {@link Layer} is activated or GlobalHider API is called.
20
+ * A feature can be hidden multiple times by different actors, e.g. contexts, layers, which is handled by this class.
21
+ * A feature will be shown again, when a {@link Context} is removed, a {@link Layer} is deactivated or GlobalHider API is called.
17
22
  * @class
18
23
  */
19
24
  class GlobalHider {
@@ -123,24 +128,6 @@ class GlobalHider {
123
128
  this._hiddenObjectFeatures = {};
124
129
  this.changed.destroy();
125
130
  }
126
-
127
- static destroy() {
128
- if (instance) {
129
- instance.destroy();
130
- }
131
- instance = undefined;
132
- }
133
- }
134
-
135
- /**
136
- * @returns {GlobalHider}
137
- * @api
138
- */
139
- export function getGlobalHider() {
140
- if (!instance) {
141
- instance = new GlobalHider();
142
- }
143
- return instance;
144
131
  }
145
132
 
146
133
  export default GlobalHider;
@@ -1,13 +1,13 @@
1
- import { check } from '@vcsuite/check';
1
+ import { check, checkMaybe } from '@vcsuite/check';
2
2
  import { parseBoolean, parseInteger } from '@vcsuite/parsers';
3
3
  import VcsObject from '../vcsObject.js';
4
4
  import Extent from '../util/extent.js';
5
- import { getGlobalHider } from './globalHider.js';
6
5
  import { vcsLayerName } from './layerSymbols.js';
7
6
  import LayerState from './layerState.js';
8
7
  import VcsEvent from '../vcsEvent.js';
9
8
  import { getCurrentLocale, getLocaleChangedEvent } from '../util/locale.js';
10
9
  import { layerClassRegistry } from '../classRegistry.js';
10
+ import GlobalHider from './globalHider.js';
11
11
 
12
12
  /**
13
13
  * @typedef {Object} GenericFeature
@@ -213,12 +213,19 @@ class Layer extends VcsObject {
213
213
  /**
214
214
  * array of object Ids which should be hidden within the context of the layers layerCollection, if this layer is active
215
215
  * @type {Array.<string>}
216
+ * @private
216
217
  * @api
217
218
  */
218
- this.hiddenObjectIds = Array.isArray(options.hiddenObjectIds) ?
219
+ this._hiddenObjectIds = Array.isArray(options.hiddenObjectIds) ?
219
220
  options.hiddenObjectIds :
220
221
  defaultOptions.hiddenObjectIds;
221
222
 
223
+ /**
224
+ * @type {import("@vcmap/core").GlobalHider|null}
225
+ * @private
226
+ */
227
+ this._globalHider = null;
228
+
222
229
  /**
223
230
  * @type {Array<string|symbol>}
224
231
  * @private
@@ -234,9 +241,6 @@ class Layer extends VcsObject {
234
241
  */
235
242
  this.exclusiveGroupsChanged = new VcsEvent();
236
243
 
237
- /** @type {import("@vcmap/core").GlobalHider} */
238
- this.globalHider = getGlobalHider();
239
-
240
244
  /**
241
245
  * @type {CopyrightOptions|undefined}
242
246
  */
@@ -352,6 +356,42 @@ class Layer extends VcsObject {
352
356
  }
353
357
  }
354
358
 
359
+ /**
360
+ * @type {Array<string>}
361
+ */
362
+ get hiddenObjectIds() { return this._hiddenObjectIds; }
363
+
364
+ /**
365
+ * @param {Array<string>} hiddenObjectIds
366
+ */
367
+ set hiddenObjectIds(hiddenObjectIds) {
368
+ check(hiddenObjectIds, [String]);
369
+
370
+ if (this._globalHider && this.active) {
371
+ this._globalHider.hideObjects(hiddenObjectIds);
372
+ }
373
+ this._hiddenObjectIds = hiddenObjectIds;
374
+ }
375
+
376
+
377
+ /**
378
+ * @type {import("@vcmap/core").GlobalHider|null}
379
+ * @readonly
380
+ */
381
+ get globalHider() { return this._globalHider; }
382
+
383
+ /**
384
+ * @param {import("@vcmap/core").GlobalHider} globalHider
385
+ */
386
+ setGlobalHider(globalHider) {
387
+ checkMaybe(globalHider, GlobalHider);
388
+
389
+ if (globalHider && this.active) {
390
+ globalHider.hideObjects(this.hiddenObjectIds);
391
+ }
392
+ this._globalHider = globalHider;
393
+ }
394
+
355
395
  /**
356
396
  * Indicates, that this layer is part of an exclusiveGroup
357
397
  * @api
@@ -616,7 +656,9 @@ class Layer extends VcsObject {
616
656
  if (this._state !== LayerState.LOADING) {
617
657
  return;
618
658
  }
619
- this.globalHider.hideObjects(this.hiddenObjectIds);
659
+ if (this._globalHider) {
660
+ this._globalHider.hideObjects(this.hiddenObjectIds);
661
+ }
620
662
  this._state = LayerState.ACTIVE;
621
663
  try {
622
664
  this.stateChanged.raiseEvent(LayerState.ACTIVE);
@@ -666,7 +708,9 @@ class Layer extends VcsObject {
666
708
  impl.deactivate();
667
709
  }
668
710
  });
669
- this.globalHider.showObjects(this.hiddenObjectIds);
711
+ if (this._globalHider) {
712
+ this._globalHider.showObjects(this.hiddenObjectIds);
713
+ }
670
714
  this._state = LayerState.INACTIVE;
671
715
  try {
672
716
  this.stateChanged.raiseEvent(LayerState.INACTIVE);
@@ -5,7 +5,6 @@ import Feature from 'ol/Feature.js';
5
5
 
6
6
  import { mercatorProjection } from '../../util/projection.js';
7
7
  import { mercatorGeometryToImageGeometry, imageGeometryToMercatorGeometry, getPolygonizedGeometry, setNewGeometry } from './obliqueHelpers.js';
8
- import { getGlobalHider } from '../globalHider.js';
9
8
  import {
10
9
  actuallyIsCircle,
11
10
  alreadyTransformedToImage,
@@ -74,7 +73,7 @@ class VectorObliqueImpl extends LayerObliqueImpl {
74
73
  /**
75
74
  * @type {import("@vcmap/core").GlobalHider}
76
75
  */
77
- this.globalHider = getGlobalHider();
76
+ this.globalHider = options.globalHider;
78
77
  /**
79
78
  * @type {import("ol/source").Vector<import("ol/geom/Geometry").default>}
80
79
  */
@@ -1,7 +1,6 @@
1
1
  import OLVectorLayer from 'ol/layer/Vector.js';
2
2
  import LayerOpenlayersImpl from './layerOpenlayersImpl.js';
3
3
  import { synchronizeFeatureVisibilityWithSource } from '../vectorHelpers.js';
4
- import { getGlobalHider } from '../globalHider.js';
5
4
 
6
5
  /**
7
6
  * represents a specific vectorlayer for openlayers.
@@ -35,7 +34,8 @@ class VectorOpenlayersImpl extends LayerOpenlayersImpl {
35
34
  this._featureVisibilityListeners = [];
36
35
  /** @type {import("ol/layer/Vector").default<import("ol/source").Vector<import("ol/geom/Geometry").default>>|null} */
37
36
  this.olLayer = null;
38
- this.globalHider = getGlobalHider();
37
+ /** @type {import("@vcmap/core").GlobalHider} */
38
+ this.globalHider = options.globalHider;
39
39
  }
40
40
 
41
41
  /**
@@ -155,7 +155,7 @@ class VectorTileLayer extends FeatureLayer {
155
155
  * @type {Array<Function>}
156
156
  * @private
157
157
  */
158
- this._featureVisibilityListener = [];
158
+ this._featureVisibilityListeners = [];
159
159
 
160
160
  /**
161
161
  * @type {Function}
@@ -254,15 +254,24 @@ class VectorTileLayer extends FeatureLayer {
254
254
  }
255
255
 
256
256
  /**
257
- *
258
- * @returns {Array<Function>}
257
+ * @param {import("@vcmap/core").GlobalHider} globalHider
258
+ */
259
+ setGlobalHider(globalHider) {
260
+ super.setGlobalHider(globalHider);
261
+ this._setupFeatureVisibilityHandlers();
262
+ }
263
+
264
+ /**
265
+ * Sets up listeners for featureVisibility and global hider
259
266
  * @private
260
267
  */
261
268
  _setupFeatureVisibilityHandlers() {
262
269
  if (!this.tileProvider.trackFeaturesToTiles) {
263
- return [];
270
+ return;
264
271
  }
265
- return [
272
+ this._featureVisibilityListeners.forEach((cb) => { cb(); });
273
+
274
+ this._featureVisibilityListeners = [
266
275
  this.featureVisibility.changed.addEventListener(({ action, ids }) => {
267
276
  const tileIdsChanged = new Set();
268
277
  ids.forEach((id) => {
@@ -289,8 +298,10 @@ class VectorTileLayer extends FeatureLayer {
289
298
  });
290
299
  this.updateTiles([...tileIdsChanged]);
291
300
  }),
301
+ ];
292
302
 
293
- this.globalHider.changed.addEventListener(({ action, ids }) => {
303
+ if (this.globalHider) {
304
+ this._featureVisibilityListeners.push(this.globalHider.changed.addEventListener(({ action, ids }) => {
294
305
  const tileIdsChanged = new Set();
295
306
  ids.forEach((id) => {
296
307
  const tileIds = this.tileProvider.featureIdToTileIds.get(id);
@@ -311,8 +322,8 @@ class VectorTileLayer extends FeatureLayer {
311
322
  }
312
323
  });
313
324
  this.updateTiles([...tileIdsChanged]);
314
- }),
315
- ];
325
+ }));
326
+ }
316
327
  }
317
328
 
318
329
  /**
@@ -400,8 +411,8 @@ class VectorTileLayer extends FeatureLayer {
400
411
  */
401
412
  async activate() {
402
413
  await super.activate();
403
- this._featureVisibilityListener = this._setupFeatureVisibilityHandlers();
404
- if (this.tileProvider.trackFeaturesToTiles) {
414
+ this._setupFeatureVisibilityHandlers();
415
+ if (this.tileProvider.trackFeaturesToTiles && this.globalHider) {
405
416
  this.tileProvider.forEachFeature((feature) => {
406
417
  synchronizeFeatureVisibility(this.featureVisibility, this.globalHider, feature);
407
418
  });
@@ -414,7 +425,7 @@ class VectorTileLayer extends FeatureLayer {
414
425
  */
415
426
  deactivate() {
416
427
  super.deactivate();
417
- this._featureVisibilityListener.forEach((cb) => { cb(); });
428
+ this._featureVisibilityListeners.forEach((cb) => { cb(); });
418
429
  }
419
430
 
420
431
  /**
@@ -422,7 +433,7 @@ class VectorTileLayer extends FeatureLayer {
422
433
  * @api
423
434
  */
424
435
  destroy() {
425
- this._featureVisibilityListener.forEach((cb) => { cb(); });
436
+ this._featureVisibilityListeners.forEach((cb) => { cb(); });
426
437
  super.destroy();
427
438
  this._tileLoadEventListener();
428
439
  if (this.featureProvider) {
@@ -1,7 +1,9 @@
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
@@ -61,6 +63,13 @@ class LayerCollection extends IndexedCollection {
61
63
  * @api
62
64
  */
63
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();
64
73
  }
65
74
 
66
75
  /**
@@ -72,6 +81,27 @@ class LayerCollection extends IndexedCollection {
72
81
  */
73
82
  get zIndexSymbol() { return this._zIndexSymbol; }
74
83
 
84
+ /**
85
+ * The current global hider
86
+ * @type {GlobalHider}
87
+ */
88
+ get globalHider() {
89
+ return this._globalHider;
90
+ }
91
+
92
+ /**
93
+ * Set global hider for these maps.
94
+ * @param {GlobalHider} globalHider
95
+ */
96
+ set globalHider(globalHider) {
97
+ check(globalHider, GlobalHider);
98
+
99
+ this._globalHider = globalHider;
100
+ this._array.forEach((layer) => {
101
+ layer.setGlobalHider(this._globalHider);
102
+ });
103
+ }
104
+
75
105
  /**
76
106
  * @param {import("@vcmap/core").Layer} layer
77
107
  * @private
@@ -171,6 +201,7 @@ class LayerCollection extends IndexedCollection {
171
201
  const insertedAt = super.add(layer, usedIndex);
172
202
  if (insertedAt != null) {
173
203
  layer[this._zIndexSymbol] = layer.zIndex;
204
+ layer.setGlobalHider(this._globalHider);
174
205
  this._ensureLocalZIndex(layer);
175
206
  this._listenToLayerEvents(layer);
176
207
  this.exclusiveManager.registerLayer(layer);
@@ -189,6 +220,7 @@ class LayerCollection extends IndexedCollection {
189
220
  delete this._layerEventListeners[layer.name];
190
221
  }
191
222
  delete layer[this._zIndexSymbol];
223
+ layer.setGlobalHider(null);
192
224
  this.exclusiveManager.unregisterLayer(layer);
193
225
  return super._remove(layer);
194
226
  }
@@ -213,6 +245,7 @@ class LayerCollection extends IndexedCollection {
213
245
 
214
246
  this._layerEventListeners = {};
215
247
  this.exclusiveManager.destroy();
248
+ this._globalHider.destroy();
216
249
  super.destroy();
217
250
  }
218
251
  }