@artstesh/maps 5.0.5 → 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 +3 -1
- package/dist/esm2022/map/helpers/marker-style.helper.mjs +5 -1
- package/dist/esm2022/map/helpers/polygon-style.helper.mjs +16 -0
- package/dist/esm2022/map/helpers/text-style.helper.mjs +14 -0
- package/dist/esm2022/map/map-plate/features/index.mjs +2 -1
- package/dist/esm2022/map/map-plate/features/polygons/polygons.component.mjs +42 -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 +23 -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/index.mjs +2 -1
- package/dist/esm2022/map/models/map.constants.mjs +4 -0
- package/dist/esm2022/map/models/marker-model.mjs +3 -2
- package/dist/esm2022/map/models/polygon.model.mjs +30 -0
- 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 +3 -1
- package/dist/esm2022/src/map/helpers/marker-style.helper.mjs +5 -1
- package/dist/esm2022/src/map/helpers/polygon-style.helper.mjs +16 -0
- package/dist/esm2022/src/map/helpers/text-style.helper.mjs +14 -0
- package/dist/esm2022/src/map/map-plate/features/index.mjs +2 -1
- package/dist/esm2022/src/map/map-plate/features/polygons/polygons.component.mjs +42 -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 +23 -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/index.mjs +2 -1
- 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/models/polygon.model.mjs +30 -0
- 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 +364 -16
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +364 -16
- package/dist/fesm2022/maps-components.mjs.map +1 -1
- package/dist/map/helpers/index.d.ts +2 -0
- package/dist/map/helpers/marker-style.helper.d.ts +2 -0
- package/dist/map/helpers/polygon-style.helper.d.ts +4 -0
- package/dist/map/helpers/text-style.helper.d.ts +4 -0
- package/dist/map/map-plate/features/index.d.ts +1 -0
- package/dist/map/map-plate/features/polygons/polygons.component.d.ts +16 -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 +4 -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/index.d.ts +1 -0
- package/dist/map/models/map.constants.d.ts +3 -0
- package/dist/map/models/polygon.model.d.ts +19 -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 +2 -0
- package/dist/src/map/helpers/marker-style.helper.d.ts +2 -0
- package/dist/src/map/helpers/polygon-style.helper.d.ts +4 -0
- package/dist/src/map/helpers/text-style.helper.d.ts +4 -0
- package/dist/src/map/map-plate/features/index.d.ts +1 -0
- package/dist/src/map/map-plate/features/polygons/polygons.component.d.ts +16 -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 +4 -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/index.d.ts +1 -0
- package/dist/src/map/models/map.constants.d.ts +3 -0
- package/dist/src/map/models/polygon.model.d.ts +19 -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
|
@@ -4,6 +4,8 @@ import * as i4 from '@angular/common';
|
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { Feature } from 'ol';
|
|
6
6
|
import { Point } from 'ol/geom';
|
|
7
|
+
import { GeoJSON, WKT } from 'ol/format';
|
|
8
|
+
import { getCenter, createEmpty, extend } from 'ol/extent';
|
|
7
9
|
import { useGeographic, get } from 'ol/proj';
|
|
8
10
|
import { Subject } from 'rxjs';
|
|
9
11
|
import { PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
@@ -15,8 +17,11 @@ import { filter, first } from 'rxjs/operators';
|
|
|
15
17
|
import { XYZ, Vector } from 'ol/source';
|
|
16
18
|
import { Vector as Vector$1 } from 'ol/layer';
|
|
17
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';
|
|
18
23
|
import Style from 'ol/style/Style';
|
|
19
|
-
import { Icon, Circle, Fill, Stroke } from 'ol/style';
|
|
24
|
+
import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
|
|
20
25
|
|
|
21
26
|
class DestructibleComponent {
|
|
22
27
|
subs = [];
|
|
@@ -117,6 +122,10 @@ class IdGenerator {
|
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
|
|
125
|
+
class MapConstants {
|
|
126
|
+
static FeatureInfo = 'f-info';
|
|
127
|
+
}
|
|
128
|
+
|
|
120
129
|
class MarkerModel {
|
|
121
130
|
lat;
|
|
122
131
|
lng;
|
|
@@ -137,11 +146,38 @@ class MarkerModel {
|
|
|
137
146
|
const feature = new Feature(new Point([this.lng, this.lat]));
|
|
138
147
|
feature.setId(this.id);
|
|
139
148
|
if (this.info)
|
|
140
|
-
feature.set(
|
|
149
|
+
feature.set(MapConstants.FeatureInfo, this.info);
|
|
141
150
|
return feature;
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
153
|
|
|
154
|
+
class PolygonModel {
|
|
155
|
+
info;
|
|
156
|
+
id;
|
|
157
|
+
lat;
|
|
158
|
+
lng;
|
|
159
|
+
_feature;
|
|
160
|
+
static fromGeoJson(id, json, info) {
|
|
161
|
+
let feature = new GeoJSON().readFeature(json);
|
|
162
|
+
feature.setId(id);
|
|
163
|
+
return new PolygonModel(feature, id, info);
|
|
164
|
+
}
|
|
165
|
+
static fromWKT(id, wkt, info) {
|
|
166
|
+
let feature = new WKT().readFeature(wkt);
|
|
167
|
+
feature.setId(id);
|
|
168
|
+
return new PolygonModel(feature, id, info);
|
|
169
|
+
}
|
|
170
|
+
constructor(feature, id, info) {
|
|
171
|
+
this.info = info;
|
|
172
|
+
this.id = id == null ? IdGenerator.get() : id;
|
|
173
|
+
this._feature = feature;
|
|
174
|
+
[this.lng, this.lat] = getCenter(this._feature.getGeometry()?.getExtent());
|
|
175
|
+
}
|
|
176
|
+
get feature() {
|
|
177
|
+
return this._feature;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
145
181
|
class GenericMessage {
|
|
146
182
|
}
|
|
147
183
|
class CallbackMessage extends GenericMessage {
|
|
@@ -168,11 +204,13 @@ class MapRenderedEvent extends GenericMessage {
|
|
|
168
204
|
class MapClickEvent extends GenericMessage {
|
|
169
205
|
coordinates;
|
|
170
206
|
entities;
|
|
207
|
+
features;
|
|
171
208
|
static ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
|
|
172
|
-
constructor(coordinates, entities) {
|
|
209
|
+
constructor(coordinates, entities, features) {
|
|
173
210
|
super();
|
|
174
211
|
this.coordinates = coordinates;
|
|
175
212
|
this.entities = entities;
|
|
213
|
+
this.features = features;
|
|
176
214
|
}
|
|
177
215
|
get id() {
|
|
178
216
|
return MapClickEvent.ID;
|
|
@@ -253,6 +291,20 @@ class RemoveTileCommand extends GenericMessage {
|
|
|
253
291
|
}
|
|
254
292
|
}
|
|
255
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
|
+
|
|
256
308
|
class MapPostboyService extends PostboyService {
|
|
257
309
|
observe = (id) => this.subscribe(id);
|
|
258
310
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPostboyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -308,8 +360,11 @@ class MapManagementService {
|
|
|
308
360
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
309
361
|
if (!this.layers[c.layer])
|
|
310
362
|
return;
|
|
311
|
-
this.layers[c.layer]?.getSource()
|
|
312
|
-
|
|
363
|
+
let source = this.layers[c.layer]?.getSource();
|
|
364
|
+
if (!!source['getSource'])
|
|
365
|
+
source = source?.getSource();
|
|
366
|
+
source?.clear();
|
|
367
|
+
source?.addFeatures(c.features);
|
|
313
368
|
});
|
|
314
369
|
}
|
|
315
370
|
observeRemoveLayer() {
|
|
@@ -343,6 +398,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
343
398
|
type: Injectable
|
|
344
399
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
345
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
|
+
|
|
346
436
|
class MapClickService {
|
|
347
437
|
postboy;
|
|
348
438
|
map;
|
|
@@ -361,7 +451,7 @@ class MapClickService {
|
|
|
361
451
|
});
|
|
362
452
|
}
|
|
363
453
|
onClick(ev) {
|
|
364
|
-
const model = new MapClickEvent(ev.coordinate, {});
|
|
454
|
+
const model = new MapClickEvent(ev.coordinate, {}, {});
|
|
365
455
|
this.map?.forEachFeatureAtPixel(ev.pixel, (f, l) => {
|
|
366
456
|
this.getFeatureCollectionWithInner([f])
|
|
367
457
|
.filter((f) => f.getId() != null)
|
|
@@ -369,7 +459,10 @@ class MapClickService {
|
|
|
369
459
|
let layerName = l.get('name');
|
|
370
460
|
if (!model.entities[layerName])
|
|
371
461
|
model.entities[layerName] = [];
|
|
372
|
-
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);
|
|
373
466
|
});
|
|
374
467
|
});
|
|
375
468
|
return model;
|
|
@@ -390,9 +483,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
390
483
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
391
484
|
|
|
392
485
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
393
|
-
constructor(service, management, state, interaction) {
|
|
486
|
+
constructor(service, management, state, feature, interaction) {
|
|
394
487
|
super(service);
|
|
395
|
-
this.registerServices([management, state, interaction]);
|
|
488
|
+
this.registerServices([management, state, interaction, feature]);
|
|
396
489
|
}
|
|
397
490
|
_up() {
|
|
398
491
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -403,13 +496,14 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
403
496
|
this.registerSubject(RemoveTileCommand.ID);
|
|
404
497
|
this.registerSubject(MapClickEvent.ID);
|
|
405
498
|
this.registerSubject(CloseTooltipCommand.ID);
|
|
499
|
+
this.registerSubject(FitToFeaturesCommand.ID);
|
|
406
500
|
}
|
|
407
|
-
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 });
|
|
408
502
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService });
|
|
409
503
|
}
|
|
410
504
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
411
505
|
type: Injectable
|
|
412
|
-
}], 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 }]; } });
|
|
413
507
|
|
|
414
508
|
class MapPlateFactory {
|
|
415
509
|
build(settings) {
|
|
@@ -532,11 +626,11 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
532
626
|
this.registrator.down();
|
|
533
627
|
};
|
|
534
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 });
|
|
535
|
-
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 });
|
|
536
630
|
}
|
|
537
631
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
538
632
|
type: Component,
|
|
539
|
-
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"] }]
|
|
540
634
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
541
635
|
type: Input
|
|
542
636
|
}] } });
|
|
@@ -921,6 +1015,211 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
921
1015
|
type: Input
|
|
922
1016
|
}] } });
|
|
923
1017
|
|
|
1018
|
+
class PolygonsComponent extends DestructibleComponent {
|
|
1019
|
+
postboy;
|
|
1020
|
+
layerName = '';
|
|
1021
|
+
constructor(postboy) {
|
|
1022
|
+
super();
|
|
1023
|
+
this.postboy = postboy;
|
|
1024
|
+
}
|
|
1025
|
+
_polygons = [];
|
|
1026
|
+
set polygons(value) {
|
|
1027
|
+
this._polygons = value;
|
|
1028
|
+
this.putPolygons();
|
|
1029
|
+
}
|
|
1030
|
+
ngOnInit() {
|
|
1031
|
+
this.postboy
|
|
1032
|
+
.subscribe(MapRenderedEvent.ID)
|
|
1033
|
+
.pipe(filter((m) => !!m), first())
|
|
1034
|
+
.subscribe(() => this.putPolygons());
|
|
1035
|
+
}
|
|
1036
|
+
putPolygons() {
|
|
1037
|
+
if (!this._polygons?.length)
|
|
1038
|
+
return;
|
|
1039
|
+
this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
|
|
1040
|
+
}
|
|
1041
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PolygonsComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1042
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: PolygonsComponent, selector: "lib-polygons", inputs: { layerName: "layerName", polygons: "polygons" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1043
|
+
}
|
|
1044
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PolygonsComponent, decorators: [{
|
|
1045
|
+
type: Component,
|
|
1046
|
+
args: [{ selector: 'lib-polygons', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
|
|
1047
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; }, propDecorators: { layerName: [{
|
|
1048
|
+
type: Input
|
|
1049
|
+
}], polygons: [{
|
|
1050
|
+
type: Input
|
|
1051
|
+
}] } });
|
|
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
|
+
|
|
924
1223
|
class MapModule {
|
|
925
1224
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
926
1225
|
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: MapModule, declarations: [DestructibleComponent,
|
|
@@ -929,7 +1228,15 @@ class MapModule {
|
|
|
929
1228
|
OsmTileLayerComponent,
|
|
930
1229
|
FeatureLayerComponent,
|
|
931
1230
|
MarkersComponent,
|
|
932
|
-
TooltipComponent
|
|
1231
|
+
TooltipComponent,
|
|
1232
|
+
PolygonsComponent,
|
|
1233
|
+
ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
|
|
1234
|
+
FeatureLayerComponent,
|
|
1235
|
+
MarkersComponent,
|
|
1236
|
+
TileLayerComponent,
|
|
1237
|
+
TooltipComponent,
|
|
1238
|
+
PolygonsComponent,
|
|
1239
|
+
ClusterLayerComponent] });
|
|
933
1240
|
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapModule, imports: [CommonModule] });
|
|
934
1241
|
}
|
|
935
1242
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapModule, decorators: [{
|
|
@@ -944,8 +1251,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
944
1251
|
FeatureLayerComponent,
|
|
945
1252
|
MarkersComponent,
|
|
946
1253
|
TooltipComponent,
|
|
1254
|
+
PolygonsComponent,
|
|
1255
|
+
ClusterLayerComponent,
|
|
1256
|
+
],
|
|
1257
|
+
exports: [
|
|
1258
|
+
MapPlateComponent,
|
|
1259
|
+
FeatureLayerComponent,
|
|
1260
|
+
MarkersComponent,
|
|
1261
|
+
TileLayerComponent,
|
|
1262
|
+
TooltipComponent,
|
|
1263
|
+
PolygonsComponent,
|
|
1264
|
+
ClusterLayerComponent,
|
|
947
1265
|
],
|
|
948
|
-
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent, TooltipComponent],
|
|
949
1266
|
}]
|
|
950
1267
|
}] });
|
|
951
1268
|
|
|
@@ -970,6 +1287,37 @@ class MarkerStyleHelper {
|
|
|
970
1287
|
}),
|
|
971
1288
|
});
|
|
972
1289
|
}
|
|
1290
|
+
static withText(style, text) {
|
|
1291
|
+
style.setText(text);
|
|
1292
|
+
return style;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
class PolygonStyleHelper {
|
|
1297
|
+
static simple(fill, stroke, strokeWidth = 1) {
|
|
1298
|
+
return new Style({
|
|
1299
|
+
fill: new Fill({
|
|
1300
|
+
color: fill,
|
|
1301
|
+
}),
|
|
1302
|
+
stroke: new Stroke({
|
|
1303
|
+
color: stroke,
|
|
1304
|
+
width: strokeWidth,
|
|
1305
|
+
}),
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
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
|
+
}
|
|
973
1321
|
}
|
|
974
1322
|
|
|
975
1323
|
/*
|
|
@@ -980,5 +1328,5 @@ class MarkerStyleHelper {
|
|
|
980
1328
|
* Generated bundle index. Do not edit.
|
|
981
1329
|
*/
|
|
982
1330
|
|
|
983
|
-
export { CallbackMessage, CloseTooltipCommand, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
|
|
1331
|
+
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 };
|
|
984
1332
|
//# sourceMappingURL=maps-components-src-map.mjs.map
|