@valtimo/layout 13.44.0 → 13.45.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.
|
@@ -27,14 +27,6 @@ import * as i3$2 from '@valtimo/access-control';
|
|
|
27
27
|
import Muuri from 'muuri';
|
|
28
28
|
import { v4 } from 'uuid';
|
|
29
29
|
import * as i7 from 'carbon-components-angular/dropdown';
|
|
30
|
-
import TileLayer from 'ol/layer/Tile';
|
|
31
|
-
import { OSM } from 'ol/source';
|
|
32
|
-
import { GeoJSON } from 'ol/format';
|
|
33
|
-
import { Map, View } from 'ol';
|
|
34
|
-
import VectorLayer from 'ol/layer/Vector';
|
|
35
|
-
import VectorSource from 'ol/source/Vector';
|
|
36
|
-
import { FullScreen, Zoom, defaults } from 'ol/control';
|
|
37
|
-
import { Style, Stroke, Fill, Icon } from 'ol/style';
|
|
38
30
|
import { Marked } from 'marked';
|
|
39
31
|
import { AuthGuardService } from '@valtimo/security';
|
|
40
32
|
|
|
@@ -4286,6 +4278,8 @@ class WidgetMapComponent {
|
|
|
4286
4278
|
this.noVisibleMapEvent = new EventEmitter();
|
|
4287
4279
|
this.widgetConfiguration$ = new BehaviorSubject(null);
|
|
4288
4280
|
this.widgetData$ = new BehaviorSubject(null);
|
|
4281
|
+
this._destroyed = false;
|
|
4282
|
+
this._subscriptions = new Subscription();
|
|
4289
4283
|
}
|
|
4290
4284
|
set widgetConfiguration(value) {
|
|
4291
4285
|
if (!value)
|
|
@@ -4306,6 +4300,8 @@ class WidgetMapComponent {
|
|
|
4306
4300
|
this.subscribeMapData();
|
|
4307
4301
|
}
|
|
4308
4302
|
ngOnDestroy() {
|
|
4303
|
+
this._destroyed = true;
|
|
4304
|
+
this._subscriptions.unsubscribe();
|
|
4309
4305
|
this._observer?.disconnect();
|
|
4310
4306
|
}
|
|
4311
4307
|
openWidthObserver() {
|
|
@@ -4315,10 +4311,23 @@ class WidgetMapComponent {
|
|
|
4315
4311
|
checkEmptyWidgetData(widgetData) {
|
|
4316
4312
|
return widgetData && Object.keys(widgetData).length === 0;
|
|
4317
4313
|
}
|
|
4318
|
-
subscribeMapData() {
|
|
4314
|
+
async subscribeMapData() {
|
|
4315
|
+
// Loaded on demand: OpenLayers is only needed by dashboards that actually show a map widget.
|
|
4316
|
+
const [{ Map: OlMap, View }, { default: TileLayer }, { OSM }, { GeoJSON }, { default: VectorLayerCtor }, { default: VectorSourceCtor }, { FullScreen, defaults, Zoom }, { Icon, Fill, Stroke, Style },] = await Promise.all([
|
|
4317
|
+
import('ol'),
|
|
4318
|
+
import('ol/layer/Tile'),
|
|
4319
|
+
import('ol/source'),
|
|
4320
|
+
import('ol/format'),
|
|
4321
|
+
import('ol/layer/Vector'),
|
|
4322
|
+
import('ol/source/Vector'),
|
|
4323
|
+
import('ol/control'),
|
|
4324
|
+
import('ol/style'),
|
|
4325
|
+
]);
|
|
4326
|
+
if (this._destroyed)
|
|
4327
|
+
return;
|
|
4319
4328
|
const fullscreen = new FullScreen();
|
|
4320
4329
|
const zoomControl = new Zoom({});
|
|
4321
|
-
this.map = new
|
|
4330
|
+
this.map = new OlMap({
|
|
4322
4331
|
target: this._widgetMapRef.nativeElement,
|
|
4323
4332
|
layers: [
|
|
4324
4333
|
new TileLayer({
|
|
@@ -4358,7 +4367,7 @@ class WidgetMapComponent {
|
|
|
4358
4367
|
width: 2,
|
|
4359
4368
|
}),
|
|
4360
4369
|
});
|
|
4361
|
-
this.widgetData$.subscribe(widgetData => {
|
|
4370
|
+
this._subscriptions.add(this.widgetData$.subscribe(widgetData => {
|
|
4362
4371
|
if (!widgetData?.geoJsonFeatureCollection?.features) {
|
|
4363
4372
|
return;
|
|
4364
4373
|
}
|
|
@@ -4369,16 +4378,16 @@ class WidgetMapComponent {
|
|
|
4369
4378
|
if (this.vectorLayer) {
|
|
4370
4379
|
this.map.removeLayer(this.vectorLayer);
|
|
4371
4380
|
}
|
|
4372
|
-
const vectorSource = new
|
|
4381
|
+
const vectorSource = new VectorSourceCtor({
|
|
4373
4382
|
features: new GeoJSON().readFeatures(featureCollection, featureOptions),
|
|
4374
4383
|
});
|
|
4375
|
-
this.vectorLayer = new
|
|
4384
|
+
this.vectorLayer = new VectorLayerCtor({
|
|
4376
4385
|
source: vectorSource,
|
|
4377
4386
|
style: vectorStyle,
|
|
4378
4387
|
});
|
|
4379
4388
|
this.map.addLayer(this.vectorLayer);
|
|
4380
4389
|
setTimeout(() => this.fitMap(vectorSource));
|
|
4381
|
-
});
|
|
4390
|
+
}));
|
|
4382
4391
|
}
|
|
4383
4392
|
fitMap(vectorSource) {
|
|
4384
4393
|
const extent = vectorSource?.getExtent();
|