@vcmap/core 6.0.7 → 6.1.0-rc.2
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/dist/cesium.d.ts +3 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/ol.d.ts +8 -1
- package/dist/src/featureProvider/featureProviderSymbols.d.ts +5 -0
- package/dist/src/featureProvider/featureProviderSymbols.js +5 -1
- package/dist/src/featureProvider/featureProviderSymbols.js.map +1 -1
- package/dist/src/interaction/featureAtPixelInteraction.js +58 -62
- package/dist/src/interaction/featureAtPixelInteraction.js.map +1 -1
- package/dist/src/interaction/featureProviderInteraction.js +25 -13
- package/dist/src/interaction/featureProviderInteraction.js.map +1 -1
- package/dist/src/layer/cesium/sourceVectorContextSync.d.ts +27 -0
- package/dist/src/layer/cesium/sourceVectorContextSync.js +94 -0
- package/dist/src/layer/cesium/sourceVectorContextSync.js.map +1 -0
- package/dist/src/layer/cesium/vectorCesiumImpl.d.ts +4 -27
- package/dist/src/layer/cesium/vectorCesiumImpl.js +15 -107
- package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorContext.d.ts +12 -1
- package/dist/src/layer/cesium/vectorContext.js +6 -0
- package/dist/src/layer/cesium/vectorContext.js.map +1 -1
- package/dist/src/layer/layerSymbols.js +1 -1
- package/dist/src/layer/layerSymbols.js.map +1 -1
- package/dist/src/layer/oblique/sourceObliqueSync.d.ts +18 -0
- package/dist/src/layer/oblique/sourceObliqueSync.js +319 -0
- package/dist/src/layer/oblique/sourceObliqueSync.js.map +1 -0
- package/dist/src/layer/oblique/vectorObliqueImpl.d.ts +2 -40
- package/dist/src/layer/oblique/vectorObliqueImpl.js +8 -283
- package/dist/src/layer/oblique/vectorObliqueImpl.js.map +1 -1
- package/dist/src/layer/vectorLayer.d.ts +10 -1
- package/dist/src/layer/vectorLayer.js +23 -1
- package/dist/src/layer/vectorLayer.js.map +1 -1
- package/dist/src/map/baseOLMap.js +8 -1
- package/dist/src/map/baseOLMap.js.map +1 -1
- package/dist/src/map/cesiumMap.d.ts +2 -0
- package/dist/src/map/cesiumMap.js +26 -1
- package/dist/src/map/cesiumMap.js.map +1 -1
- package/dist/src/map/vcsMap.d.ts +24 -12
- package/dist/src/map/vcsMap.js +92 -38
- package/dist/src/map/vcsMap.js.map +1 -1
- package/dist/src/ol/source/ClusterEnhancedVectorSource.d.ts +6 -4
- package/dist/src/ol/source/ClusterEnhancedVectorSource.js +4 -9
- package/dist/src/ol/source/ClusterEnhancedVectorSource.js.map +1 -1
- package/dist/src/ol/source/VcsCluster.d.ts +10 -10
- package/dist/src/ol/source/VcsCluster.js +23 -7
- package/dist/src/ol/source/VcsCluster.js.map +1 -1
- package/dist/src/util/clipping/clippingPolygonHelper.d.ts +7 -0
- package/dist/src/util/clipping/clippingPolygonHelper.js +53 -0
- package/dist/src/util/clipping/clippingPolygonHelper.js.map +1 -0
- package/dist/src/util/clipping/clippingPolygonObject.d.ts +59 -0
- package/dist/src/util/clipping/clippingPolygonObject.js +158 -0
- package/dist/src/util/clipping/clippingPolygonObject.js.map +1 -0
- package/dist/src/util/clipping/clippingPolygonObjectCollection.d.ts +18 -0
- package/dist/src/util/clipping/clippingPolygonObjectCollection.js +167 -0
- package/dist/src/util/clipping/clippingPolygonObjectCollection.js.map +1 -0
- package/dist/src/util/layerCollection.d.ts +11 -1
- package/dist/src/util/layerCollection.js +67 -12
- package/dist/src/util/layerCollection.js.map +1 -1
- package/dist/src/util/mapCollection.d.ts +16 -1
- package/dist/src/util/mapCollection.js +37 -3
- package/dist/src/util/mapCollection.js.map +1 -1
- package/dist/src/util/renderScreenshot.d.ts +9 -0
- package/dist/src/util/renderScreenshot.js +162 -0
- package/dist/src/util/renderScreenshot.js.map +1 -0
- package/dist/src/util/rotation.d.ts +30 -0
- package/dist/src/util/rotation.js +145 -0
- package/dist/src/util/rotation.js.map +1 -0
- package/dist/src/util/vcsTemplate.d.ts +7 -0
- package/dist/src/util/vcsTemplate.js +248 -0
- package/dist/src/util/vcsTemplate.js.map +1 -0
- package/dist/src/vcsApp.d.ts +7 -0
- package/dist/src/vcsApp.js +29 -0
- package/dist/src/vcsApp.js.map +1 -1
- package/dist/src/vcsModule.d.ts +6 -2
- package/dist/src/vcsModule.js.map +1 -1
- package/dist/src/vectorCluster/vectorClusterCesiumContext.d.ts +18 -0
- package/dist/src/{layer/cesium/clusterContext.js → vectorCluster/vectorClusterCesiumContext.js} +28 -42
- package/dist/src/vectorCluster/vectorClusterCesiumContext.js.map +1 -0
- package/dist/src/vectorCluster/vectorClusterGroup.d.ts +96 -0
- package/dist/src/vectorCluster/vectorClusterGroup.js +320 -0
- package/dist/src/vectorCluster/vectorClusterGroup.js.map +1 -0
- package/dist/src/vectorCluster/vectorClusterGroupCesiumImpl.d.ts +20 -0
- package/dist/src/vectorCluster/vectorClusterGroupCesiumImpl.js +115 -0
- package/dist/src/vectorCluster/vectorClusterGroupCesiumImpl.js.map +1 -0
- package/dist/src/vectorCluster/vectorClusterGroupCollection.d.ts +19 -0
- package/dist/src/vectorCluster/vectorClusterGroupCollection.js +37 -0
- package/dist/src/vectorCluster/vectorClusterGroupCollection.js.map +1 -0
- package/dist/src/vectorCluster/vectorClusterGroupImpl.d.ts +31 -0
- package/dist/src/vectorCluster/vectorClusterGroupImpl.js +76 -0
- package/dist/src/vectorCluster/vectorClusterGroupImpl.js.map +1 -0
- package/dist/src/vectorCluster/vectorClusterGroupObliqueImpl.d.ts +17 -0
- package/dist/src/vectorCluster/vectorClusterGroupObliqueImpl.js +62 -0
- package/dist/src/vectorCluster/vectorClusterGroupObliqueImpl.js.map +1 -0
- package/dist/src/vectorCluster/vectorClusterGroupOpenlayersImpl.d.ts +17 -0
- package/dist/src/vectorCluster/vectorClusterGroupOpenlayersImpl.js +62 -0
- package/dist/src/vectorCluster/vectorClusterGroupOpenlayersImpl.js.map +1 -0
- package/dist/src/vectorCluster/vectorClusterStyleItem.d.ts +110 -0
- package/dist/src/vectorCluster/vectorClusterStyleItem.js +374 -0
- package/dist/src/vectorCluster/vectorClusterStyleItem.js.map +1 -0
- package/dist/src/vectorCluster/vectorClusterSymbols.d.ts +1 -0
- package/dist/src/vectorCluster/vectorClusterSymbols.js +3 -0
- package/dist/src/vectorCluster/vectorClusterSymbols.js.map +1 -0
- package/index.ts +42 -1
- package/package.json +3 -1
- package/src/cesium/cesium.d.ts +3 -0
- package/src/featureProvider/featureProviderSymbols.ts +6 -1
- package/src/interaction/featureAtPixelInteraction.ts +109 -84
- package/src/interaction/featureProviderInteraction.ts +42 -28
- package/src/layer/cesium/sourceVectorContextSync.ts +134 -0
- package/src/layer/cesium/vcsTile/vcsDebugTile.ts +1 -1
- package/src/layer/cesium/vcsTile/vcsVectorTile.ts +1 -1
- package/src/layer/cesium/vectorCesiumImpl.ts +30 -144
- package/src/layer/cesium/vectorContext.ts +17 -1
- package/src/layer/layerSymbols.ts +1 -1
- package/src/layer/oblique/sourceObliqueSync.ts +436 -0
- package/src/layer/oblique/vectorObliqueImpl.ts +11 -397
- package/src/layer/vectorLayer.ts +35 -2
- package/src/map/baseOLMap.ts +8 -1
- package/src/map/cesiumMap.ts +36 -3
- package/src/map/vcsMap.ts +121 -47
- package/src/ol/ol.d.ts +8 -1
- package/src/ol/source/{ClusterEnhancedVectorSource.js → ClusterEnhancedVectorSource.ts} +7 -10
- package/src/ol/source/VcsCluster.ts +58 -0
- package/src/util/clipping/clippingPolygonHelper.ts +86 -0
- package/src/util/clipping/clippingPolygonObject.ts +223 -0
- package/src/util/clipping/clippingPolygonObjectCollection.ts +249 -0
- package/src/util/layerCollection.ts +90 -12
- package/src/util/mapCollection.ts +53 -2
- package/src/util/renderScreenshot.ts +193 -0
- package/src/util/rotation.ts +215 -0
- package/src/util/vcsTemplate.ts +373 -0
- package/src/vcsApp.ts +65 -0
- package/src/vcsModule.ts +6 -2
- package/src/vectorCluster/vectorClusterCesiumContext.ts +123 -0
- package/src/vectorCluster/vectorClusterGroup.ts +463 -0
- package/src/vectorCluster/vectorClusterGroupCesiumImpl.ts +176 -0
- package/src/vectorCluster/vectorClusterGroupCollection.ts +43 -0
- package/src/vectorCluster/vectorClusterGroupImpl.ts +107 -0
- package/src/vectorCluster/vectorClusterGroupObliqueImpl.ts +84 -0
- package/src/vectorCluster/vectorClusterGroupOpenlayersImpl.ts +81 -0
- package/src/vectorCluster/vectorClusterStyleItem.ts +490 -0
- package/src/vectorCluster/vectorClusterSymbols.ts +2 -0
- package/dist/src/layer/cesium/clusterContext.d.ts +0 -20
- package/dist/src/layer/cesium/clusterContext.js.map +0 -1
- package/src/layer/cesium/clusterContext.ts +0 -140
- package/src/ol/source/VcsCluster.js +0 -37
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { unByKey } from 'ol/Observable.js';
|
|
2
|
+
import { parseInteger } from '@vcsuite/parsers';
|
|
3
|
+
import { check, maybe } from '@vcsuite/check';
|
|
4
|
+
import VcsObject from '../vcsObject.js';
|
|
5
|
+
import VectorLayer from '../layer/vectorLayer.js';
|
|
6
|
+
import ClusterEnhancedVectorSource from '../ol/source/ClusterEnhancedVectorSource.js';
|
|
7
|
+
import FeatureVisibility, { synchronizeFeatureVisibility, } from '../layer/featureVisibility.js';
|
|
8
|
+
import LayerState from '../layer/layerState.js';
|
|
9
|
+
import VectorClusterStyleItem, { getDefaultClusterStyleItem, } from './vectorClusterStyleItem.js';
|
|
10
|
+
import GlobalHider from '../layer/globalHider.js';
|
|
11
|
+
import VectorProperties from '../layer/vectorProperties.js';
|
|
12
|
+
import CesiumMap from '../map/cesiumMap.js';
|
|
13
|
+
import VectorClusterGroupCesiumImpl from './vectorClusterGroupCesiumImpl.js';
|
|
14
|
+
import VectorClusterGroupOpenlayersImpl from './vectorClusterGroupOpenlayersImpl.js';
|
|
15
|
+
import OpenlayersMap from '../map/openlayersMap.js';
|
|
16
|
+
import ObliqueMap from '../map/obliqueMap.js';
|
|
17
|
+
import VectorClusterGroupObliqueImpl from './vectorClusterGroupObliqueImpl.js';
|
|
18
|
+
function featureIsClusterable(feature, vectorProperties) {
|
|
19
|
+
if (feature) {
|
|
20
|
+
const geometry = feature?.getGeometry();
|
|
21
|
+
return (!!geometry &&
|
|
22
|
+
geometry.getType() === 'Point' &&
|
|
23
|
+
vectorProperties.renderAs(feature) === 'geometry');
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
function getStyleOrDefaultStyle(styleOptions, defaultValue) {
|
|
28
|
+
if (styleOptions) {
|
|
29
|
+
if (styleOptions instanceof VectorClusterStyleItem) {
|
|
30
|
+
return styleOptions;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return new VectorClusterStyleItem(styleOptions);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return defaultValue;
|
|
37
|
+
}
|
|
38
|
+
export default class VectorClusterGroup extends VcsObject {
|
|
39
|
+
static get className() {
|
|
40
|
+
return 'VectorClusterGroup';
|
|
41
|
+
}
|
|
42
|
+
static getDefaultOptions() {
|
|
43
|
+
return {
|
|
44
|
+
type: 'VectorClusterGroup',
|
|
45
|
+
name: '',
|
|
46
|
+
style: undefined,
|
|
47
|
+
highlightStyle: undefined,
|
|
48
|
+
clusterDistance: 40,
|
|
49
|
+
vectorProperties: {
|
|
50
|
+
...VectorProperties.getDefaultOptions(),
|
|
51
|
+
eyeOffset: [0, 0, -100],
|
|
52
|
+
heightAboveGround: 60,
|
|
53
|
+
altitudeMode: 'clampToTerrain',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
_layerListeners = new Map();
|
|
58
|
+
_activeSourceListeners = new Map();
|
|
59
|
+
_source = new ClusterEnhancedVectorSource({});
|
|
60
|
+
_featureVisibility = new FeatureVisibility();
|
|
61
|
+
_style;
|
|
62
|
+
highlightStyle;
|
|
63
|
+
_styleFunction;
|
|
64
|
+
_activeMaps = new Set();
|
|
65
|
+
_implementations = new Map();
|
|
66
|
+
_globalHider;
|
|
67
|
+
vectorProperties;
|
|
68
|
+
clusterDistance;
|
|
69
|
+
constructor(options) {
|
|
70
|
+
super(options);
|
|
71
|
+
const defaultOptions = VectorClusterGroup.getDefaultOptions();
|
|
72
|
+
this._style = getStyleOrDefaultStyle(options.style, getDefaultClusterStyleItem());
|
|
73
|
+
if (options.highlightStyle) {
|
|
74
|
+
this.highlightStyle =
|
|
75
|
+
options.highlightStyle instanceof VectorClusterStyleItem
|
|
76
|
+
? options.highlightStyle
|
|
77
|
+
: new VectorClusterStyleItem(options.highlightStyle);
|
|
78
|
+
}
|
|
79
|
+
this.clusterDistance = parseInteger(options.clusterDistance, defaultOptions.clusterDistance);
|
|
80
|
+
this.vectorProperties = new VectorProperties(options.vectorProperties ?? defaultOptions.vectorProperties);
|
|
81
|
+
this._styleFunction = this._style.createStyleFunction((layerName) => [...this._layerListeners.keys()].find((l) => l.name === layerName));
|
|
82
|
+
}
|
|
83
|
+
get featureVisibility() {
|
|
84
|
+
return this._featureVisibility;
|
|
85
|
+
}
|
|
86
|
+
get style() {
|
|
87
|
+
return this._style;
|
|
88
|
+
}
|
|
89
|
+
get globalHider() {
|
|
90
|
+
return this._globalHider;
|
|
91
|
+
}
|
|
92
|
+
setStyle(style) {
|
|
93
|
+
this._style = getStyleOrDefaultStyle(style, this._style);
|
|
94
|
+
this._styleFunction = this._style.createStyleFunction((layerName) => [...this._layerListeners.keys()].find((l) => l.name === layerName));
|
|
95
|
+
this._implementations.forEach((impl) => {
|
|
96
|
+
if (impl) {
|
|
97
|
+
impl.style = this._styleFunction;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
this._source
|
|
101
|
+
.getFeatures()
|
|
102
|
+
.filter((f) => !f.getStyle())
|
|
103
|
+
.forEach((f) => f.changed());
|
|
104
|
+
}
|
|
105
|
+
getHighlightStyleForFeature(feature) {
|
|
106
|
+
if (this.highlightStyle) {
|
|
107
|
+
return this.highlightStyle.createStyleFunction((layerName) => [...this._layerListeners.keys()].find((l) => l.name === layerName))(feature, 1);
|
|
108
|
+
}
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
addLayer(layer) {
|
|
112
|
+
check(layer, VectorLayer);
|
|
113
|
+
this._layerListeners.set(layer, [
|
|
114
|
+
layer.stateChanged.addEventListener((state) => {
|
|
115
|
+
if (state === LayerState.ACTIVE) {
|
|
116
|
+
this._handleActivation(layer);
|
|
117
|
+
}
|
|
118
|
+
else if (state === LayerState.INACTIVE) {
|
|
119
|
+
this._handleDeactivation(layer);
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
synchronizeFeatureVisibility(layer.featureVisibility, this._featureVisibility),
|
|
123
|
+
]);
|
|
124
|
+
if (layer.active) {
|
|
125
|
+
this._handleActivation(layer);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
removeLayer(layer) {
|
|
129
|
+
this._handleDeactivation(layer);
|
|
130
|
+
this._layerListeners.get(layer)?.forEach((cb) => cb());
|
|
131
|
+
this._layerListeners.delete(layer);
|
|
132
|
+
}
|
|
133
|
+
getFeatures() {
|
|
134
|
+
return this._source.getFeatures();
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* destroys all current implementations and recreates the ones which have an active map.
|
|
138
|
+
* called for instance when the URL for a layer changes
|
|
139
|
+
*/
|
|
140
|
+
async forceRedraw() {
|
|
141
|
+
const maps = [...this._implementations.keys()];
|
|
142
|
+
const promises = maps.map((map) => {
|
|
143
|
+
this.removedFromMap(map);
|
|
144
|
+
if (map.active) {
|
|
145
|
+
return this.mapActivated(map);
|
|
146
|
+
}
|
|
147
|
+
return Promise.resolve();
|
|
148
|
+
});
|
|
149
|
+
await Promise.all(promises);
|
|
150
|
+
}
|
|
151
|
+
setGlobalHider(globalHider) {
|
|
152
|
+
check(globalHider, maybe(GlobalHider));
|
|
153
|
+
this._globalHider = globalHider;
|
|
154
|
+
this.forceRedraw().catch((_e) => {
|
|
155
|
+
this.getLogger().error('Failed to redraw after setting global hider');
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
_handleActivation(layer) {
|
|
159
|
+
if (!this._activeSourceListeners.has(layer)) {
|
|
160
|
+
const source = layer.getSource();
|
|
161
|
+
if (source.getState() === 'ready') {
|
|
162
|
+
const features = source
|
|
163
|
+
.getFeatures()
|
|
164
|
+
.filter((f) => featureIsClusterable(f, layer.vectorProperties));
|
|
165
|
+
this._source.addFeatures(features);
|
|
166
|
+
const listeners = [
|
|
167
|
+
source.on('addfeature', ({ feature }) => {
|
|
168
|
+
if (featureIsClusterable(feature, layer.vectorProperties)) {
|
|
169
|
+
this._source.addFeature(feature);
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
172
|
+
source.on('removefeature', ({ feature }) => {
|
|
173
|
+
this._source.removeFeature(feature);
|
|
174
|
+
}),
|
|
175
|
+
];
|
|
176
|
+
this._activeSourceListeners.set(layer, () => unByKey(listeners));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
source.once('change', this._handleActivation.bind(this, layer));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
_handleDeactivation(layer) {
|
|
184
|
+
if (this._activeSourceListeners.has(layer)) {
|
|
185
|
+
const source = layer.getSource();
|
|
186
|
+
source
|
|
187
|
+
.getFeatures()
|
|
188
|
+
.filter((f) => featureIsClusterable(f, layer.vectorProperties))
|
|
189
|
+
.forEach((feat) => {
|
|
190
|
+
this._source.removeFeature(feat, true);
|
|
191
|
+
});
|
|
192
|
+
this._source.changed();
|
|
193
|
+
this._activeSourceListeners.get(layer)();
|
|
194
|
+
this._activeSourceListeners.delete(layer);
|
|
195
|
+
// previous result item & last feature clicked handling
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// eslint-disable-next-line class-methods-use-this
|
|
199
|
+
isSupported(map) {
|
|
200
|
+
return (map.className === 'OpenlayersMap' ||
|
|
201
|
+
map.className === 'CesiumMap' ||
|
|
202
|
+
map.className === 'ObliqueMap');
|
|
203
|
+
}
|
|
204
|
+
getImplementationOptions() {
|
|
205
|
+
return {
|
|
206
|
+
clusterDistance: this.clusterDistance,
|
|
207
|
+
featureVisibility: this._featureVisibility,
|
|
208
|
+
globalHider: this._globalHider,
|
|
209
|
+
maxResolution: 0,
|
|
210
|
+
minResolution: 0,
|
|
211
|
+
name: this.name,
|
|
212
|
+
source: this._source,
|
|
213
|
+
style: this._styleFunction,
|
|
214
|
+
vectorProperties: this.vectorProperties,
|
|
215
|
+
getLayerByName: (layerName) => [...this._layerListeners.keys()].find((l) => l.name === layerName),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
_createImplementationForMap(map) {
|
|
219
|
+
if (map instanceof CesiumMap) {
|
|
220
|
+
return new VectorClusterGroupCesiumImpl(map, this.getImplementationOptions());
|
|
221
|
+
}
|
|
222
|
+
else if (map instanceof OpenlayersMap) {
|
|
223
|
+
return new VectorClusterGroupOpenlayersImpl(map, this.getImplementationOptions());
|
|
224
|
+
}
|
|
225
|
+
else if (map instanceof ObliqueMap) {
|
|
226
|
+
return new VectorClusterGroupObliqueImpl(map, this.getImplementationOptions());
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* creates or returns a cached array of cluster group implementations for the given map.
|
|
232
|
+
* @param map initialized Map
|
|
233
|
+
* @returns return the specific implementation
|
|
234
|
+
*/
|
|
235
|
+
getImplementationForMap(map) {
|
|
236
|
+
if (!this._implementations.has(map)) {
|
|
237
|
+
this._implementations.set(map, this._createImplementationForMap(map));
|
|
238
|
+
}
|
|
239
|
+
return this._implementations.get(map);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Returns all implementation of this vector cluster group for all maps
|
|
243
|
+
*/
|
|
244
|
+
getImplementations() {
|
|
245
|
+
return [...this._implementations.values()].flat().filter((i) => !!i);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* is called from the map when the map is activated and this vector cluster group belongs to the maps layer collections vector cluster group collection.
|
|
249
|
+
* Will create an implementation if it does not exists and will forward the activation call to the implementation.
|
|
250
|
+
* @param map
|
|
251
|
+
*/
|
|
252
|
+
async mapActivated(map) {
|
|
253
|
+
this._activeMaps.add(map);
|
|
254
|
+
await this._activateImplsForMap(map);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* is called from the map when the map is deactivated, and this vector cluster group belongs to the maps layer collections vector cluster group collection.
|
|
258
|
+
* will forward deactivation call to the map specific implementation
|
|
259
|
+
* @param map
|
|
260
|
+
*/
|
|
261
|
+
mapDeactivated(map) {
|
|
262
|
+
this._activeMaps.delete(map);
|
|
263
|
+
const impl = this.getImplementationForMap(map);
|
|
264
|
+
impl?.deactivate();
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* is called when a vector cluster group is removed from a maps layer collections vector cluster group collection or said map is destroyed.
|
|
268
|
+
* destroys the associated implementation.
|
|
269
|
+
* @param map
|
|
270
|
+
*/
|
|
271
|
+
removedFromMap(map) {
|
|
272
|
+
this._activeMaps.delete(map);
|
|
273
|
+
const impl = this.getImplementationForMap(map);
|
|
274
|
+
impl?.destroy();
|
|
275
|
+
this._implementations.delete(map);
|
|
276
|
+
}
|
|
277
|
+
async _activateImplsForMap(map) {
|
|
278
|
+
const impl = this.getImplementationForMap(map);
|
|
279
|
+
if (impl) {
|
|
280
|
+
try {
|
|
281
|
+
await impl.activate();
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
this.getLogger().error(`Layer ${this.name} could not activate impl for map ${map.name}`);
|
|
285
|
+
this.getLogger().error(String(err));
|
|
286
|
+
this._implementations.set(map, undefined);
|
|
287
|
+
impl.destroy();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
toJSON() {
|
|
292
|
+
const config = super.toJSON();
|
|
293
|
+
const defaultOptions = VectorClusterGroup.getDefaultOptions();
|
|
294
|
+
if (!this.style.equals(new VectorClusterStyleItem({}))) {
|
|
295
|
+
config.style = this.style.toJSON();
|
|
296
|
+
delete config.style.name;
|
|
297
|
+
delete config.style.type;
|
|
298
|
+
}
|
|
299
|
+
if (this.highlightStyle) {
|
|
300
|
+
config.highlightStyle = this.highlightStyle.toJSON();
|
|
301
|
+
delete config.highlightStyle.name;
|
|
302
|
+
delete config.highlightStyle.type;
|
|
303
|
+
}
|
|
304
|
+
if (this.clusterDistance !== defaultOptions.clusterDistance) {
|
|
305
|
+
config.clusterDistance = this.clusterDistance;
|
|
306
|
+
}
|
|
307
|
+
const vectorProperties = this.vectorProperties.getVcsMeta(defaultOptions.vectorProperties);
|
|
308
|
+
if (Object.keys(vectorProperties).length > 0) {
|
|
309
|
+
config.vectorProperties = vectorProperties;
|
|
310
|
+
}
|
|
311
|
+
return config;
|
|
312
|
+
}
|
|
313
|
+
destroy() {
|
|
314
|
+
this._featureVisibility.destroy();
|
|
315
|
+
[...this._layerListeners.values()].forEach((arr) => arr.forEach((cb) => cb()));
|
|
316
|
+
this._layerListeners.clear();
|
|
317
|
+
super.destroy();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=vectorClusterGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectorClusterGroup.js","sourceRoot":"","sources":["../../../src/vectorCluster/vectorClusterGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,SAA+B,MAAM,iBAAiB,CAAC;AAC9D,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,2BAA2B,MAAM,6CAA6C,CAAC;AACtF,OAAO,iBAAiB,EAAE,EACxB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,UAA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ementationOptions } from './vectorClusterGroup.js';
|
|
3
|
+
import VectorClusterGroupImpl from './vectorClusterGroupImpl.js';
|
|
4
|
+
/**
|
|
5
|
+
* Clusters for vector layers containing point features only
|
|
6
|
+
*/
|
|
7
|
+
export default class VectorClusterGroupCesiumImpl extends VectorClusterGroupImpl<CesiumMap> {
|
|
8
|
+
static get className(): string;
|
|
9
|
+
private _rootCollection;
|
|
10
|
+
private _removeClusterEventListener;
|
|
11
|
+
private _context;
|
|
12
|
+
private _sourceVectorContextSync;
|
|
13
|
+
private _getLayerByName;
|
|
14
|
+
constructor(map: CesiumMap, options: VectorClusterGroupImplementationOptions);
|
|
15
|
+
private _onCluster;
|
|
16
|
+
initialize(): Promise<void>;
|
|
17
|
+
activate(): Promise<void>;
|
|
18
|
+
deactivate(): void;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Cartographic, CustomDataSource, Math as CesiumMath, } from '@vcmap-cesium/engine';
|
|
2
|
+
import Feature from 'ol/Feature.js';
|
|
3
|
+
import Point from 'ol/geom/Point.js';
|
|
4
|
+
import { getStylesArray } from '../util/featureconverter/convert.js';
|
|
5
|
+
import { getBillboardOptions } from '../util/featureconverter/pointToCesium.js';
|
|
6
|
+
import Projection from '../util/projection.js';
|
|
7
|
+
import VectorClusterCesiumContext from './vectorClusterCesiumContext.js';
|
|
8
|
+
import { createSourceVectorContextSync, } from '../layer/cesium/sourceVectorContextSync.js';
|
|
9
|
+
import VectorClusterGroupImpl from './vectorClusterGroupImpl.js';
|
|
10
|
+
import { vectorClusterGroupName } from './vectorClusterSymbols.js';
|
|
11
|
+
import { vcsLayerName } from '../layer/layerSymbols.js';
|
|
12
|
+
let scratchCartographic = new Cartographic();
|
|
13
|
+
/**
|
|
14
|
+
* Clusters for vector layers containing point features only
|
|
15
|
+
*/
|
|
16
|
+
export default class VectorClusterGroupCesiumImpl extends VectorClusterGroupImpl {
|
|
17
|
+
static get className() {
|
|
18
|
+
return 'VectorClusterGroupCesiumImpl';
|
|
19
|
+
}
|
|
20
|
+
_rootCollection;
|
|
21
|
+
_removeClusterEventListener;
|
|
22
|
+
_context;
|
|
23
|
+
_sourceVectorContextSync;
|
|
24
|
+
_getLayerByName;
|
|
25
|
+
constructor(map, options) {
|
|
26
|
+
super(map, options);
|
|
27
|
+
this._rootCollection = new CustomDataSource(this.name);
|
|
28
|
+
this._rootCollection.clustering.clusterLabels = true;
|
|
29
|
+
this._rootCollection.clustering.clusterPoints = false;
|
|
30
|
+
this._rootCollection.clustering.enabled = true;
|
|
31
|
+
this._rootCollection.clustering.minimumClusterSize = 2;
|
|
32
|
+
this._rootCollection.clustering.pixelRange = options.clusterDistance;
|
|
33
|
+
this._getLayerByName = options.getLayerByName;
|
|
34
|
+
}
|
|
35
|
+
_onCluster(entities, cluster) {
|
|
36
|
+
const size = entities.length;
|
|
37
|
+
if (size < 2) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const features = entities.map((e) => e.olFeature);
|
|
41
|
+
const feature = new Feature({ features });
|
|
42
|
+
feature[vectorClusterGroupName] = this.name;
|
|
43
|
+
const style = getStylesArray(this.style, feature, 0)[0];
|
|
44
|
+
scratchCartographic = Cartographic.fromCartesian(cluster.billboard.position, undefined, scratchCartographic);
|
|
45
|
+
const position = Projection.wgs84ToMercator([
|
|
46
|
+
CesiumMath.toDegrees(scratchCartographic.longitude),
|
|
47
|
+
CesiumMath.toDegrees(scratchCartographic.latitude),
|
|
48
|
+
scratchCartographic.height,
|
|
49
|
+
], true);
|
|
50
|
+
feature.setGeometry(new Point(position));
|
|
51
|
+
const bbOptions = getBillboardOptions(feature, style, this.vectorProperties.getAltitudeMode(feature), this.vectorProperties);
|
|
52
|
+
if (bbOptions) {
|
|
53
|
+
cluster.billboard.image = bbOptions.image;
|
|
54
|
+
cluster.billboard.scale = bbOptions.scale;
|
|
55
|
+
cluster.billboard.heightReference =
|
|
56
|
+
bbOptions.heightReference;
|
|
57
|
+
cluster.billboard.verticalOrigin =
|
|
58
|
+
bbOptions.verticalOrigin;
|
|
59
|
+
if (bbOptions.eyeOffset) {
|
|
60
|
+
cluster.billboard.eyeOffset = bbOptions.eyeOffset;
|
|
61
|
+
}
|
|
62
|
+
if (bbOptions.scaleByDistance) {
|
|
63
|
+
cluster.billboard.scaleByDistance = bbOptions.scaleByDistance;
|
|
64
|
+
}
|
|
65
|
+
cluster.billboard.olFeature = feature;
|
|
66
|
+
cluster.label.show = false;
|
|
67
|
+
cluster.billboard.show = true;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
cluster.label.show = false;
|
|
71
|
+
cluster.billboard.show = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async initialize() {
|
|
75
|
+
if (!this.initialized) {
|
|
76
|
+
this._context = new VectorClusterCesiumContext(this._rootCollection);
|
|
77
|
+
this._rootCollection[vectorClusterGroupName] = this.name;
|
|
78
|
+
await this.map.addClusterDataSource(this._rootCollection);
|
|
79
|
+
this._sourceVectorContextSync = createSourceVectorContextSync(this._source, this._context, this.map.getScene(), this.style, (f) => this._getLayerByName(f[vcsLayerName])?.vectorProperties ??
|
|
80
|
+
this.vectorProperties);
|
|
81
|
+
this._removeClusterEventListener =
|
|
82
|
+
this._rootCollection.clustering.clusterEvent.addEventListener((entities, cluster) => {
|
|
83
|
+
this._onCluster(entities, cluster);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
await super.initialize();
|
|
87
|
+
}
|
|
88
|
+
async activate() {
|
|
89
|
+
if (!this.active) {
|
|
90
|
+
await super.activate();
|
|
91
|
+
if (this.active) {
|
|
92
|
+
this._sourceVectorContextSync?.activate();
|
|
93
|
+
this._rootCollection.show = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
deactivate() {
|
|
98
|
+
this._rootCollection.show = false;
|
|
99
|
+
this._sourceVectorContextSync?.deactivate();
|
|
100
|
+
super.deactivate();
|
|
101
|
+
}
|
|
102
|
+
destroy() {
|
|
103
|
+
if (this._removeClusterEventListener) {
|
|
104
|
+
this._removeClusterEventListener();
|
|
105
|
+
}
|
|
106
|
+
if (this.initialized) {
|
|
107
|
+
this._sourceVectorContextSync?.destroy();
|
|
108
|
+
this._context?.destroy();
|
|
109
|
+
this.map.removeClusterDataSource(this._rootCollection);
|
|
110
|
+
}
|
|
111
|
+
this._context = undefined;
|
|
112
|
+
super.destroy();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=vectorClusterGroupCesiumImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectorClusterGroupCesiumImpl.js","sourceRoot":"","sources":["../../../src/vectorCluster/vectorClusterGroupCesiumImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,gBAAgB,EAIhB,IAAI,IAAI,UAAU,GAGnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAG/C,OAAO,0BAA0B,MAAM,iCAAiC,CAAC;AACzE,OAAO,EACL,6BAA6B,GAE9B,MAAM,4CAA4C,CAAC;AACpD,OAAO,sBAAsB,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,IAAI,mBAAmB,GAAG,IAAI,YAAY,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,4BAA6B,SAAQ,sBAAiC;IACzF,MAAM,KAAK,SAAS;QAClB,OAAO,8BAA8B,CAAC;IACxC,CAAC;IAEO,e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EAAE,CAAC;gBAC1C,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAED,UAAU;QACR,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,KAAK,CAAC;QAClC,IAAI,CAAC,wBAAwB,EAAE,UAAU,EAAE,CAAC;QAC5C,KAAK,CAAC,UAAU,EAAE,CAAC;IACrB,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACrC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACrC,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,wBAAwB,EAAE,OAAO,EAAE,CAAC;YACzC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;YACzB,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import VectorClusterGroup from './vectorClusterGroup.js';
|
|
2
|
+
import Collection from '../util/collection.js';
|
|
3
|
+
import GlobalHider from '../layer/globalHider.js';
|
|
4
|
+
export default class VectorClusterGroupCollection extends Collection<VectorClusterGroup> {
|
|
5
|
+
/**
|
|
6
|
+
* The global hider for this collection.
|
|
7
|
+
*/
|
|
8
|
+
private _globalHider;
|
|
9
|
+
constructor(globalHider: GlobalHider);
|
|
10
|
+
/**
|
|
11
|
+
* The current global hider of these layers
|
|
12
|
+
*/
|
|
13
|
+
get globalHider(): GlobalHider;
|
|
14
|
+
/**
|
|
15
|
+
* The current global hider of these layers
|
|
16
|
+
* @param globalHider
|
|
17
|
+
*/
|
|
18
|
+
set globalHider(globalHider: GlobalHider);
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { check } from '@vcsuite/check';
|
|
2
|
+
import Collection from '../util/collection.js';
|
|
3
|
+
import GlobalHider from '../layer/globalHider.js';
|
|
4
|
+
export default class VectorClusterGroupCollection extends Collection {
|
|
5
|
+
/**
|
|
6
|
+
* The global hider for this collection.
|
|
7
|
+
*/
|
|
8
|
+
_globalHider;
|
|
9
|
+
constructor(globalHider) {
|
|
10
|
+
super();
|
|
11
|
+
this._globalHider = globalHider;
|
|
12
|
+
this.added.addEventListener((g) => {
|
|
13
|
+
g.setGlobalHider(this._globalHider);
|
|
14
|
+
});
|
|
15
|
+
this.removed.addEventListener((g) => {
|
|
16
|
+
g.setGlobalHider();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The current global hider of these layers
|
|
21
|
+
*/
|
|
22
|
+
get globalHider() {
|
|
23
|
+
return this._globalHider;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The current global hider of these layers
|
|
27
|
+
* @param globalHider
|
|
28
|
+
*/
|
|
29
|
+
set globalHider(globalHider) {
|
|
30
|
+
check(globalHider, GlobalHider);
|
|
31
|
+
this._globalHider = globalHider;
|
|
32
|
+
this._array.forEach((vectorClusterGroup) => {
|
|
33
|
+
vectorClusterGroup.setGlobalHider(this._globalHider);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=vectorClusterGroupCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectorClusterGroupCollection.js","sourceRoot":"","sources":["../../../src/vectorCluster/vectorClusterGroupCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,4BAA6B,SAAQ,UAA8B;IACtF;;OAEG;IACK,YAAY,CAAc;IAElC,YAAY,WAAwB;QAClC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAEhC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE;YAChC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE;YAClC,CAAC,CAAC,cAAc,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW,CAAC,WAAwB;QACtC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAEhC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,EAAE;YACzC,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StyleFunction } from 'ol/style/Style.js';
|
|
2
|
+
import type { VectorClusterGroupImplementationOptions } from './vectorClusterGroup.js';
|
|
3
|
+
import VcsObject from '../vcsObject.js';
|
|
4
|
+
import VectorProperties from '../layer/vectorProperties.js';
|
|
5
|
+
import ClusterEnhancedVectorSource from '../ol/source/ClusterEnhancedVectorSource.js';
|
|
6
|
+
import type GlobalHider from '../layer/globalHider.js';
|
|
7
|
+
import FeatureVisibility from '../layer/featureVisibility.js';
|
|
8
|
+
import VcsMap from '../map/vcsMap.js';
|
|
9
|
+
/**
|
|
10
|
+
* Clusters for vector layers containing point features only
|
|
11
|
+
*/
|
|
12
|
+
export default class VectorClusterGroupImpl<M extends VcsMap> extends VcsObject {
|
|
13
|
+
static get className(): string;
|
|
14
|
+
private _map;
|
|
15
|
+
private _state;
|
|
16
|
+
private _initialized;
|
|
17
|
+
style: StyleFunction;
|
|
18
|
+
protected _source: ClusterEnhancedVectorSource;
|
|
19
|
+
private _featureVisibilityListeners;
|
|
20
|
+
protected _featureVisibility: FeatureVisibility;
|
|
21
|
+
protected _globalHider: GlobalHider | undefined;
|
|
22
|
+
vectorProperties: VectorProperties;
|
|
23
|
+
constructor(map: M, options: VectorClusterGroupImplementationOptions);
|
|
24
|
+
get map(): M;
|
|
25
|
+
get active(): boolean;
|
|
26
|
+
get initialized(): boolean;
|
|
27
|
+
initialize(): Promise<void>;
|
|
28
|
+
activate(): Promise<void>;
|
|
29
|
+
deactivate(): void;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import VcsObject from '../vcsObject.js';
|
|
2
|
+
import LayerState from '../layer/layerState.js';
|
|
3
|
+
import { synchronizeFeatureVisibilityWithSource } from '../layer/vectorHelpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* Clusters for vector layers containing point features only
|
|
6
|
+
*/
|
|
7
|
+
export default class VectorClusterGroupImpl extends VcsObject {
|
|
8
|
+
static get className() {
|
|
9
|
+
return 'VectorClusterCesiumImpl';
|
|
10
|
+
}
|
|
11
|
+
_map;
|
|
12
|
+
_state = LayerState.INACTIVE;
|
|
13
|
+
_initialized = false;
|
|
14
|
+
style;
|
|
15
|
+
_source;
|
|
16
|
+
_featureVisibilityListeners = [];
|
|
17
|
+
_featureVisibility;
|
|
18
|
+
_globalHider;
|
|
19
|
+
vectorProperties;
|
|
20
|
+
constructor(map, options) {
|
|
21
|
+
super(options);
|
|
22
|
+
this._map = map;
|
|
23
|
+
this.style = options.style;
|
|
24
|
+
this._source = options.source;
|
|
25
|
+
this.vectorProperties = options.vectorProperties;
|
|
26
|
+
this._featureVisibility = options.featureVisibility;
|
|
27
|
+
this._globalHider = options.globalHider;
|
|
28
|
+
}
|
|
29
|
+
get map() {
|
|
30
|
+
if (!this._map) {
|
|
31
|
+
throw new Error('Trying to access uninitialized VectorClusterGroupImpl');
|
|
32
|
+
}
|
|
33
|
+
return this._map;
|
|
34
|
+
}
|
|
35
|
+
get active() {
|
|
36
|
+
return this._state === LayerState.ACTIVE;
|
|
37
|
+
}
|
|
38
|
+
get initialized() {
|
|
39
|
+
return this._initialized;
|
|
40
|
+
}
|
|
41
|
+
initialize() {
|
|
42
|
+
this._initialized = true;
|
|
43
|
+
return Promise.resolve();
|
|
44
|
+
}
|
|
45
|
+
async activate() {
|
|
46
|
+
if (this.map.active && !this.active) {
|
|
47
|
+
this._state = LayerState.LOADING;
|
|
48
|
+
await this.initialize();
|
|
49
|
+
if (this._state === LayerState.LOADING) {
|
|
50
|
+
this._state = LayerState.ACTIVE;
|
|
51
|
+
if (this._featureVisibilityListeners.length === 0) {
|
|
52
|
+
this._featureVisibilityListeners =
|
|
53
|
+
synchronizeFeatureVisibilityWithSource(this._featureVisibility, this._source, this._globalHider);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
deactivate() {
|
|
59
|
+
this._state = LayerState.INACTIVE;
|
|
60
|
+
this._featureVisibilityListeners.forEach((cb) => {
|
|
61
|
+
cb();
|
|
62
|
+
});
|
|
63
|
+
this._featureVisibilityListeners = [];
|
|
64
|
+
}
|
|
65
|
+
destroy() {
|
|
66
|
+
this._featureVisibilityListeners.forEach((cb) => {
|
|
67
|
+
cb();
|
|
68
|
+
});
|
|
69
|
+
this._featureVisibilityListeners = [];
|
|
70
|
+
this._initialized = false;
|
|
71
|
+
this._state = LayerState.INACTIVE;
|
|
72
|
+
this._map = undefined;
|
|
73
|
+
super.destroy();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=vectorClusterGroupImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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