@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
|
}
|
|
@@ -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
|
|
346
|
+
var _a;
|
|
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 = source === null || source === void 0 ? void 0 : source.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: "15.2.10", 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: "15.2.10", ngImport: i0, type: MapFeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
413
|
+
MapFeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapFeatureService });
|
|
414
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", 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: "15.2.10", 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: "15.2.10", 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: "15.2.10", 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: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
426
486
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", 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) {
|
|
@@ -542,10 +602,10 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
542
602
|
}
|
|
543
603
|
}
|
|
544
604
|
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 });
|
|
545
|
-
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 });
|
|
605
|
+
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 });
|
|
546
606
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
547
607
|
type: Component,
|
|
548
|
-
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"] }]
|
|
608
|
+
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"] }]
|
|
549
609
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
550
610
|
type: Input
|
|
551
611
|
}] } });
|
|
@@ -960,6 +1020,175 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
960
1020
|
type: Input
|
|
961
1021
|
}] } });
|
|
962
1022
|
|
|
1023
|
+
class ClusterLayerSettings {
|
|
1024
|
+
constructor() {
|
|
1025
|
+
this.name = IdGenerator.get();
|
|
1026
|
+
this.zIndex = 1;
|
|
1027
|
+
this.maxZoom = 19;
|
|
1028
|
+
this.minZoom = 0;
|
|
1029
|
+
this.distance = 20;
|
|
1030
|
+
this.bbox = false;
|
|
1031
|
+
}
|
|
1032
|
+
static copy(model) {
|
|
1033
|
+
const result = new ClusterLayerSettings();
|
|
1034
|
+
result.name = model.name;
|
|
1035
|
+
result.maxZoom = model.maxZoom;
|
|
1036
|
+
result.minZoom = model.minZoom;
|
|
1037
|
+
result.zIndex = model.zIndex;
|
|
1038
|
+
result.bbox = model.bbox;
|
|
1039
|
+
result.distance = model.distance;
|
|
1040
|
+
result.style = model.style;
|
|
1041
|
+
return result;
|
|
1042
|
+
}
|
|
1043
|
+
setZIndex(zIndex) {
|
|
1044
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex }));
|
|
1045
|
+
}
|
|
1046
|
+
setDistance(distance) {
|
|
1047
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { distance }));
|
|
1048
|
+
}
|
|
1049
|
+
setName(name) {
|
|
1050
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { name }));
|
|
1051
|
+
}
|
|
1052
|
+
setMaxZoom(maxZoom) {
|
|
1053
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
|
|
1054
|
+
}
|
|
1055
|
+
setMinZoom(minZoom) {
|
|
1056
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
|
|
1057
|
+
}
|
|
1058
|
+
setBbox(bbox) {
|
|
1059
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { bbox }));
|
|
1060
|
+
}
|
|
1061
|
+
setStyle(style) {
|
|
1062
|
+
return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
|
|
1063
|
+
}
|
|
1064
|
+
isSame(model) {
|
|
1065
|
+
if (this.maxZoom !== model.maxZoom)
|
|
1066
|
+
return false;
|
|
1067
|
+
if (this.minZoom !== model.minZoom)
|
|
1068
|
+
return false;
|
|
1069
|
+
if (this.zIndex !== model.zIndex)
|
|
1070
|
+
return false;
|
|
1071
|
+
if (this.name !== model.name)
|
|
1072
|
+
return false;
|
|
1073
|
+
if (this.distance !== model.distance)
|
|
1074
|
+
return false;
|
|
1075
|
+
if (this.bbox !== model.bbox)
|
|
1076
|
+
return false;
|
|
1077
|
+
if (this.style !== model.style)
|
|
1078
|
+
return false;
|
|
1079
|
+
return true;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
class ClusterLayerManager {
|
|
1084
|
+
constructor(settings, layer, postboy) {
|
|
1085
|
+
this.settings = settings;
|
|
1086
|
+
this.layer = layer;
|
|
1087
|
+
this.postboy = postboy;
|
|
1088
|
+
this.observeClick();
|
|
1089
|
+
}
|
|
1090
|
+
observeClick() {
|
|
1091
|
+
this.postboy.subscribe(MapClickEvent.ID).subscribe((m) => {
|
|
1092
|
+
var _a, _b;
|
|
1093
|
+
if (((_b = (_a = m.features[this.settings.name]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 1) {
|
|
1094
|
+
this.postboy.fire(new FitToFeaturesCommand(m.features[this.settings.name], -1));
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
class ClusterLayerFactory {
|
|
1101
|
+
build(settings, postboy) {
|
|
1102
|
+
const source = new Vector({
|
|
1103
|
+
strategy: settings.bbox ? bbox : undefined,
|
|
1104
|
+
});
|
|
1105
|
+
const cluster = new Cluster({
|
|
1106
|
+
distance: settings.distance,
|
|
1107
|
+
source: source,
|
|
1108
|
+
geometryFunction: (feature) => {
|
|
1109
|
+
var _a;
|
|
1110
|
+
const geom = feature.getGeometry();
|
|
1111
|
+
if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Point') {
|
|
1112
|
+
return geom;
|
|
1113
|
+
}
|
|
1114
|
+
else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Polygon') {
|
|
1115
|
+
return geom === null || geom === void 0 ? void 0 : geom.getInteriorPoint();
|
|
1116
|
+
}
|
|
1117
|
+
else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'MultiPolygon') {
|
|
1118
|
+
return (_a = fromExtent(geom.getExtent())) === null || _a === void 0 ? void 0 : _a.getInteriorPoint();
|
|
1119
|
+
}
|
|
1120
|
+
return undefined;
|
|
1121
|
+
},
|
|
1122
|
+
});
|
|
1123
|
+
const layer = new Vector$1({
|
|
1124
|
+
source: cluster,
|
|
1125
|
+
maxZoom: settings.maxZoom || undefined,
|
|
1126
|
+
minZoom: settings.minZoom || undefined,
|
|
1127
|
+
zIndex: settings.zIndex || 0,
|
|
1128
|
+
});
|
|
1129
|
+
layer.setStyle(this.styleFunc(settings));
|
|
1130
|
+
layer.set('name', settings.name);
|
|
1131
|
+
return new ClusterLayerManager(settings, layer, postboy);
|
|
1132
|
+
}
|
|
1133
|
+
styleFunc(settings) {
|
|
1134
|
+
return (feature) => {
|
|
1135
|
+
const features = feature.get('features');
|
|
1136
|
+
if (!settings.style)
|
|
1137
|
+
return undefined;
|
|
1138
|
+
return settings.style(features.map((f) => (Object.assign({ id: f.getId() }, f.get(MapConstants.FeatureInfo)))));
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
ClusterLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1143
|
+
ClusterLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, providedIn: 'root' });
|
|
1144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, decorators: [{
|
|
1145
|
+
type: Injectable,
|
|
1146
|
+
args: [{
|
|
1147
|
+
providedIn: 'root',
|
|
1148
|
+
}]
|
|
1149
|
+
}] });
|
|
1150
|
+
|
|
1151
|
+
class ClusterLayerComponent extends DestructibleComponent {
|
|
1152
|
+
constructor(postboy, factory) {
|
|
1153
|
+
super();
|
|
1154
|
+
this.postboy = postboy;
|
|
1155
|
+
this.factory = factory;
|
|
1156
|
+
this.manager = null;
|
|
1157
|
+
this._settings = new ClusterLayerSettings();
|
|
1158
|
+
this.onDestroy = () => this.removeLayer();
|
|
1159
|
+
}
|
|
1160
|
+
ngOnInit() {
|
|
1161
|
+
this.postboy
|
|
1162
|
+
.subscribe(MapRenderedEvent.ID)
|
|
1163
|
+
.pipe(filter((m) => !!m), first())
|
|
1164
|
+
.subscribe((m) => this.initLayer());
|
|
1165
|
+
}
|
|
1166
|
+
set settings(value) {
|
|
1167
|
+
if (!value || this._settings.isSame(value))
|
|
1168
|
+
return;
|
|
1169
|
+
this._settings = value;
|
|
1170
|
+
this.initLayer();
|
|
1171
|
+
}
|
|
1172
|
+
initLayer() {
|
|
1173
|
+
this.removeLayer();
|
|
1174
|
+
this.manager = this.factory.build(this._settings, this.postboy);
|
|
1175
|
+
this.postboy.fire(new AddLayerCommand(this.manager.layer));
|
|
1176
|
+
}
|
|
1177
|
+
removeLayer() {
|
|
1178
|
+
var _a;
|
|
1179
|
+
if ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.layer)
|
|
1180
|
+
this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
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 });
|
|
1184
|
+
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 });
|
|
1185
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerComponent, decorators: [{
|
|
1186
|
+
type: Component,
|
|
1187
|
+
args: [{ selector: 'lib-cluster-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
|
|
1188
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
|
|
1189
|
+
type: Input
|
|
1190
|
+
}] } });
|
|
1191
|
+
|
|
963
1192
|
class MapModule {
|
|
964
1193
|
}
|
|
965
1194
|
MapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -970,12 +1199,14 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
|
|
|
970
1199
|
FeatureLayerComponent,
|
|
971
1200
|
MarkersComponent,
|
|
972
1201
|
TooltipComponent,
|
|
973
|
-
PolygonsComponent
|
|
1202
|
+
PolygonsComponent,
|
|
1203
|
+
ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
|
|
974
1204
|
FeatureLayerComponent,
|
|
975
1205
|
MarkersComponent,
|
|
976
1206
|
TileLayerComponent,
|
|
977
1207
|
TooltipComponent,
|
|
978
|
-
PolygonsComponent
|
|
1208
|
+
PolygonsComponent,
|
|
1209
|
+
ClusterLayerComponent] });
|
|
979
1210
|
MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
|
|
980
1211
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
|
|
981
1212
|
type: NgModule,
|
|
@@ -990,6 +1221,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
990
1221
|
MarkersComponent,
|
|
991
1222
|
TooltipComponent,
|
|
992
1223
|
PolygonsComponent,
|
|
1224
|
+
ClusterLayerComponent,
|
|
993
1225
|
],
|
|
994
1226
|
exports: [
|
|
995
1227
|
MapPlateComponent,
|
|
@@ -998,6 +1230,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
998
1230
|
TileLayerComponent,
|
|
999
1231
|
TooltipComponent,
|
|
1000
1232
|
PolygonsComponent,
|
|
1233
|
+
ClusterLayerComponent,
|
|
1001
1234
|
],
|
|
1002
1235
|
}]
|
|
1003
1236
|
}] });
|
|
@@ -1023,6 +1256,10 @@ class MarkerStyleHelper {
|
|
|
1023
1256
|
}),
|
|
1024
1257
|
});
|
|
1025
1258
|
}
|
|
1259
|
+
static withText(style, text) {
|
|
1260
|
+
style.setText(text);
|
|
1261
|
+
return style;
|
|
1262
|
+
}
|
|
1026
1263
|
}
|
|
1027
1264
|
|
|
1028
1265
|
class PolygonStyleHelper {
|
|
@@ -1039,6 +1276,19 @@ class PolygonStyleHelper {
|
|
|
1039
1276
|
}
|
|
1040
1277
|
}
|
|
1041
1278
|
|
|
1279
|
+
class TextStyleHelper {
|
|
1280
|
+
static get(text, font, color) {
|
|
1281
|
+
return new Text({
|
|
1282
|
+
text: text,
|
|
1283
|
+
font: font,
|
|
1284
|
+
textAlign: 'center',
|
|
1285
|
+
fill: new Fill({
|
|
1286
|
+
color: color,
|
|
1287
|
+
}),
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1042
1292
|
/*
|
|
1043
1293
|
* Public API Surface of maps
|
|
1044
1294
|
*/
|
|
@@ -1051,5 +1301,5 @@ class PolygonStyleHelper {
|
|
|
1051
1301
|
* Generated bundle index. Do not edit.
|
|
1052
1302
|
*/
|
|
1053
1303
|
|
|
1054
|
-
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 };
|
|
1304
|
+
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 };
|
|
1055
1305
|
//# sourceMappingURL=maps-components.mjs.map
|