@artstesh/maps 4.0.6 → 4.0.7
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/esm2020/map/helpers/index.mjs +2 -1
- package/dist/esm2020/map/helpers/marker-style.helper.mjs +5 -1
- package/dist/esm2020/map/helpers/text-style.helper.mjs +14 -0
- package/dist/esm2020/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.mjs +59 -0
- package/dist/esm2020/map/map-plate/layers/cluster-layer/cluster-layer.component.mjs +50 -0
- package/dist/esm2020/map/map-plate/layers/cluster-layer/cluster-layer.manager.mjs +18 -0
- package/dist/esm2020/map/map-plate/layers/cluster-layer/cluster-layer.settings.mjs +61 -0
- package/dist/esm2020/map/map-plate/layers/index.mjs +3 -1
- package/dist/esm2020/map/map-plate/map-plate.component.mjs +4 -3
- package/dist/esm2020/map/map.module.mjs +8 -3
- package/dist/esm2020/map/messages/commands/add-layer.command.mjs +1 -1
- package/dist/esm2020/map/messages/commands/fit-to-features.command.mjs +13 -0
- package/dist/esm2020/map/messages/events/map-click.event.mjs +3 -2
- package/dist/esm2020/map/models/i-identified.mjs +2 -0
- package/dist/esm2020/map/models/map.constants.mjs +4 -0
- package/dist/esm2020/map/models/marker-model.mjs +3 -2
- package/dist/esm2020/map/services/map-click.service.mjs +7 -3
- package/dist/esm2020/map/services/map-feature.service.mjs +39 -0
- package/dist/esm2020/map/services/map-management.service.mjs +6 -3
- package/dist/esm2020/map/services/message-registrator.service.mjs +9 -6
- package/dist/esm2020/src/map/helpers/index.mjs +2 -1
- package/dist/esm2020/src/map/helpers/marker-style.helper.mjs +5 -1
- package/dist/esm2020/src/map/helpers/text-style.helper.mjs +14 -0
- package/dist/esm2020/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.mjs +59 -0
- package/dist/esm2020/src/map/map-plate/layers/cluster-layer/cluster-layer.component.mjs +50 -0
- package/dist/esm2020/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.mjs +18 -0
- package/dist/esm2020/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.mjs +61 -0
- package/dist/esm2020/src/map/map-plate/layers/index.mjs +3 -1
- package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +4 -3
- package/dist/esm2020/src/map/map.module.mjs +8 -3
- package/dist/esm2020/src/map/messages/commands/add-layer.command.mjs +1 -1
- package/dist/esm2020/src/map/messages/commands/fit-to-features.command.mjs +13 -0
- package/dist/esm2020/src/map/messages/events/map-click.event.mjs +3 -2
- package/dist/esm2020/src/map/models/i-identified.mjs +2 -0
- package/dist/esm2020/src/map/models/map.constants.mjs +4 -0
- package/dist/esm2020/src/map/models/marker-model.mjs +3 -2
- package/dist/esm2020/src/map/services/map-click.service.mjs +7 -3
- package/dist/esm2020/src/map/services/map-feature.service.mjs +39 -0
- package/dist/esm2020/src/map/services/map-management.service.mjs +6 -3
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +9 -6
- package/dist/fesm2015/maps-components-src-map.mjs +268 -18
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +268 -18
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +264 -17
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +264 -17
- package/dist/fesm2020/maps-components.mjs.map +1 -1
- package/dist/map/helpers/index.d.ts +1 -0
- package/dist/map/helpers/marker-style.helper.d.ts +2 -0
- package/dist/map/helpers/text-style.helper.d.ts +4 -0
- package/dist/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.d.ts +11 -0
- package/dist/map/map-plate/layers/cluster-layer/cluster-layer.component.d.ts +21 -0
- package/dist/map/map-plate/layers/cluster-layer/cluster-layer.manager.d.ts +11 -0
- package/dist/map/map-plate/layers/cluster-layer/cluster-layer.settings.d.ts +20 -0
- package/dist/map/map-plate/layers/index.d.ts +2 -0
- package/dist/map/map.module.d.ts +3 -2
- package/dist/map/messages/commands/add-layer.command.d.ts +3 -2
- package/dist/map/messages/commands/fit-to-features.command.d.ts +10 -0
- package/dist/map/messages/events/map-click.event.d.ts +10 -2
- package/dist/map/models/i-identified.d.ts +3 -0
- package/dist/map/models/map.constants.d.ts +3 -0
- package/dist/map/services/map-feature.service.d.ts +14 -0
- package/dist/map/services/message-registrator.service.d.ts +2 -1
- package/dist/src/map/helpers/index.d.ts +1 -0
- package/dist/src/map/helpers/marker-style.helper.d.ts +2 -0
- package/dist/src/map/helpers/text-style.helper.d.ts +4 -0
- package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.d.ts +11 -0
- package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.component.d.ts +21 -0
- package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.d.ts +11 -0
- package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.d.ts +20 -0
- package/dist/src/map/map-plate/layers/index.d.ts +2 -0
- package/dist/src/map/map.module.d.ts +3 -2
- package/dist/src/map/messages/commands/add-layer.command.d.ts +3 -2
- package/dist/src/map/messages/commands/fit-to-features.command.d.ts +10 -0
- package/dist/src/map/messages/events/map-click.event.d.ts +10 -2
- package/dist/src/map/models/i-identified.d.ts +3 -0
- package/dist/src/map/models/map.constants.d.ts +3 -0
- package/dist/src/map/services/map-feature.service.d.ts +14 -0
- package/dist/src/map/services/message-registrator.service.d.ts +2 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { CommonModule } from '@angular/common';
|
|
|
5
5
|
import { Feature } from 'ol';
|
|
6
6
|
import { Point } from 'ol/geom';
|
|
7
7
|
import { GeoJSON, WKT } from 'ol/format';
|
|
8
|
-
import { getCenter } from 'ol/extent';
|
|
8
|
+
import { getCenter, createEmpty, extend } from 'ol/extent';
|
|
9
9
|
import { useGeographic, get } from 'ol/proj';
|
|
10
10
|
import { Subject } from 'rxjs';
|
|
11
11
|
import { PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
@@ -17,8 +17,11 @@ import { filter, first } from 'rxjs/operators';
|
|
|
17
17
|
import { XYZ, Vector } from 'ol/source';
|
|
18
18
|
import { Vector as Vector$1 } from 'ol/layer';
|
|
19
19
|
import Overlay from 'ol/Overlay';
|
|
20
|
+
import { bbox } from 'ol/loadingstrategy';
|
|
21
|
+
import { fromExtent } from 'ol/geom/Polygon';
|
|
22
|
+
import Cluster from 'ol/source/Cluster';
|
|
20
23
|
import Style from 'ol/style/Style';
|
|
21
|
-
import { Icon, Circle, Fill, Stroke } from 'ol/style';
|
|
24
|
+
import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
|
|
22
25
|
|
|
23
26
|
class DestructibleComponent {
|
|
24
27
|
constructor() {
|
|
@@ -122,6 +125,10 @@ class IdGenerator {
|
|
|
122
125
|
}
|
|
123
126
|
IdGenerator.collection = 'ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789'.split('');
|
|
124
127
|
|
|
128
|
+
class MapConstants {
|
|
129
|
+
}
|
|
130
|
+
MapConstants.FeatureInfo = 'f-info';
|
|
131
|
+
|
|
125
132
|
class MarkerModel {
|
|
126
133
|
constructor(lat, lng, id, info) {
|
|
127
134
|
this.lat = lat;
|
|
@@ -137,7 +144,7 @@ class MarkerModel {
|
|
|
137
144
|
const feature = new Feature(new Point([this.lng, this.lat]));
|
|
138
145
|
feature.setId(this.id);
|
|
139
146
|
if (this.info)
|
|
140
|
-
feature.set(
|
|
147
|
+
feature.set(MapConstants.FeatureInfo, this.info);
|
|
141
148
|
return feature;
|
|
142
149
|
}
|
|
143
150
|
}
|
|
@@ -190,10 +197,11 @@ class MapRenderedEvent extends GenericMessage {
|
|
|
190
197
|
MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
|
|
191
198
|
|
|
192
199
|
class MapClickEvent extends GenericMessage {
|
|
193
|
-
constructor(coordinates, entities) {
|
|
200
|
+
constructor(coordinates, entities, features) {
|
|
194
201
|
super();
|
|
195
202
|
this.coordinates = coordinates;
|
|
196
203
|
this.entities = entities;
|
|
204
|
+
this.features = features;
|
|
197
205
|
}
|
|
198
206
|
get id() {
|
|
199
207
|
return MapClickEvent.ID;
|
|
@@ -268,6 +276,18 @@ class RemoveTileCommand extends GenericMessage {
|
|
|
268
276
|
}
|
|
269
277
|
RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
|
|
270
278
|
|
|
279
|
+
class FitToFeaturesCommand extends GenericMessage {
|
|
280
|
+
constructor(features, zoomAfter = 0) {
|
|
281
|
+
super();
|
|
282
|
+
this.features = features;
|
|
283
|
+
this.zoomAfter = zoomAfter;
|
|
284
|
+
}
|
|
285
|
+
get id() {
|
|
286
|
+
return FitToFeaturesCommand.ID;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
FitToFeaturesCommand.ID = '76cdc091-3793-4b6c-82f7-1e0334cf08a8';
|
|
290
|
+
|
|
271
291
|
class MapPostboyService extends PostboyService {
|
|
272
292
|
constructor() {
|
|
273
293
|
super(...arguments);
|
|
@@ -324,8 +344,11 @@ class MapManagementService {
|
|
|
324
344
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
325
345
|
if (!this.layers[c.layer])
|
|
326
346
|
return;
|
|
327
|
-
this.layers[c.layer]?.getSource()
|
|
328
|
-
|
|
347
|
+
let source = this.layers[c.layer]?.getSource();
|
|
348
|
+
if (!!source['getSource'])
|
|
349
|
+
source = source?.getSource();
|
|
350
|
+
source?.clear();
|
|
351
|
+
source?.addFeatures(c.features);
|
|
329
352
|
});
|
|
330
353
|
}
|
|
331
354
|
observeRemoveLayer() {
|
|
@@ -357,6 +380,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
357
380
|
type: Injectable
|
|
358
381
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
359
382
|
|
|
383
|
+
class MapFeatureService {
|
|
384
|
+
constructor(postboy) {
|
|
385
|
+
this.postboy = postboy;
|
|
386
|
+
}
|
|
387
|
+
up() {
|
|
388
|
+
this.observeMapRender();
|
|
389
|
+
this.observeFitToFeatures();
|
|
390
|
+
}
|
|
391
|
+
observeMapRender() {
|
|
392
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
393
|
+
this.map = m.map;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
observeFitToFeatures() {
|
|
397
|
+
this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((m) => {
|
|
398
|
+
this.fitToGeometries(m.features.map((f) => f.getGeometry()), m.zoomAfter);
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
fitToGeometries(geometries, zoomAfter) {
|
|
402
|
+
if (!geometries?.length || !this.map)
|
|
403
|
+
return;
|
|
404
|
+
const extent = createEmpty();
|
|
405
|
+
geometries.forEach((g) => extend(extent, g.getExtent()));
|
|
406
|
+
this.map.getView().fit(extent);
|
|
407
|
+
this.map.getView().setZoom(this.map.getView().getZoom() + zoomAfter);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
MapFeatureService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapFeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
411
|
+
MapFeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapFeatureService });
|
|
412
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapFeatureService, decorators: [{
|
|
413
|
+
type: Injectable
|
|
414
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
415
|
+
|
|
360
416
|
class MapClickService {
|
|
361
417
|
constructor(postboy) {
|
|
362
418
|
this.postboy = postboy;
|
|
@@ -373,7 +429,7 @@ class MapClickService {
|
|
|
373
429
|
});
|
|
374
430
|
}
|
|
375
431
|
onClick(ev) {
|
|
376
|
-
const model = new MapClickEvent(ev.coordinate, {});
|
|
432
|
+
const model = new MapClickEvent(ev.coordinate, {}, {});
|
|
377
433
|
this.map?.forEachFeatureAtPixel(ev.pixel, (f, l) => {
|
|
378
434
|
this.getFeatureCollectionWithInner([f])
|
|
379
435
|
.filter((f) => f.getId() != null)
|
|
@@ -381,7 +437,10 @@ class MapClickService {
|
|
|
381
437
|
let layerName = l.get('name');
|
|
382
438
|
if (!model.entities[layerName])
|
|
383
439
|
model.entities[layerName] = [];
|
|
384
|
-
model.
|
|
440
|
+
if (!model.features[layerName])
|
|
441
|
+
model.features[layerName] = [];
|
|
442
|
+
model.entities[layerName].push({ id: fs.getId(), ...fs.get(MapConstants.FeatureInfo) });
|
|
443
|
+
model.features[layerName].push(fs);
|
|
385
444
|
});
|
|
386
445
|
});
|
|
387
446
|
return model;
|
|
@@ -402,9 +461,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
402
461
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
403
462
|
|
|
404
463
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
405
|
-
constructor(service, management, state, interaction) {
|
|
464
|
+
constructor(service, management, state, feature, interaction) {
|
|
406
465
|
super(service);
|
|
407
|
-
this.registerServices([management, state, interaction]);
|
|
466
|
+
this.registerServices([management, state, interaction, feature]);
|
|
408
467
|
}
|
|
409
468
|
_up() {
|
|
410
469
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -415,13 +474,14 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
415
474
|
this.registerSubject(RemoveTileCommand.ID);
|
|
416
475
|
this.registerSubject(MapClickEvent.ID);
|
|
417
476
|
this.registerSubject(CloseTooltipCommand.ID);
|
|
477
|
+
this.registerSubject(FitToFeaturesCommand.ID);
|
|
418
478
|
}
|
|
419
479
|
}
|
|
420
|
-
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
480
|
+
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
421
481
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
422
482
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
423
483
|
type: Injectable
|
|
424
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapClickService }]; } });
|
|
484
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }]; } });
|
|
425
485
|
|
|
426
486
|
class MapPlateFactory {
|
|
427
487
|
build(settings) {
|
|
@@ -537,10 +597,10 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
537
597
|
}
|
|
538
598
|
}
|
|
539
599
|
MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
540
|
-
MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
600
|
+
MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService, MapFeatureService], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
541
601
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
542
602
|
type: Component,
|
|
543
|
-
args: [{ selector: 'lib-map-plate', changeDetection: ChangeDetectionStrategy.OnPush, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService], template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"] }]
|
|
603
|
+
args: [{ selector: 'lib-map-plate', changeDetection: ChangeDetectionStrategy.OnPush, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService, MapFeatureService], template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"] }]
|
|
544
604
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
545
605
|
type: Input
|
|
546
606
|
}] } });
|
|
@@ -950,6 +1010,172 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
950
1010
|
type: Input
|
|
951
1011
|
}] } });
|
|
952
1012
|
|
|
1013
|
+
class ClusterLayerSettings {
|
|
1014
|
+
constructor() {
|
|
1015
|
+
this.name = IdGenerator.get();
|
|
1016
|
+
this.zIndex = 1;
|
|
1017
|
+
this.maxZoom = 19;
|
|
1018
|
+
this.minZoom = 0;
|
|
1019
|
+
this.distance = 20;
|
|
1020
|
+
this.bbox = false;
|
|
1021
|
+
}
|
|
1022
|
+
static copy(model) {
|
|
1023
|
+
const result = new ClusterLayerSettings();
|
|
1024
|
+
result.name = model.name;
|
|
1025
|
+
result.maxZoom = model.maxZoom;
|
|
1026
|
+
result.minZoom = model.minZoom;
|
|
1027
|
+
result.zIndex = model.zIndex;
|
|
1028
|
+
result.bbox = model.bbox;
|
|
1029
|
+
result.distance = model.distance;
|
|
1030
|
+
result.style = model.style;
|
|
1031
|
+
return result;
|
|
1032
|
+
}
|
|
1033
|
+
setZIndex(zIndex) {
|
|
1034
|
+
return ClusterLayerSettings.copy({ ...this, zIndex });
|
|
1035
|
+
}
|
|
1036
|
+
setDistance(distance) {
|
|
1037
|
+
return ClusterLayerSettings.copy({ ...this, distance });
|
|
1038
|
+
}
|
|
1039
|
+
setName(name) {
|
|
1040
|
+
return ClusterLayerSettings.copy({ ...this, name });
|
|
1041
|
+
}
|
|
1042
|
+
setMaxZoom(maxZoom) {
|
|
1043
|
+
return ClusterLayerSettings.copy({ ...this, maxZoom });
|
|
1044
|
+
}
|
|
1045
|
+
setMinZoom(minZoom) {
|
|
1046
|
+
return ClusterLayerSettings.copy({ ...this, minZoom });
|
|
1047
|
+
}
|
|
1048
|
+
setBbox(bbox) {
|
|
1049
|
+
return ClusterLayerSettings.copy({ ...this, bbox });
|
|
1050
|
+
}
|
|
1051
|
+
setStyle(style) {
|
|
1052
|
+
return ClusterLayerSettings.copy({ ...this, style });
|
|
1053
|
+
}
|
|
1054
|
+
isSame(model) {
|
|
1055
|
+
if (this.maxZoom !== model.maxZoom)
|
|
1056
|
+
return false;
|
|
1057
|
+
if (this.minZoom !== model.minZoom)
|
|
1058
|
+
return false;
|
|
1059
|
+
if (this.zIndex !== model.zIndex)
|
|
1060
|
+
return false;
|
|
1061
|
+
if (this.name !== model.name)
|
|
1062
|
+
return false;
|
|
1063
|
+
if (this.distance !== model.distance)
|
|
1064
|
+
return false;
|
|
1065
|
+
if (this.bbox !== model.bbox)
|
|
1066
|
+
return false;
|
|
1067
|
+
if (this.style !== model.style)
|
|
1068
|
+
return false;
|
|
1069
|
+
return true;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
class ClusterLayerManager {
|
|
1074
|
+
constructor(settings, layer, postboy) {
|
|
1075
|
+
this.settings = settings;
|
|
1076
|
+
this.layer = layer;
|
|
1077
|
+
this.postboy = postboy;
|
|
1078
|
+
this.observeClick();
|
|
1079
|
+
}
|
|
1080
|
+
observeClick() {
|
|
1081
|
+
this.postboy.subscribe(MapClickEvent.ID).subscribe((m) => {
|
|
1082
|
+
if ((m.features[this.settings.name]?.length ?? 0) > 1) {
|
|
1083
|
+
this.postboy.fire(new FitToFeaturesCommand(m.features[this.settings.name], -1));
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
class ClusterLayerFactory {
|
|
1090
|
+
build(settings, postboy) {
|
|
1091
|
+
const source = new Vector({
|
|
1092
|
+
strategy: settings.bbox ? bbox : undefined,
|
|
1093
|
+
});
|
|
1094
|
+
const cluster = new Cluster({
|
|
1095
|
+
distance: settings.distance,
|
|
1096
|
+
source: source,
|
|
1097
|
+
geometryFunction: (feature) => {
|
|
1098
|
+
const geom = feature.getGeometry();
|
|
1099
|
+
if (geom?.getType() == 'Point') {
|
|
1100
|
+
return geom;
|
|
1101
|
+
}
|
|
1102
|
+
else if (geom?.getType() == 'Polygon') {
|
|
1103
|
+
return geom?.getInteriorPoint();
|
|
1104
|
+
}
|
|
1105
|
+
else if (geom?.getType() == 'MultiPolygon') {
|
|
1106
|
+
return fromExtent(geom.getExtent())?.getInteriorPoint();
|
|
1107
|
+
}
|
|
1108
|
+
return undefined;
|
|
1109
|
+
},
|
|
1110
|
+
});
|
|
1111
|
+
const layer = new Vector$1({
|
|
1112
|
+
source: cluster,
|
|
1113
|
+
maxZoom: settings.maxZoom || undefined,
|
|
1114
|
+
minZoom: settings.minZoom || undefined,
|
|
1115
|
+
zIndex: settings.zIndex || 0,
|
|
1116
|
+
});
|
|
1117
|
+
layer.setStyle(this.styleFunc(settings));
|
|
1118
|
+
layer.set('name', settings.name);
|
|
1119
|
+
return new ClusterLayerManager(settings, layer, postboy);
|
|
1120
|
+
}
|
|
1121
|
+
styleFunc(settings) {
|
|
1122
|
+
return (feature) => {
|
|
1123
|
+
const features = feature.get('features');
|
|
1124
|
+
if (!settings.style)
|
|
1125
|
+
return undefined;
|
|
1126
|
+
return settings.style(features.map((f) => ({ id: f.getId(), ...f.get(MapConstants.FeatureInfo) })));
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
ClusterLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1131
|
+
ClusterLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, providedIn: 'root' });
|
|
1132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, decorators: [{
|
|
1133
|
+
type: Injectable,
|
|
1134
|
+
args: [{
|
|
1135
|
+
providedIn: 'root',
|
|
1136
|
+
}]
|
|
1137
|
+
}] });
|
|
1138
|
+
|
|
1139
|
+
class ClusterLayerComponent extends DestructibleComponent {
|
|
1140
|
+
constructor(postboy, factory) {
|
|
1141
|
+
super();
|
|
1142
|
+
this.postboy = postboy;
|
|
1143
|
+
this.factory = factory;
|
|
1144
|
+
this.manager = null;
|
|
1145
|
+
this._settings = new ClusterLayerSettings();
|
|
1146
|
+
this.onDestroy = () => this.removeLayer();
|
|
1147
|
+
}
|
|
1148
|
+
ngOnInit() {
|
|
1149
|
+
this.postboy
|
|
1150
|
+
.subscribe(MapRenderedEvent.ID)
|
|
1151
|
+
.pipe(filter((m) => !!m), first())
|
|
1152
|
+
.subscribe((m) => this.initLayer());
|
|
1153
|
+
}
|
|
1154
|
+
set settings(value) {
|
|
1155
|
+
if (!value || this._settings.isSame(value))
|
|
1156
|
+
return;
|
|
1157
|
+
this._settings = value;
|
|
1158
|
+
this.initLayer();
|
|
1159
|
+
}
|
|
1160
|
+
initLayer() {
|
|
1161
|
+
this.removeLayer();
|
|
1162
|
+
this.manager = this.factory.build(this._settings, this.postboy);
|
|
1163
|
+
this.postboy.fire(new AddLayerCommand(this.manager.layer));
|
|
1164
|
+
}
|
|
1165
|
+
removeLayer() {
|
|
1166
|
+
if (this.manager?.layer)
|
|
1167
|
+
this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
ClusterLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerComponent, deps: [{ token: MapPostboyService }, { token: ClusterLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
|
|
1171
|
+
ClusterLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ClusterLayerComponent, selector: "lib-cluster-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerComponent, decorators: [{
|
|
1173
|
+
type: Component,
|
|
1174
|
+
args: [{ selector: 'lib-cluster-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
|
|
1175
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
|
|
1176
|
+
type: Input
|
|
1177
|
+
}] } });
|
|
1178
|
+
|
|
953
1179
|
class MapModule {
|
|
954
1180
|
}
|
|
955
1181
|
MapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -960,12 +1186,14 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
|
|
|
960
1186
|
FeatureLayerComponent,
|
|
961
1187
|
MarkersComponent,
|
|
962
1188
|
TooltipComponent,
|
|
963
|
-
PolygonsComponent
|
|
1189
|
+
PolygonsComponent,
|
|
1190
|
+
ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
|
|
964
1191
|
FeatureLayerComponent,
|
|
965
1192
|
MarkersComponent,
|
|
966
1193
|
TileLayerComponent,
|
|
967
1194
|
TooltipComponent,
|
|
968
|
-
PolygonsComponent
|
|
1195
|
+
PolygonsComponent,
|
|
1196
|
+
ClusterLayerComponent] });
|
|
969
1197
|
MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
|
|
970
1198
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
|
|
971
1199
|
type: NgModule,
|
|
@@ -980,6 +1208,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
980
1208
|
MarkersComponent,
|
|
981
1209
|
TooltipComponent,
|
|
982
1210
|
PolygonsComponent,
|
|
1211
|
+
ClusterLayerComponent,
|
|
983
1212
|
],
|
|
984
1213
|
exports: [
|
|
985
1214
|
MapPlateComponent,
|
|
@@ -988,6 +1217,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
988
1217
|
TileLayerComponent,
|
|
989
1218
|
TooltipComponent,
|
|
990
1219
|
PolygonsComponent,
|
|
1220
|
+
ClusterLayerComponent,
|
|
991
1221
|
],
|
|
992
1222
|
}]
|
|
993
1223
|
}] });
|
|
@@ -1013,6 +1243,10 @@ class MarkerStyleHelper {
|
|
|
1013
1243
|
}),
|
|
1014
1244
|
});
|
|
1015
1245
|
}
|
|
1246
|
+
static withText(style, text) {
|
|
1247
|
+
style.setText(text);
|
|
1248
|
+
return style;
|
|
1249
|
+
}
|
|
1016
1250
|
}
|
|
1017
1251
|
|
|
1018
1252
|
class PolygonStyleHelper {
|
|
@@ -1029,6 +1263,19 @@ class PolygonStyleHelper {
|
|
|
1029
1263
|
}
|
|
1030
1264
|
}
|
|
1031
1265
|
|
|
1266
|
+
class TextStyleHelper {
|
|
1267
|
+
static get(text, font, color) {
|
|
1268
|
+
return new Text({
|
|
1269
|
+
text: text,
|
|
1270
|
+
font: font,
|
|
1271
|
+
textAlign: 'center',
|
|
1272
|
+
fill: new Fill({
|
|
1273
|
+
color: color,
|
|
1274
|
+
}),
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1032
1279
|
/*
|
|
1033
1280
|
* Public API Surface of maps
|
|
1034
1281
|
*/
|
|
@@ -1041,5 +1288,5 @@ class PolygonStyleHelper {
|
|
|
1041
1288
|
* Generated bundle index. Do not edit.
|
|
1042
1289
|
*/
|
|
1043
1290
|
|
|
1044
|
-
export { CallbackMessage, CloseTooltipCommand, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
|
|
1291
|
+
export { CallbackMessage, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
|
|
1045
1292
|
//# sourceMappingURL=maps-components.mjs.map
|