@artstesh/maps 5.0.6 → 5.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/esm2022/map/helpers/index.mjs +2 -1
- package/dist/esm2022/map/helpers/marker-style.helper.mjs +5 -1
- package/dist/esm2022/map/helpers/text-style.helper.mjs +14 -0
- package/dist/esm2022/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.mjs +59 -0
- package/dist/esm2022/map/map-plate/layers/cluster-layer/cluster-layer.component.mjs +52 -0
- package/dist/esm2022/map/map-plate/layers/cluster-layer/cluster-layer.manager.mjs +21 -0
- package/dist/esm2022/map/map-plate/layers/cluster-layer/cluster-layer.settings.mjs +60 -0
- package/dist/esm2022/map/map-plate/layers/index.mjs +3 -1
- package/dist/esm2022/map/map-plate/map-plate.component.mjs +4 -3
- package/dist/esm2022/map/map.module.mjs +8 -3
- package/dist/esm2022/map/messages/commands/add-layer.command.mjs +1 -1
- package/dist/esm2022/map/messages/commands/fit-to-features.command.mjs +15 -0
- package/dist/esm2022/map/messages/events/map-click.event.mjs +4 -2
- package/dist/esm2022/map/models/i-identified.mjs +2 -0
- package/dist/esm2022/map/models/map.constants.mjs +4 -0
- package/dist/esm2022/map/models/marker-model.mjs +3 -2
- package/dist/esm2022/map/services/map-click.service.mjs +7 -3
- package/dist/esm2022/map/services/map-feature.service.mjs +41 -0
- package/dist/esm2022/map/services/map-management.service.mjs +6 -3
- package/dist/esm2022/map/services/message-registrator.service.mjs +9 -6
- package/dist/esm2022/src/map/helpers/index.mjs +2 -1
- package/dist/esm2022/src/map/helpers/marker-style.helper.mjs +5 -1
- package/dist/esm2022/src/map/helpers/text-style.helper.mjs +14 -0
- package/dist/esm2022/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.mjs +59 -0
- package/dist/esm2022/src/map/map-plate/layers/cluster-layer/cluster-layer.component.mjs +52 -0
- package/dist/esm2022/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.mjs +21 -0
- package/dist/esm2022/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.mjs +60 -0
- package/dist/esm2022/src/map/map-plate/layers/index.mjs +3 -1
- package/dist/esm2022/src/map/map-plate/map-plate.component.mjs +4 -3
- package/dist/esm2022/src/map/map.module.mjs +8 -3
- package/dist/esm2022/src/map/messages/commands/add-layer.command.mjs +1 -1
- package/dist/esm2022/src/map/messages/commands/fit-to-features.command.mjs +15 -0
- package/dist/esm2022/src/map/messages/events/map-click.event.mjs +4 -2
- package/dist/esm2022/src/map/models/i-identified.mjs +2 -0
- package/dist/esm2022/src/map/models/map.constants.mjs +4 -0
- package/dist/esm2022/src/map/models/marker-model.mjs +3 -2
- package/dist/esm2022/src/map/services/map-click.service.mjs +7 -3
- package/dist/esm2022/src/map/services/map-feature.service.mjs +41 -0
- package/dist/esm2022/src/map/services/map-management.service.mjs +6 -3
- package/dist/esm2022/src/map/services/message-registrator.service.mjs +9 -6
- package/dist/fesm2022/maps-components-src-map.mjs +273 -17
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +273 -17
- package/dist/fesm2022/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
|
subs = [];
|
|
@@ -119,6 +122,10 @@ class IdGenerator {
|
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
|
|
125
|
+
class MapConstants {
|
|
126
|
+
static FeatureInfo = 'f-info';
|
|
127
|
+
}
|
|
128
|
+
|
|
122
129
|
class MarkerModel {
|
|
123
130
|
lat;
|
|
124
131
|
lng;
|
|
@@ -139,7 +146,7 @@ class MarkerModel {
|
|
|
139
146
|
const feature = new Feature(new Point([this.lng, this.lat]));
|
|
140
147
|
feature.setId(this.id);
|
|
141
148
|
if (this.info)
|
|
142
|
-
feature.set(
|
|
149
|
+
feature.set(MapConstants.FeatureInfo, this.info);
|
|
143
150
|
return feature;
|
|
144
151
|
}
|
|
145
152
|
}
|
|
@@ -197,11 +204,13 @@ class MapRenderedEvent extends GenericMessage {
|
|
|
197
204
|
class MapClickEvent extends GenericMessage {
|
|
198
205
|
coordinates;
|
|
199
206
|
entities;
|
|
207
|
+
features;
|
|
200
208
|
static ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
|
|
201
|
-
constructor(coordinates, entities) {
|
|
209
|
+
constructor(coordinates, entities, features) {
|
|
202
210
|
super();
|
|
203
211
|
this.coordinates = coordinates;
|
|
204
212
|
this.entities = entities;
|
|
213
|
+
this.features = features;
|
|
205
214
|
}
|
|
206
215
|
get id() {
|
|
207
216
|
return MapClickEvent.ID;
|
|
@@ -282,6 +291,20 @@ class RemoveTileCommand extends GenericMessage {
|
|
|
282
291
|
}
|
|
283
292
|
}
|
|
284
293
|
|
|
294
|
+
class FitToFeaturesCommand extends GenericMessage {
|
|
295
|
+
features;
|
|
296
|
+
zoomAfter;
|
|
297
|
+
static ID = '76cdc091-3793-4b6c-82f7-1e0334cf08a8';
|
|
298
|
+
constructor(features, zoomAfter = 0) {
|
|
299
|
+
super();
|
|
300
|
+
this.features = features;
|
|
301
|
+
this.zoomAfter = zoomAfter;
|
|
302
|
+
}
|
|
303
|
+
get id() {
|
|
304
|
+
return FitToFeaturesCommand.ID;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
285
308
|
class MapPostboyService extends PostboyService {
|
|
286
309
|
observe = (id) => this.subscribe(id);
|
|
287
310
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPostboyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -337,8 +360,11 @@ class MapManagementService {
|
|
|
337
360
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
338
361
|
if (!this.layers[c.layer])
|
|
339
362
|
return;
|
|
340
|
-
this.layers[c.layer]?.getSource()
|
|
341
|
-
|
|
363
|
+
let source = this.layers[c.layer]?.getSource();
|
|
364
|
+
if (!!source['getSource'])
|
|
365
|
+
source = source?.getSource();
|
|
366
|
+
source?.clear();
|
|
367
|
+
source?.addFeatures(c.features);
|
|
342
368
|
});
|
|
343
369
|
}
|
|
344
370
|
observeRemoveLayer() {
|
|
@@ -372,6 +398,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
372
398
|
type: Injectable
|
|
373
399
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
374
400
|
|
|
401
|
+
class MapFeatureService {
|
|
402
|
+
postboy;
|
|
403
|
+
map;
|
|
404
|
+
constructor(postboy) {
|
|
405
|
+
this.postboy = postboy;
|
|
406
|
+
}
|
|
407
|
+
up() {
|
|
408
|
+
this.observeMapRender();
|
|
409
|
+
this.observeFitToFeatures();
|
|
410
|
+
}
|
|
411
|
+
observeMapRender() {
|
|
412
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
413
|
+
this.map = m.map;
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
observeFitToFeatures() {
|
|
417
|
+
this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((m) => {
|
|
418
|
+
this.fitToGeometries(m.features.map((f) => f.getGeometry()), m.zoomAfter);
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
fitToGeometries(geometries, zoomAfter) {
|
|
422
|
+
if (!geometries?.length || !this.map)
|
|
423
|
+
return;
|
|
424
|
+
const extent = createEmpty();
|
|
425
|
+
geometries.forEach((g) => extend(extent, g.getExtent()));
|
|
426
|
+
this.map.getView().fit(extent);
|
|
427
|
+
this.map.getView().setZoom(this.map.getView().getZoom() + zoomAfter);
|
|
428
|
+
}
|
|
429
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapFeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
430
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapFeatureService });
|
|
431
|
+
}
|
|
432
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapFeatureService, decorators: [{
|
|
433
|
+
type: Injectable
|
|
434
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
435
|
+
|
|
375
436
|
class MapClickService {
|
|
376
437
|
postboy;
|
|
377
438
|
map;
|
|
@@ -390,7 +451,7 @@ class MapClickService {
|
|
|
390
451
|
});
|
|
391
452
|
}
|
|
392
453
|
onClick(ev) {
|
|
393
|
-
const model = new MapClickEvent(ev.coordinate, {});
|
|
454
|
+
const model = new MapClickEvent(ev.coordinate, {}, {});
|
|
394
455
|
this.map?.forEachFeatureAtPixel(ev.pixel, (f, l) => {
|
|
395
456
|
this.getFeatureCollectionWithInner([f])
|
|
396
457
|
.filter((f) => f.getId() != null)
|
|
@@ -398,7 +459,10 @@ class MapClickService {
|
|
|
398
459
|
let layerName = l.get('name');
|
|
399
460
|
if (!model.entities[layerName])
|
|
400
461
|
model.entities[layerName] = [];
|
|
401
|
-
model.
|
|
462
|
+
if (!model.features[layerName])
|
|
463
|
+
model.features[layerName] = [];
|
|
464
|
+
model.entities[layerName].push({ id: fs.getId(), ...fs.get(MapConstants.FeatureInfo) });
|
|
465
|
+
model.features[layerName].push(fs);
|
|
402
466
|
});
|
|
403
467
|
});
|
|
404
468
|
return model;
|
|
@@ -419,9 +483,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
419
483
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
420
484
|
|
|
421
485
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
422
|
-
constructor(service, management, state, interaction) {
|
|
486
|
+
constructor(service, management, state, feature, interaction) {
|
|
423
487
|
super(service);
|
|
424
|
-
this.registerServices([management, state, interaction]);
|
|
488
|
+
this.registerServices([management, state, interaction, feature]);
|
|
425
489
|
}
|
|
426
490
|
_up() {
|
|
427
491
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -432,13 +496,14 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
432
496
|
this.registerSubject(RemoveTileCommand.ID);
|
|
433
497
|
this.registerSubject(MapClickEvent.ID);
|
|
434
498
|
this.registerSubject(CloseTooltipCommand.ID);
|
|
499
|
+
this.registerSubject(FitToFeaturesCommand.ID);
|
|
435
500
|
}
|
|
436
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
501
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
437
502
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService });
|
|
438
503
|
}
|
|
439
504
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
440
505
|
type: Injectable
|
|
441
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapClickService }]; } });
|
|
506
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }]; } });
|
|
442
507
|
|
|
443
508
|
class MapPlateFactory {
|
|
444
509
|
build(settings) {
|
|
@@ -561,11 +626,11 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
561
626
|
this.registrator.down();
|
|
562
627
|
};
|
|
563
628
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
564
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", 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 });
|
|
629
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", 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 });
|
|
565
630
|
}
|
|
566
631
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
567
632
|
type: Component,
|
|
568
|
-
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"] }]
|
|
633
|
+
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"] }]
|
|
569
634
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
570
635
|
type: Input
|
|
571
636
|
}] } });
|
|
@@ -985,6 +1050,176 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
985
1050
|
type: Input
|
|
986
1051
|
}] } });
|
|
987
1052
|
|
|
1053
|
+
class ClusterLayerSettings {
|
|
1054
|
+
name = IdGenerator.get();
|
|
1055
|
+
zIndex = 1;
|
|
1056
|
+
maxZoom = 19;
|
|
1057
|
+
minZoom = 0;
|
|
1058
|
+
distance = 20;
|
|
1059
|
+
bbox = false;
|
|
1060
|
+
style;
|
|
1061
|
+
static copy(model) {
|
|
1062
|
+
const result = new ClusterLayerSettings();
|
|
1063
|
+
result.name = model.name;
|
|
1064
|
+
result.maxZoom = model.maxZoom;
|
|
1065
|
+
result.minZoom = model.minZoom;
|
|
1066
|
+
result.zIndex = model.zIndex;
|
|
1067
|
+
result.bbox = model.bbox;
|
|
1068
|
+
result.distance = model.distance;
|
|
1069
|
+
result.style = model.style;
|
|
1070
|
+
return result;
|
|
1071
|
+
}
|
|
1072
|
+
setZIndex(zIndex) {
|
|
1073
|
+
return ClusterLayerSettings.copy({ ...this, zIndex });
|
|
1074
|
+
}
|
|
1075
|
+
setDistance(distance) {
|
|
1076
|
+
return ClusterLayerSettings.copy({ ...this, distance });
|
|
1077
|
+
}
|
|
1078
|
+
setName(name) {
|
|
1079
|
+
return ClusterLayerSettings.copy({ ...this, name });
|
|
1080
|
+
}
|
|
1081
|
+
setMaxZoom(maxZoom) {
|
|
1082
|
+
return ClusterLayerSettings.copy({ ...this, maxZoom });
|
|
1083
|
+
}
|
|
1084
|
+
setMinZoom(minZoom) {
|
|
1085
|
+
return ClusterLayerSettings.copy({ ...this, minZoom });
|
|
1086
|
+
}
|
|
1087
|
+
setBbox(bbox) {
|
|
1088
|
+
return ClusterLayerSettings.copy({ ...this, bbox });
|
|
1089
|
+
}
|
|
1090
|
+
setStyle(style) {
|
|
1091
|
+
return ClusterLayerSettings.copy({ ...this, style });
|
|
1092
|
+
}
|
|
1093
|
+
isSame(model) {
|
|
1094
|
+
if (this.maxZoom !== model.maxZoom)
|
|
1095
|
+
return false;
|
|
1096
|
+
if (this.minZoom !== model.minZoom)
|
|
1097
|
+
return false;
|
|
1098
|
+
if (this.zIndex !== model.zIndex)
|
|
1099
|
+
return false;
|
|
1100
|
+
if (this.name !== model.name)
|
|
1101
|
+
return false;
|
|
1102
|
+
if (this.distance !== model.distance)
|
|
1103
|
+
return false;
|
|
1104
|
+
if (this.bbox !== model.bbox)
|
|
1105
|
+
return false;
|
|
1106
|
+
if (this.style !== model.style)
|
|
1107
|
+
return false;
|
|
1108
|
+
return true;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
class ClusterLayerManager {
|
|
1113
|
+
settings;
|
|
1114
|
+
layer;
|
|
1115
|
+
postboy;
|
|
1116
|
+
constructor(settings, layer, postboy) {
|
|
1117
|
+
this.settings = settings;
|
|
1118
|
+
this.layer = layer;
|
|
1119
|
+
this.postboy = postboy;
|
|
1120
|
+
this.observeClick();
|
|
1121
|
+
}
|
|
1122
|
+
observeClick() {
|
|
1123
|
+
this.postboy.subscribe(MapClickEvent.ID).subscribe((m) => {
|
|
1124
|
+
if ((m.features[this.settings.name]?.length ?? 0) > 1) {
|
|
1125
|
+
this.postboy.fire(new FitToFeaturesCommand(m.features[this.settings.name], -1));
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
class ClusterLayerFactory {
|
|
1132
|
+
build(settings, postboy) {
|
|
1133
|
+
const source = new Vector({
|
|
1134
|
+
strategy: settings.bbox ? bbox : undefined,
|
|
1135
|
+
});
|
|
1136
|
+
const cluster = new Cluster({
|
|
1137
|
+
distance: settings.distance,
|
|
1138
|
+
source: source,
|
|
1139
|
+
geometryFunction: (feature) => {
|
|
1140
|
+
const geom = feature.getGeometry();
|
|
1141
|
+
if (geom?.getType() == 'Point') {
|
|
1142
|
+
return geom;
|
|
1143
|
+
}
|
|
1144
|
+
else if (geom?.getType() == 'Polygon') {
|
|
1145
|
+
return geom?.getInteriorPoint();
|
|
1146
|
+
}
|
|
1147
|
+
else if (geom?.getType() == 'MultiPolygon') {
|
|
1148
|
+
return fromExtent(geom.getExtent())?.getInteriorPoint();
|
|
1149
|
+
}
|
|
1150
|
+
return undefined;
|
|
1151
|
+
},
|
|
1152
|
+
});
|
|
1153
|
+
const layer = new Vector$1({
|
|
1154
|
+
source: cluster,
|
|
1155
|
+
maxZoom: settings.maxZoom || undefined,
|
|
1156
|
+
minZoom: settings.minZoom || undefined,
|
|
1157
|
+
zIndex: settings.zIndex || 0,
|
|
1158
|
+
});
|
|
1159
|
+
layer.setStyle(this.styleFunc(settings));
|
|
1160
|
+
layer.set('name', settings.name);
|
|
1161
|
+
return new ClusterLayerManager(settings, layer, postboy);
|
|
1162
|
+
}
|
|
1163
|
+
styleFunc(settings) {
|
|
1164
|
+
return (feature) => {
|
|
1165
|
+
const features = feature.get('features');
|
|
1166
|
+
if (!settings.style)
|
|
1167
|
+
return undefined;
|
|
1168
|
+
return settings.style(features.map((f) => ({ id: f.getId(), ...f.get(MapConstants.FeatureInfo) })));
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClusterLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1172
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClusterLayerFactory, providedIn: 'root' });
|
|
1173
|
+
}
|
|
1174
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClusterLayerFactory, decorators: [{
|
|
1175
|
+
type: Injectable,
|
|
1176
|
+
args: [{
|
|
1177
|
+
providedIn: 'root',
|
|
1178
|
+
}]
|
|
1179
|
+
}] });
|
|
1180
|
+
|
|
1181
|
+
class ClusterLayerComponent extends DestructibleComponent {
|
|
1182
|
+
postboy;
|
|
1183
|
+
factory;
|
|
1184
|
+
manager = null;
|
|
1185
|
+
_settings = new ClusterLayerSettings();
|
|
1186
|
+
constructor(postboy, factory) {
|
|
1187
|
+
super();
|
|
1188
|
+
this.postboy = postboy;
|
|
1189
|
+
this.factory = factory;
|
|
1190
|
+
}
|
|
1191
|
+
ngOnInit() {
|
|
1192
|
+
this.postboy
|
|
1193
|
+
.subscribe(MapRenderedEvent.ID)
|
|
1194
|
+
.pipe(filter((m) => !!m), first())
|
|
1195
|
+
.subscribe((m) => this.initLayer());
|
|
1196
|
+
}
|
|
1197
|
+
set settings(value) {
|
|
1198
|
+
if (!value || this._settings.isSame(value))
|
|
1199
|
+
return;
|
|
1200
|
+
this._settings = value;
|
|
1201
|
+
this.initLayer();
|
|
1202
|
+
}
|
|
1203
|
+
onDestroy = () => this.removeLayer();
|
|
1204
|
+
initLayer() {
|
|
1205
|
+
this.removeLayer();
|
|
1206
|
+
this.manager = this.factory.build(this._settings, this.postboy);
|
|
1207
|
+
this.postboy.fire(new AddLayerCommand(this.manager.layer));
|
|
1208
|
+
}
|
|
1209
|
+
removeLayer() {
|
|
1210
|
+
if (this.manager?.layer)
|
|
1211
|
+
this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
|
|
1212
|
+
}
|
|
1213
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClusterLayerComponent, deps: [{ token: MapPostboyService }, { token: ClusterLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
|
|
1214
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ClusterLayerComponent, selector: "lib-cluster-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1215
|
+
}
|
|
1216
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClusterLayerComponent, decorators: [{
|
|
1217
|
+
type: Component,
|
|
1218
|
+
args: [{ selector: 'lib-cluster-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
|
|
1219
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
|
|
1220
|
+
type: Input
|
|
1221
|
+
}] } });
|
|
1222
|
+
|
|
988
1223
|
class MapModule {
|
|
989
1224
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
990
1225
|
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: MapModule, declarations: [DestructibleComponent,
|
|
@@ -994,12 +1229,14 @@ class MapModule {
|
|
|
994
1229
|
FeatureLayerComponent,
|
|
995
1230
|
MarkersComponent,
|
|
996
1231
|
TooltipComponent,
|
|
997
|
-
PolygonsComponent
|
|
1232
|
+
PolygonsComponent,
|
|
1233
|
+
ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
|
|
998
1234
|
FeatureLayerComponent,
|
|
999
1235
|
MarkersComponent,
|
|
1000
1236
|
TileLayerComponent,
|
|
1001
1237
|
TooltipComponent,
|
|
1002
|
-
PolygonsComponent
|
|
1238
|
+
PolygonsComponent,
|
|
1239
|
+
ClusterLayerComponent] });
|
|
1003
1240
|
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapModule, imports: [CommonModule] });
|
|
1004
1241
|
}
|
|
1005
1242
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapModule, decorators: [{
|
|
@@ -1015,6 +1252,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1015
1252
|
MarkersComponent,
|
|
1016
1253
|
TooltipComponent,
|
|
1017
1254
|
PolygonsComponent,
|
|
1255
|
+
ClusterLayerComponent,
|
|
1018
1256
|
],
|
|
1019
1257
|
exports: [
|
|
1020
1258
|
MapPlateComponent,
|
|
@@ -1023,6 +1261,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1023
1261
|
TileLayerComponent,
|
|
1024
1262
|
TooltipComponent,
|
|
1025
1263
|
PolygonsComponent,
|
|
1264
|
+
ClusterLayerComponent,
|
|
1026
1265
|
],
|
|
1027
1266
|
}]
|
|
1028
1267
|
}] });
|
|
@@ -1048,6 +1287,10 @@ class MarkerStyleHelper {
|
|
|
1048
1287
|
}),
|
|
1049
1288
|
});
|
|
1050
1289
|
}
|
|
1290
|
+
static withText(style, text) {
|
|
1291
|
+
style.setText(text);
|
|
1292
|
+
return style;
|
|
1293
|
+
}
|
|
1051
1294
|
}
|
|
1052
1295
|
|
|
1053
1296
|
class PolygonStyleHelper {
|
|
@@ -1064,6 +1307,19 @@ class PolygonStyleHelper {
|
|
|
1064
1307
|
}
|
|
1065
1308
|
}
|
|
1066
1309
|
|
|
1310
|
+
class TextStyleHelper {
|
|
1311
|
+
static get(text, font, color) {
|
|
1312
|
+
return new Text({
|
|
1313
|
+
text: text,
|
|
1314
|
+
font: font,
|
|
1315
|
+
textAlign: 'center',
|
|
1316
|
+
fill: new Fill({
|
|
1317
|
+
color: color,
|
|
1318
|
+
}),
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1067
1323
|
/*
|
|
1068
1324
|
* Public API Surface of maps
|
|
1069
1325
|
*/
|
|
@@ -1076,5 +1332,5 @@ class PolygonStyleHelper {
|
|
|
1076
1332
|
* Generated bundle index. Do not edit.
|
|
1077
1333
|
*/
|
|
1078
1334
|
|
|
1079
|
-
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 };
|
|
1335
|
+
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 };
|
|
1080
1336
|
//# sourceMappingURL=maps-components.mjs.map
|