@artstesh/maps 1.0.6 → 1.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/bundles/maps-components-src-map.umd.js +306 -19
- package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
- package/dist/bundles/maps-components.umd.js +306 -19
- package/dist/bundles/maps-components.umd.js.map +1 -1
- package/dist/esm2015/map/helpers/index.js +2 -1
- package/dist/esm2015/map/helpers/marker-style.helper.js +5 -1
- package/dist/esm2015/map/helpers/text-style.helper.js +14 -0
- package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.js +60 -0
- package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.component.js +56 -0
- package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.manager.js +19 -0
- package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.settings.js +61 -0
- package/dist/esm2015/map/map-plate/layers/index.js +3 -1
- package/dist/esm2015/map/map-plate/map-plate.component.js +4 -3
- package/dist/esm2015/map/map.module.js +8 -3
- package/dist/esm2015/map/messages/commands/add-layer.command.js +1 -1
- package/dist/esm2015/map/messages/commands/fit-to-features.command.js +13 -0
- package/dist/esm2015/map/messages/events/map-click.event.js +3 -2
- package/dist/esm2015/map/models/i-identified.js +2 -0
- package/dist/esm2015/map/models/map.constants.js +4 -0
- package/dist/esm2015/map/models/marker-model.js +3 -2
- package/dist/esm2015/map/services/map-click.service.js +7 -3
- package/dist/esm2015/map/services/map-feature.service.js +39 -0
- package/dist/esm2015/map/services/map-management.service.js +7 -4
- package/dist/esm2015/map/services/message-registrator.service.js +9 -6
- package/dist/esm2015/src/map/helpers/index.js +2 -1
- package/dist/esm2015/src/map/helpers/marker-style.helper.js +5 -1
- package/dist/esm2015/src/map/helpers/text-style.helper.js +14 -0
- package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.js +60 -0
- package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.component.js +56 -0
- package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.js +19 -0
- package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.js +61 -0
- package/dist/esm2015/src/map/map-plate/layers/index.js +3 -1
- package/dist/esm2015/src/map/map-plate/map-plate.component.js +4 -3
- package/dist/esm2015/src/map/map.module.js +8 -3
- package/dist/esm2015/src/map/messages/commands/add-layer.command.js +1 -1
- package/dist/esm2015/src/map/messages/commands/fit-to-features.command.js +13 -0
- package/dist/esm2015/src/map/messages/events/map-click.event.js +3 -2
- package/dist/esm2015/src/map/models/i-identified.js +2 -0
- package/dist/esm2015/src/map/models/map.constants.js +4 -0
- package/dist/esm2015/src/map/models/marker-model.js +3 -2
- package/dist/esm2015/src/map/services/map-click.service.js +7 -3
- package/dist/esm2015/src/map/services/map-feature.service.js +39 -0
- package/dist/esm2015/src/map/services/map-management.service.js +7 -4
- package/dist/esm2015/src/map/services/message-registrator.service.js +9 -6
- package/dist/fesm2015/maps-components-src-map.js +273 -18
- package/dist/fesm2015/maps-components-src-map.js.map +1 -1
- package/dist/fesm2015/maps-components.js +273 -18
- package/dist/fesm2015/maps-components.js.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
|
}
|
|
@@ -191,10 +198,11 @@ class MapRenderedEvent extends GenericMessage {
|
|
|
191
198
|
MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
|
|
192
199
|
|
|
193
200
|
class MapClickEvent extends GenericMessage {
|
|
194
|
-
constructor(coordinates, entities) {
|
|
201
|
+
constructor(coordinates, entities, features) {
|
|
195
202
|
super();
|
|
196
203
|
this.coordinates = coordinates;
|
|
197
204
|
this.entities = entities;
|
|
205
|
+
this.features = features;
|
|
198
206
|
}
|
|
199
207
|
get id() {
|
|
200
208
|
return MapClickEvent.ID;
|
|
@@ -269,6 +277,18 @@ class RemoveTileCommand extends GenericMessage {
|
|
|
269
277
|
}
|
|
270
278
|
RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
|
|
271
279
|
|
|
280
|
+
class FitToFeaturesCommand extends GenericMessage {
|
|
281
|
+
constructor(features, zoomAfter = 0) {
|
|
282
|
+
super();
|
|
283
|
+
this.features = features;
|
|
284
|
+
this.zoomAfter = zoomAfter;
|
|
285
|
+
}
|
|
286
|
+
get id() {
|
|
287
|
+
return FitToFeaturesCommand.ID;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
FitToFeaturesCommand.ID = '76cdc091-3793-4b6c-82f7-1e0334cf08a8';
|
|
291
|
+
|
|
272
292
|
class MapPostboyService extends PostboyService {
|
|
273
293
|
constructor() {
|
|
274
294
|
super(...arguments);
|
|
@@ -323,11 +343,14 @@ class MapManagementService {
|
|
|
323
343
|
}
|
|
324
344
|
observePlaceFeatures() {
|
|
325
345
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
326
|
-
var _a, _b
|
|
346
|
+
var _a, _b;
|
|
327
347
|
if (!this.layers[c.layer])
|
|
328
348
|
return;
|
|
329
|
-
|
|
330
|
-
(
|
|
349
|
+
let source = (_a = this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource();
|
|
350
|
+
if (!!source['getSource'])
|
|
351
|
+
source = (_b = source) === null || _b === void 0 ? void 0 : _b.getSource();
|
|
352
|
+
source === null || source === void 0 ? void 0 : source.clear();
|
|
353
|
+
source === null || source === void 0 ? void 0 : source.addFeatures(c.features);
|
|
331
354
|
});
|
|
332
355
|
}
|
|
333
356
|
observeRemoveLayer() {
|
|
@@ -359,6 +382,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
359
382
|
type: Injectable
|
|
360
383
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
361
384
|
|
|
385
|
+
class MapFeatureService {
|
|
386
|
+
constructor(postboy) {
|
|
387
|
+
this.postboy = postboy;
|
|
388
|
+
}
|
|
389
|
+
up() {
|
|
390
|
+
this.observeMapRender();
|
|
391
|
+
this.observeFitToFeatures();
|
|
392
|
+
}
|
|
393
|
+
observeMapRender() {
|
|
394
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
395
|
+
this.map = m.map;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
observeFitToFeatures() {
|
|
399
|
+
this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((m) => {
|
|
400
|
+
this.fitToGeometries(m.features.map((f) => f.getGeometry()), m.zoomAfter);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
fitToGeometries(geometries, zoomAfter) {
|
|
404
|
+
if (!(geometries === null || geometries === void 0 ? void 0 : geometries.length) || !this.map)
|
|
405
|
+
return;
|
|
406
|
+
const extent = createEmpty();
|
|
407
|
+
geometries.forEach((g) => extend(extent, g.getExtent()));
|
|
408
|
+
this.map.getView().fit(extent);
|
|
409
|
+
this.map.getView().setZoom(this.map.getView().getZoom() + zoomAfter);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
MapFeatureService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapFeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
413
|
+
MapFeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapFeatureService });
|
|
414
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapFeatureService, decorators: [{
|
|
415
|
+
type: Injectable
|
|
416
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
417
|
+
|
|
362
418
|
class MapClickService {
|
|
363
419
|
constructor(postboy) {
|
|
364
420
|
this.postboy = postboy;
|
|
@@ -377,7 +433,7 @@ class MapClickService {
|
|
|
377
433
|
}
|
|
378
434
|
onClick(ev) {
|
|
379
435
|
var _a;
|
|
380
|
-
const model = new MapClickEvent(ev.coordinate, {});
|
|
436
|
+
const model = new MapClickEvent(ev.coordinate, {}, {});
|
|
381
437
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.forEachFeatureAtPixel(ev.pixel, (f, l) => {
|
|
382
438
|
this.getFeatureCollectionWithInner([f])
|
|
383
439
|
.filter((f) => f.getId() != null)
|
|
@@ -385,7 +441,10 @@ class MapClickService {
|
|
|
385
441
|
let layerName = l.get('name');
|
|
386
442
|
if (!model.entities[layerName])
|
|
387
443
|
model.entities[layerName] = [];
|
|
388
|
-
model.
|
|
444
|
+
if (!model.features[layerName])
|
|
445
|
+
model.features[layerName] = [];
|
|
446
|
+
model.entities[layerName].push(Object.assign({ id: fs.getId() }, fs.get(MapConstants.FeatureInfo)));
|
|
447
|
+
model.features[layerName].push(fs);
|
|
389
448
|
});
|
|
390
449
|
});
|
|
391
450
|
return model;
|
|
@@ -406,9 +465,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
406
465
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
407
466
|
|
|
408
467
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
409
|
-
constructor(service, management, state, interaction) {
|
|
468
|
+
constructor(service, management, state, feature, interaction) {
|
|
410
469
|
super(service);
|
|
411
|
-
this.registerServices([management, state, interaction]);
|
|
470
|
+
this.registerServices([management, state, interaction, feature]);
|
|
412
471
|
}
|
|
413
472
|
_up() {
|
|
414
473
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -419,13 +478,14 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
419
478
|
this.registerSubject(RemoveTileCommand.ID);
|
|
420
479
|
this.registerSubject(MapClickEvent.ID);
|
|
421
480
|
this.registerSubject(CloseTooltipCommand.ID);
|
|
481
|
+
this.registerSubject(FitToFeaturesCommand.ID);
|
|
422
482
|
}
|
|
423
483
|
}
|
|
424
|
-
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
484
|
+
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
425
485
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService });
|
|
426
486
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
427
487
|
type: Injectable
|
|
428
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapClickService }]; } });
|
|
488
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }]; } });
|
|
429
489
|
|
|
430
490
|
class MapPlateFactory {
|
|
431
491
|
build(settings) {
|
|
@@ -547,7 +607,7 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
547
607
|
}
|
|
548
608
|
}
|
|
549
609
|
MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
550
|
-
MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", 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"], components: [{ type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
610
|
+
MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", 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"], components: [{ type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
551
611
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
552
612
|
type: Component,
|
|
553
613
|
args: [{
|
|
@@ -555,7 +615,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
555
615
|
templateUrl: './map-plate.component.html',
|
|
556
616
|
styleUrls: ['./map-plate.component.scss'],
|
|
557
617
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
558
|
-
providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService],
|
|
618
|
+
providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService, MapFeatureService],
|
|
559
619
|
}]
|
|
560
620
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
561
621
|
type: Input
|
|
@@ -996,6 +1056,180 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
996
1056
|
type: Input
|
|
997
1057
|
}] } });
|
|
998
1058
|
|
|
1059
|
+
class ClusterLayerSettings {
|
|
1060
|
+
constructor() {
|
|
1061
|
+
this.name = IdGenerator.get();
|
|
1062
|
+
this.zIndex = 1;
|
|
1063
|
+
this.maxZoom = 19;
|
|
1064
|
+
this.minZoom = 0;
|
|
1065
|
+
this.distance = 20;
|
|
1066
|
+
this.bbox = false;
|
|
1067
|
+
}
|
|
1068
|
+
static copy(model) {
|
|
1069
|
+
const result = new ClusterLayerSettings();
|
|
1070
|
+
result.name = model.name;
|
|
1071
|
+
result.maxZoom = model.maxZoom;
|
|
1072
|
+
result.minZoom = model.minZoom;
|
|
1073
|
+
result.zIndex = model.zIndex;
|
|
1074
|
+
result.bbox = model.bbox;
|
|
1075
|
+
result.distance = model.distance;
|
|
1076
|
+
result.style = model.style;
|
|
1077
|
+
return result;
|
|
1078
|
+
}
|
|
1079
|
+
setZIndex(zIndex) {
|
|
1080
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex }));
|
|
1081
|
+
}
|
|
1082
|
+
setDistance(distance) {
|
|
1083
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { distance }));
|
|
1084
|
+
}
|
|
1085
|
+
setName(name) {
|
|
1086
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { name }));
|
|
1087
|
+
}
|
|
1088
|
+
setMaxZoom(maxZoom) {
|
|
1089
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
|
|
1090
|
+
}
|
|
1091
|
+
setMinZoom(minZoom) {
|
|
1092
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
|
|
1093
|
+
}
|
|
1094
|
+
setBbox(bbox) {
|
|
1095
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { bbox }));
|
|
1096
|
+
}
|
|
1097
|
+
setStyle(style) {
|
|
1098
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
|
|
1099
|
+
}
|
|
1100
|
+
isSame(model) {
|
|
1101
|
+
if (this.maxZoom !== model.maxZoom)
|
|
1102
|
+
return false;
|
|
1103
|
+
if (this.minZoom !== model.minZoom)
|
|
1104
|
+
return false;
|
|
1105
|
+
if (this.zIndex !== model.zIndex)
|
|
1106
|
+
return false;
|
|
1107
|
+
if (this.name !== model.name)
|
|
1108
|
+
return false;
|
|
1109
|
+
if (this.distance !== model.distance)
|
|
1110
|
+
return false;
|
|
1111
|
+
if (this.bbox !== model.bbox)
|
|
1112
|
+
return false;
|
|
1113
|
+
if (this.style !== model.style)
|
|
1114
|
+
return false;
|
|
1115
|
+
return true;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
class ClusterLayerManager {
|
|
1120
|
+
constructor(settings, layer, postboy) {
|
|
1121
|
+
this.settings = settings;
|
|
1122
|
+
this.layer = layer;
|
|
1123
|
+
this.postboy = postboy;
|
|
1124
|
+
this.observeClick();
|
|
1125
|
+
}
|
|
1126
|
+
observeClick() {
|
|
1127
|
+
this.postboy.subscribe(MapClickEvent.ID).subscribe((m) => {
|
|
1128
|
+
var _a, _b;
|
|
1129
|
+
if (((_b = (_a = m.features[this.settings.name]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 1) {
|
|
1130
|
+
this.postboy.fire(new FitToFeaturesCommand(m.features[this.settings.name], -1));
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
class ClusterLayerFactory {
|
|
1137
|
+
build(settings, postboy) {
|
|
1138
|
+
const source = new Vector({
|
|
1139
|
+
strategy: settings.bbox ? bbox : undefined,
|
|
1140
|
+
});
|
|
1141
|
+
const cluster = new Cluster({
|
|
1142
|
+
distance: settings.distance,
|
|
1143
|
+
source: source,
|
|
1144
|
+
geometryFunction: (feature) => {
|
|
1145
|
+
var _a, _b;
|
|
1146
|
+
const geom = feature.getGeometry();
|
|
1147
|
+
if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Point') {
|
|
1148
|
+
return geom;
|
|
1149
|
+
}
|
|
1150
|
+
else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Polygon') {
|
|
1151
|
+
return (_a = geom) === null || _a === void 0 ? void 0 : _a.getInteriorPoint();
|
|
1152
|
+
}
|
|
1153
|
+
else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'MultiPolygon') {
|
|
1154
|
+
return (_b = fromExtent(geom.getExtent())) === null || _b === void 0 ? void 0 : _b.getInteriorPoint();
|
|
1155
|
+
}
|
|
1156
|
+
return undefined;
|
|
1157
|
+
},
|
|
1158
|
+
});
|
|
1159
|
+
const layer = new Vector$1({
|
|
1160
|
+
source: cluster,
|
|
1161
|
+
maxZoom: settings.maxZoom || undefined,
|
|
1162
|
+
minZoom: settings.minZoom || undefined,
|
|
1163
|
+
zIndex: settings.zIndex || 0,
|
|
1164
|
+
});
|
|
1165
|
+
layer.setStyle(this.styleFunc(settings));
|
|
1166
|
+
layer.set('name', settings.name);
|
|
1167
|
+
return new ClusterLayerManager(settings, layer, postboy);
|
|
1168
|
+
}
|
|
1169
|
+
styleFunc(settings) {
|
|
1170
|
+
return (feature) => {
|
|
1171
|
+
const features = feature.get('features');
|
|
1172
|
+
if (!settings.style)
|
|
1173
|
+
return undefined;
|
|
1174
|
+
return settings.style(features.map((f) => (Object.assign({ id: f.getId() }, f.get(MapConstants.FeatureInfo)))));
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
ClusterLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1179
|
+
ClusterLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerFactory, providedIn: 'root' });
|
|
1180
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerFactory, decorators: [{
|
|
1181
|
+
type: Injectable,
|
|
1182
|
+
args: [{
|
|
1183
|
+
providedIn: 'root',
|
|
1184
|
+
}]
|
|
1185
|
+
}] });
|
|
1186
|
+
|
|
1187
|
+
class ClusterLayerComponent extends DestructibleComponent {
|
|
1188
|
+
constructor(postboy, factory) {
|
|
1189
|
+
super();
|
|
1190
|
+
this.postboy = postboy;
|
|
1191
|
+
this.factory = factory;
|
|
1192
|
+
this.manager = null;
|
|
1193
|
+
this._settings = new ClusterLayerSettings();
|
|
1194
|
+
this.onDestroy = () => this.removeLayer();
|
|
1195
|
+
}
|
|
1196
|
+
ngOnInit() {
|
|
1197
|
+
this.postboy
|
|
1198
|
+
.subscribe(MapRenderedEvent.ID)
|
|
1199
|
+
.pipe(filter((m) => !!m), first())
|
|
1200
|
+
.subscribe((m) => this.initLayer());
|
|
1201
|
+
}
|
|
1202
|
+
set settings(value) {
|
|
1203
|
+
if (!value || this._settings.isSame(value))
|
|
1204
|
+
return;
|
|
1205
|
+
this._settings = value;
|
|
1206
|
+
this.initLayer();
|
|
1207
|
+
}
|
|
1208
|
+
initLayer() {
|
|
1209
|
+
this.removeLayer();
|
|
1210
|
+
this.manager = this.factory.build(this._settings, this.postboy);
|
|
1211
|
+
this.postboy.fire(new AddLayerCommand(this.manager.layer));
|
|
1212
|
+
}
|
|
1213
|
+
removeLayer() {
|
|
1214
|
+
var _a;
|
|
1215
|
+
if ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.layer)
|
|
1216
|
+
this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
ClusterLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerComponent, deps: [{ token: MapPostboyService }, { token: ClusterLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
|
|
1220
|
+
ClusterLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ClusterLayerComponent, selector: "lib-cluster-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1221
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerComponent, decorators: [{
|
|
1222
|
+
type: Component,
|
|
1223
|
+
args: [{
|
|
1224
|
+
selector: 'lib-cluster-layer',
|
|
1225
|
+
template: '',
|
|
1226
|
+
styleUrls: [],
|
|
1227
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1228
|
+
}]
|
|
1229
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
|
|
1230
|
+
type: Input
|
|
1231
|
+
}] } });
|
|
1232
|
+
|
|
999
1233
|
class MapModule {
|
|
1000
1234
|
}
|
|
1001
1235
|
MapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -1006,12 +1240,14 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.
|
|
|
1006
1240
|
FeatureLayerComponent,
|
|
1007
1241
|
MarkersComponent,
|
|
1008
1242
|
TooltipComponent,
|
|
1009
|
-
PolygonsComponent
|
|
1243
|
+
PolygonsComponent,
|
|
1244
|
+
ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
|
|
1010
1245
|
FeatureLayerComponent,
|
|
1011
1246
|
MarkersComponent,
|
|
1012
1247
|
TileLayerComponent,
|
|
1013
1248
|
TooltipComponent,
|
|
1014
|
-
PolygonsComponent
|
|
1249
|
+
PolygonsComponent,
|
|
1250
|
+
ClusterLayerComponent] });
|
|
1015
1251
|
MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, imports: [[CommonModule]] });
|
|
1016
1252
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, decorators: [{
|
|
1017
1253
|
type: NgModule,
|
|
@@ -1026,6 +1262,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
1026
1262
|
MarkersComponent,
|
|
1027
1263
|
TooltipComponent,
|
|
1028
1264
|
PolygonsComponent,
|
|
1265
|
+
ClusterLayerComponent,
|
|
1029
1266
|
],
|
|
1030
1267
|
exports: [
|
|
1031
1268
|
MapPlateComponent,
|
|
@@ -1034,6 +1271,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
1034
1271
|
TileLayerComponent,
|
|
1035
1272
|
TooltipComponent,
|
|
1036
1273
|
PolygonsComponent,
|
|
1274
|
+
ClusterLayerComponent,
|
|
1037
1275
|
],
|
|
1038
1276
|
}]
|
|
1039
1277
|
}] });
|
|
@@ -1059,6 +1297,10 @@ class MarkerStyleHelper {
|
|
|
1059
1297
|
}),
|
|
1060
1298
|
});
|
|
1061
1299
|
}
|
|
1300
|
+
static withText(style, text) {
|
|
1301
|
+
style.setText(text);
|
|
1302
|
+
return style;
|
|
1303
|
+
}
|
|
1062
1304
|
}
|
|
1063
1305
|
|
|
1064
1306
|
class PolygonStyleHelper {
|
|
@@ -1075,6 +1317,19 @@ class PolygonStyleHelper {
|
|
|
1075
1317
|
}
|
|
1076
1318
|
}
|
|
1077
1319
|
|
|
1320
|
+
class TextStyleHelper {
|
|
1321
|
+
static get(text, font, color) {
|
|
1322
|
+
return new Text({
|
|
1323
|
+
text: text,
|
|
1324
|
+
font: font,
|
|
1325
|
+
textAlign: 'center',
|
|
1326
|
+
fill: new Fill({
|
|
1327
|
+
color: color,
|
|
1328
|
+
}),
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1078
1333
|
/*
|
|
1079
1334
|
* Public API Surface of maps
|
|
1080
1335
|
*/
|
|
@@ -1083,5 +1338,5 @@ class PolygonStyleHelper {
|
|
|
1083
1338
|
* Generated bundle index. Do not edit.
|
|
1084
1339
|
*/
|
|
1085
1340
|
|
|
1086
|
-
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 };
|
|
1341
|
+
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 };
|
|
1087
1342
|
//# sourceMappingURL=maps-components-src-map.js.map
|