@artstesh/maps 1.0.5 → 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 +418 -19
- package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
- package/dist/bundles/maps-components.umd.js +418 -19
- package/dist/bundles/maps-components.umd.js.map +1 -1
- package/dist/esm2015/map/helpers/index.js +3 -1
- package/dist/esm2015/map/helpers/marker-style.helper.js +5 -1
- package/dist/esm2015/map/helpers/polygon-style.helper.js +16 -0
- package/dist/esm2015/map/helpers/text-style.helper.js +14 -0
- package/dist/esm2015/map/map-plate/features/index.js +2 -1
- package/dist/esm2015/map/map-plate/features/polygons/polygons.component.js +47 -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 +23 -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/index.js +2 -1
- package/dist/esm2015/map/models/map.constants.js +4 -0
- package/dist/esm2015/map/models/marker-model.js +3 -2
- package/dist/esm2015/map/models/polygon.model.js +26 -0
- 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 +3 -1
- package/dist/esm2015/src/map/helpers/marker-style.helper.js +5 -1
- package/dist/esm2015/src/map/helpers/polygon-style.helper.js +16 -0
- package/dist/esm2015/src/map/helpers/text-style.helper.js +14 -0
- package/dist/esm2015/src/map/map-plate/features/index.js +2 -1
- package/dist/esm2015/src/map/map-plate/features/polygons/polygons.component.js +47 -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 +23 -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/index.js +2 -1
- 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/models/polygon.model.js +26 -0
- 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 +365 -17
- package/dist/fesm2015/maps-components-src-map.js.map +1 -1
- package/dist/fesm2015/maps-components.js +365 -17
- package/dist/fesm2015/maps-components.js.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 i5 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
|
constructor() {
|
|
@@ -120,6 +125,10 @@ class IdGenerator {
|
|
|
120
125
|
}
|
|
121
126
|
IdGenerator.collection = 'ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789'.split('');
|
|
122
127
|
|
|
128
|
+
class MapConstants {
|
|
129
|
+
}
|
|
130
|
+
MapConstants.FeatureInfo = 'f-info';
|
|
131
|
+
|
|
123
132
|
class MarkerModel {
|
|
124
133
|
constructor(lat, lng, id, info) {
|
|
125
134
|
this.lat = lat;
|
|
@@ -135,11 +144,34 @@ class MarkerModel {
|
|
|
135
144
|
const feature = new Feature(new Point([this.lng, this.lat]));
|
|
136
145
|
feature.setId(this.id);
|
|
137
146
|
if (this.info)
|
|
138
|
-
feature.set(
|
|
147
|
+
feature.set(MapConstants.FeatureInfo, this.info);
|
|
139
148
|
return feature;
|
|
140
149
|
}
|
|
141
150
|
}
|
|
142
151
|
|
|
152
|
+
class PolygonModel {
|
|
153
|
+
constructor(feature, id, info) {
|
|
154
|
+
var _a;
|
|
155
|
+
this.info = info;
|
|
156
|
+
this.id = id == null ? IdGenerator.get() : id;
|
|
157
|
+
this._feature = feature;
|
|
158
|
+
[this.lng, this.lat] = getCenter((_a = this._feature.getGeometry()) === null || _a === void 0 ? void 0 : _a.getExtent());
|
|
159
|
+
}
|
|
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
|
+
get feature() {
|
|
171
|
+
return this._feature;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
143
175
|
class GenericMessage {
|
|
144
176
|
}
|
|
145
177
|
class CallbackMessage extends GenericMessage {
|
|
@@ -166,10 +198,11 @@ class MapRenderedEvent extends GenericMessage {
|
|
|
166
198
|
MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
|
|
167
199
|
|
|
168
200
|
class MapClickEvent extends GenericMessage {
|
|
169
|
-
constructor(coordinates, entities) {
|
|
201
|
+
constructor(coordinates, entities, features) {
|
|
170
202
|
super();
|
|
171
203
|
this.coordinates = coordinates;
|
|
172
204
|
this.entities = entities;
|
|
205
|
+
this.features = features;
|
|
173
206
|
}
|
|
174
207
|
get id() {
|
|
175
208
|
return MapClickEvent.ID;
|
|
@@ -244,6 +277,18 @@ class RemoveTileCommand extends GenericMessage {
|
|
|
244
277
|
}
|
|
245
278
|
RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
|
|
246
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
|
+
|
|
247
292
|
class MapPostboyService extends PostboyService {
|
|
248
293
|
constructor() {
|
|
249
294
|
super(...arguments);
|
|
@@ -298,11 +343,14 @@ class MapManagementService {
|
|
|
298
343
|
}
|
|
299
344
|
observePlaceFeatures() {
|
|
300
345
|
this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
|
|
301
|
-
var _a, _b
|
|
346
|
+
var _a, _b;
|
|
302
347
|
if (!this.layers[c.layer])
|
|
303
348
|
return;
|
|
304
|
-
|
|
305
|
-
(
|
|
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);
|
|
306
354
|
});
|
|
307
355
|
}
|
|
308
356
|
observeRemoveLayer() {
|
|
@@ -334,6 +382,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
334
382
|
type: Injectable
|
|
335
383
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
336
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
|
+
|
|
337
418
|
class MapClickService {
|
|
338
419
|
constructor(postboy) {
|
|
339
420
|
this.postboy = postboy;
|
|
@@ -352,7 +433,7 @@ class MapClickService {
|
|
|
352
433
|
}
|
|
353
434
|
onClick(ev) {
|
|
354
435
|
var _a;
|
|
355
|
-
const model = new MapClickEvent(ev.coordinate, {});
|
|
436
|
+
const model = new MapClickEvent(ev.coordinate, {}, {});
|
|
356
437
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.forEachFeatureAtPixel(ev.pixel, (f, l) => {
|
|
357
438
|
this.getFeatureCollectionWithInner([f])
|
|
358
439
|
.filter((f) => f.getId() != null)
|
|
@@ -360,7 +441,10 @@ class MapClickService {
|
|
|
360
441
|
let layerName = l.get('name');
|
|
361
442
|
if (!model.entities[layerName])
|
|
362
443
|
model.entities[layerName] = [];
|
|
363
|
-
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);
|
|
364
448
|
});
|
|
365
449
|
});
|
|
366
450
|
return model;
|
|
@@ -381,9 +465,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
381
465
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
382
466
|
|
|
383
467
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
384
|
-
constructor(service, management, state, interaction) {
|
|
468
|
+
constructor(service, management, state, feature, interaction) {
|
|
385
469
|
super(service);
|
|
386
|
-
this.registerServices([management, state, interaction]);
|
|
470
|
+
this.registerServices([management, state, interaction, feature]);
|
|
387
471
|
}
|
|
388
472
|
_up() {
|
|
389
473
|
this.registerReplay(MapRenderedEvent.ID);
|
|
@@ -394,13 +478,14 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
394
478
|
this.registerSubject(RemoveTileCommand.ID);
|
|
395
479
|
this.registerSubject(MapClickEvent.ID);
|
|
396
480
|
this.registerSubject(CloseTooltipCommand.ID);
|
|
481
|
+
this.registerSubject(FitToFeaturesCommand.ID);
|
|
397
482
|
}
|
|
398
483
|
}
|
|
399
|
-
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 });
|
|
400
485
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService });
|
|
401
486
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
402
487
|
type: Injectable
|
|
403
|
-
}], 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 }]; } });
|
|
404
489
|
|
|
405
490
|
class MapPlateFactory {
|
|
406
491
|
build(settings) {
|
|
@@ -522,7 +607,7 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
522
607
|
}
|
|
523
608
|
}
|
|
524
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 });
|
|
525
|
-
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 });
|
|
526
611
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
527
612
|
type: Component,
|
|
528
613
|
args: [{
|
|
@@ -530,7 +615,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
530
615
|
templateUrl: './map-plate.component.html',
|
|
531
616
|
styleUrls: ['./map-plate.component.scss'],
|
|
532
617
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
533
|
-
providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService],
|
|
618
|
+
providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService, MapFeatureService],
|
|
534
619
|
}]
|
|
535
620
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
536
621
|
type: Input
|
|
@@ -931,6 +1016,220 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
931
1016
|
type: Input
|
|
932
1017
|
}] } });
|
|
933
1018
|
|
|
1019
|
+
class PolygonsComponent extends DestructibleComponent {
|
|
1020
|
+
constructor(postboy) {
|
|
1021
|
+
super();
|
|
1022
|
+
this.postboy = postboy;
|
|
1023
|
+
this.layerName = '';
|
|
1024
|
+
this._polygons = [];
|
|
1025
|
+
}
|
|
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
|
+
var _a;
|
|
1038
|
+
if (!((_a = this._polygons) === null || _a === void 0 ? void 0 : _a.length))
|
|
1039
|
+
return;
|
|
1040
|
+
this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
PolygonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PolygonsComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1044
|
+
PolygonsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: PolygonsComponent, selector: "lib-polygons", inputs: { layerName: "layerName", polygons: "polygons" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1045
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PolygonsComponent, decorators: [{
|
|
1046
|
+
type: Component,
|
|
1047
|
+
args: [{
|
|
1048
|
+
selector: 'lib-polygons',
|
|
1049
|
+
template: '',
|
|
1050
|
+
styleUrls: [],
|
|
1051
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1052
|
+
}]
|
|
1053
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; }, propDecorators: { layerName: [{
|
|
1054
|
+
type: Input
|
|
1055
|
+
}], polygons: [{
|
|
1056
|
+
type: Input
|
|
1057
|
+
}] } });
|
|
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
|
+
|
|
934
1233
|
class MapModule {
|
|
935
1234
|
}
|
|
936
1235
|
MapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -940,7 +1239,15 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.
|
|
|
940
1239
|
OsmTileLayerComponent,
|
|
941
1240
|
FeatureLayerComponent,
|
|
942
1241
|
MarkersComponent,
|
|
943
|
-
TooltipComponent
|
|
1242
|
+
TooltipComponent,
|
|
1243
|
+
PolygonsComponent,
|
|
1244
|
+
ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
|
|
1245
|
+
FeatureLayerComponent,
|
|
1246
|
+
MarkersComponent,
|
|
1247
|
+
TileLayerComponent,
|
|
1248
|
+
TooltipComponent,
|
|
1249
|
+
PolygonsComponent,
|
|
1250
|
+
ClusterLayerComponent] });
|
|
944
1251
|
MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, imports: [[CommonModule]] });
|
|
945
1252
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, decorators: [{
|
|
946
1253
|
type: NgModule,
|
|
@@ -954,8 +1261,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
954
1261
|
FeatureLayerComponent,
|
|
955
1262
|
MarkersComponent,
|
|
956
1263
|
TooltipComponent,
|
|
1264
|
+
PolygonsComponent,
|
|
1265
|
+
ClusterLayerComponent,
|
|
1266
|
+
],
|
|
1267
|
+
exports: [
|
|
1268
|
+
MapPlateComponent,
|
|
1269
|
+
FeatureLayerComponent,
|
|
1270
|
+
MarkersComponent,
|
|
1271
|
+
TileLayerComponent,
|
|
1272
|
+
TooltipComponent,
|
|
1273
|
+
PolygonsComponent,
|
|
1274
|
+
ClusterLayerComponent,
|
|
957
1275
|
],
|
|
958
|
-
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent, TooltipComponent],
|
|
959
1276
|
}]
|
|
960
1277
|
}] });
|
|
961
1278
|
|
|
@@ -980,6 +1297,37 @@ class MarkerStyleHelper {
|
|
|
980
1297
|
}),
|
|
981
1298
|
});
|
|
982
1299
|
}
|
|
1300
|
+
static withText(style, text) {
|
|
1301
|
+
style.setText(text);
|
|
1302
|
+
return style;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
class PolygonStyleHelper {
|
|
1307
|
+
static simple(fill, stroke, strokeWidth = 1) {
|
|
1308
|
+
return new Style({
|
|
1309
|
+
fill: new Fill({
|
|
1310
|
+
color: fill,
|
|
1311
|
+
}),
|
|
1312
|
+
stroke: new Stroke({
|
|
1313
|
+
color: stroke,
|
|
1314
|
+
width: strokeWidth,
|
|
1315
|
+
}),
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
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
|
+
}
|
|
983
1331
|
}
|
|
984
1332
|
|
|
985
1333
|
/*
|
|
@@ -994,5 +1342,5 @@ class MarkerStyleHelper {
|
|
|
994
1342
|
* Generated bundle index. Do not edit.
|
|
995
1343
|
*/
|
|
996
1344
|
|
|
997
|
-
export { CallbackMessage, CloseTooltipCommand, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
|
|
1345
|
+
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 };
|
|
998
1346
|
//# sourceMappingURL=maps-components.js.map
|