@artstesh/maps 1.0.7 → 1.0.8

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.
Files changed (128) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +644 -433
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +644 -433
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/helpers/text-style.helper.js +1 -1
  6. package/dist/esm2015/map/map-plate/features/polygons/polygons.component.js +2 -3
  7. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.js +1 -1
  8. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.manager.js +20 -2
  9. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.settings.js +8 -1
  10. package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.component.js +1 -1
  11. package/dist/esm2015/map/map-plate/map-plate.component.js +23 -4
  12. package/dist/esm2015/map/messages/commands/add-layer.command.js +3 -3
  13. package/dist/esm2015/map/messages/commands/add-tile.command.js +3 -3
  14. package/dist/esm2015/map/messages/commands/cancel-drawing.command.js +8 -0
  15. package/dist/esm2015/map/messages/commands/close-tooltip.command.js +3 -3
  16. package/dist/esm2015/map/messages/commands/fit-to-features.command.js +3 -3
  17. package/dist/esm2015/map/messages/commands/place-layer-features.command.js +3 -3
  18. package/dist/esm2015/map/messages/commands/remove-layer.command.js +3 -3
  19. package/dist/esm2015/map/messages/commands/remove-tile.command.js +3 -3
  20. package/dist/esm2015/map/messages/commands/start-drawing.command.js +15 -0
  21. package/dist/esm2015/map/messages/events/drawing-finished.event.js +11 -0
  22. package/dist/esm2015/map/messages/events/map-click.event.js +3 -3
  23. package/dist/esm2015/map/messages/events/map-move-end.event.js +13 -0
  24. package/dist/esm2015/map/messages/events/map-rendered.event.js +3 -3
  25. package/dist/esm2015/map/messages/index.js +4 -2
  26. package/dist/esm2015/map/messages/queries/get-layer.query.js +12 -0
  27. package/dist/esm2015/map/models/drawing-type.enum.js +5 -0
  28. package/dist/esm2015/map/models/feature-format.enum.js +6 -0
  29. package/dist/esm2015/map/models/index.js +3 -1
  30. package/dist/esm2015/map/models/map.constants.js +2 -1
  31. package/dist/esm2015/map/services/drawing/drawing.service.js +80 -0
  32. package/dist/esm2015/map/services/map-management.service.js +6 -1
  33. package/dist/esm2015/map/services/map-postboy.service.js +8 -5
  34. package/dist/esm2015/map/services/map-state.service.js +12 -2
  35. package/dist/esm2015/map/services/message-registrator.service.js +16 -5
  36. package/dist/esm2015/src/map/helpers/text-style.helper.js +1 -1
  37. package/dist/esm2015/src/map/map-plate/features/polygons/polygons.component.js +2 -3
  38. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.js +1 -1
  39. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.js +20 -2
  40. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.js +8 -1
  41. package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.component.js +1 -1
  42. package/dist/esm2015/src/map/map-plate/map-plate.component.js +23 -4
  43. package/dist/esm2015/src/map/messages/commands/add-layer.command.js +3 -3
  44. package/dist/esm2015/src/map/messages/commands/add-tile.command.js +3 -3
  45. package/dist/esm2015/src/map/messages/commands/cancel-drawing.command.js +8 -0
  46. package/dist/esm2015/src/map/messages/commands/close-tooltip.command.js +3 -3
  47. package/dist/esm2015/src/map/messages/commands/fit-to-features.command.js +3 -3
  48. package/dist/esm2015/src/map/messages/commands/place-layer-features.command.js +3 -3
  49. package/dist/esm2015/src/map/messages/commands/remove-layer.command.js +3 -3
  50. package/dist/esm2015/src/map/messages/commands/remove-tile.command.js +3 -3
  51. package/dist/esm2015/src/map/messages/commands/start-drawing.command.js +15 -0
  52. package/dist/esm2015/src/map/messages/events/drawing-finished.event.js +11 -0
  53. package/dist/esm2015/src/map/messages/events/map-click.event.js +3 -3
  54. package/dist/esm2015/src/map/messages/events/map-move-end.event.js +13 -0
  55. package/dist/esm2015/src/map/messages/events/map-rendered.event.js +3 -3
  56. package/dist/esm2015/src/map/messages/index.js +4 -2
  57. package/dist/esm2015/src/map/messages/queries/get-layer.query.js +12 -0
  58. package/dist/esm2015/src/map/models/drawing-type.enum.js +5 -0
  59. package/dist/esm2015/src/map/models/feature-format.enum.js +6 -0
  60. package/dist/esm2015/src/map/models/index.js +3 -1
  61. package/dist/esm2015/src/map/models/map.constants.js +2 -1
  62. package/dist/esm2015/src/map/services/drawing/drawing.service.js +80 -0
  63. package/dist/esm2015/src/map/services/map-management.service.js +6 -1
  64. package/dist/esm2015/src/map/services/map-postboy.service.js +8 -5
  65. package/dist/esm2015/src/map/services/map-state.service.js +12 -2
  66. package/dist/esm2015/src/map/services/message-registrator.service.js +16 -5
  67. package/dist/fesm2015/maps-components-src-map.js +553 -381
  68. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  69. package/dist/fesm2015/maps-components.js +553 -381
  70. package/dist/fesm2015/maps-components.js.map +1 -1
  71. package/dist/map/map-plate/layers/cluster-layer/cluster-layer.manager.d.ts +2 -0
  72. package/dist/map/map-plate/layers/cluster-layer/cluster-layer.settings.d.ts +2 -0
  73. package/dist/map/map-plate/map-plate.component.d.ts +2 -0
  74. package/dist/map/messages/commands/add-layer.command.d.ts +3 -3
  75. package/dist/map/messages/commands/add-tile.command.d.ts +3 -3
  76. package/dist/map/messages/commands/cancel-drawing.command.d.ts +5 -0
  77. package/dist/map/messages/commands/close-tooltip.command.d.ts +3 -3
  78. package/dist/map/messages/commands/fit-to-features.command.d.ts +3 -3
  79. package/dist/map/messages/commands/place-layer-features.command.d.ts +3 -3
  80. package/dist/map/messages/commands/remove-layer.command.d.ts +3 -3
  81. package/dist/map/messages/commands/remove-tile.command.d.ts +3 -3
  82. package/dist/map/messages/commands/start-drawing.command.d.ts +11 -0
  83. package/dist/map/messages/events/drawing-finished.event.d.ts +6 -0
  84. package/dist/map/messages/events/map-click.event.d.ts +3 -3
  85. package/dist/map/messages/events/map-move-end.event.d.ts +8 -0
  86. package/dist/map/messages/events/map-rendered.event.d.ts +3 -3
  87. package/dist/map/messages/index.d.ts +3 -1
  88. package/dist/map/messages/queries/get-layer.query.d.ts +10 -0
  89. package/dist/map/models/drawing-type.enum.d.ts +3 -0
  90. package/dist/map/models/feature-format.enum.d.ts +4 -0
  91. package/dist/map/models/index.d.ts +2 -0
  92. package/dist/map/models/map.constants.d.ts +1 -0
  93. package/dist/map/services/drawing/drawing.service.d.ts +17 -0
  94. package/dist/map/services/map-management.service.d.ts +1 -0
  95. package/dist/map/services/map-postboy.service.d.ts +1 -2
  96. package/dist/map/services/message-registrator.service.d.ts +2 -1
  97. package/dist/package.json +1 -1
  98. package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.d.ts +2 -0
  99. package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.d.ts +2 -0
  100. package/dist/src/map/map-plate/map-plate.component.d.ts +2 -0
  101. package/dist/src/map/messages/commands/add-layer.command.d.ts +3 -3
  102. package/dist/src/map/messages/commands/add-tile.command.d.ts +3 -3
  103. package/dist/src/map/messages/commands/cancel-drawing.command.d.ts +5 -0
  104. package/dist/src/map/messages/commands/close-tooltip.command.d.ts +3 -3
  105. package/dist/src/map/messages/commands/fit-to-features.command.d.ts +3 -3
  106. package/dist/src/map/messages/commands/place-layer-features.command.d.ts +3 -3
  107. package/dist/src/map/messages/commands/remove-layer.command.d.ts +3 -3
  108. package/dist/src/map/messages/commands/remove-tile.command.d.ts +3 -3
  109. package/dist/src/map/messages/commands/start-drawing.command.d.ts +11 -0
  110. package/dist/src/map/messages/events/drawing-finished.event.d.ts +6 -0
  111. package/dist/src/map/messages/events/map-click.event.d.ts +3 -3
  112. package/dist/src/map/messages/events/map-move-end.event.d.ts +8 -0
  113. package/dist/src/map/messages/events/map-rendered.event.d.ts +3 -3
  114. package/dist/src/map/messages/index.d.ts +3 -1
  115. package/dist/src/map/messages/queries/get-layer.query.d.ts +10 -0
  116. package/dist/src/map/models/drawing-type.enum.d.ts +3 -0
  117. package/dist/src/map/models/feature-format.enum.d.ts +4 -0
  118. package/dist/src/map/models/index.d.ts +2 -0
  119. package/dist/src/map/models/map.constants.d.ts +1 -0
  120. package/dist/src/map/services/drawing/drawing.service.d.ts +17 -0
  121. package/dist/src/map/services/map-management.service.d.ts +1 -0
  122. package/dist/src/map/services/map-postboy.service.d.ts +1 -2
  123. package/dist/src/map/services/message-registrator.service.d.ts +2 -1
  124. package/package.json +2 -2
  125. package/dist/esm2015/map/messages/generic-message.js +0 -15
  126. package/dist/esm2015/src/map/messages/generic-message.js +0 -15
  127. package/dist/map/messages/generic-message.d.ts +0 -9
  128. package/dist/src/map/messages/generic-message.d.ts +0 -9
@@ -1,25 +1,26 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgModule } from '@angular/core';
3
- import * as i5 from '@angular/common';
3
+ import * as i6 from '@angular/common';
4
4
  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
8
  import { getCenter, createEmpty, extend } from 'ol/extent';
9
- import { useGeographic, get } from 'ol/proj';
10
- import { Subject } from 'rxjs';
11
- import { PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
12
- import Map from 'ol/Map';
13
- import View from 'ol/View';
9
+ import { get, useGeographic } from 'ol/proj';
10
+ import { PostboyGenericMessage, PostboyCallbackMessage, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
11
+ import { first, filter, auditTime } from 'rxjs/operators';
12
+ import { Vector, XYZ } from 'ol/source';
13
+ import { Draw } from 'ol/interaction';
14
14
  import TileLayer from 'ol/layer/Tile';
15
15
  import OSM from 'ol/source/OSM';
16
- import { filter, first } from 'rxjs/operators';
17
- import { XYZ, Vector } from 'ol/source';
18
16
  import { Vector as Vector$1 } from 'ol/layer';
19
- import Overlay from 'ol/Overlay';
20
17
  import { bbox } from 'ol/loadingstrategy';
21
18
  import { fromExtent } from 'ol/geom/Polygon';
22
19
  import Cluster from 'ol/source/Cluster';
20
+ import { combineLatest } from 'rxjs';
21
+ import Map from 'ol/Map';
22
+ import View from 'ol/View';
23
+ import Overlay from 'ol/Overlay';
23
24
  import Style from 'ol/style/Style';
24
25
  import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
25
26
 
@@ -127,7 +128,8 @@ IdGenerator.collection = 'ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789'.split('');
127
128
 
128
129
  class MapConstants {
129
130
  }
130
- MapConstants.FeatureInfo = 'f-info';
131
+ MapConstants.FeatureInfo = 'f-info';
132
+ MapConstants.DrawingLayerId = '93a981756ec7';
131
133
 
132
134
  class MarkerModel {
133
135
  constructor(lat, lng, id, info) {
@@ -172,21 +174,18 @@ class PolygonModel {
172
174
  }
173
175
  }
174
176
 
175
- class GenericMessage {
176
- }
177
- class CallbackMessage extends GenericMessage {
178
- constructor() {
179
- super(...arguments);
180
- this.result$ = new Subject();
181
- this.result = this.result$.asObservable();
182
- }
183
- finish(value) {
184
- this.result$.next(value);
185
- this.result$.complete();
186
- }
187
- }
177
+ var DrawingType;
178
+ (function (DrawingType) {
179
+ DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
180
+ })(DrawingType || (DrawingType = {}));
181
+
182
+ var FeatureOutputFormat;
183
+ (function (FeatureOutputFormat) {
184
+ FeatureOutputFormat[FeatureOutputFormat["GeoJson"] = 1] = "GeoJson";
185
+ FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
186
+ })(FeatureOutputFormat || (FeatureOutputFormat = {}));
188
187
 
189
- class MapRenderedEvent extends GenericMessage {
188
+ class MapRenderedEvent extends PostboyGenericMessage {
190
189
  constructor(map) {
191
190
  super();
192
191
  this.map = map;
@@ -197,7 +196,7 @@ class MapRenderedEvent extends GenericMessage {
197
196
  }
198
197
  MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
199
198
 
200
- class MapClickEvent extends GenericMessage {
199
+ class MapClickEvent extends PostboyGenericMessage {
201
200
  constructor(coordinates, entities, features) {
202
201
  super();
203
202
  this.coordinates = coordinates;
@@ -210,7 +209,19 @@ class MapClickEvent extends GenericMessage {
210
209
  }
211
210
  MapClickEvent.ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
212
211
 
213
- class CloseTooltipCommand extends GenericMessage {
212
+ class MapMoveEndEvent extends PostboyGenericMessage {
213
+ constructor(zoom, extent) {
214
+ super();
215
+ this.zoom = zoom;
216
+ this.extent = extent;
217
+ }
218
+ get id() {
219
+ return MapMoveEndEvent.ID;
220
+ }
221
+ }
222
+ MapMoveEndEvent.ID = 'f21f783e-b5af-4489-9fec-8027fd07a8ad';
223
+
224
+ class CloseTooltipCommand extends PostboyGenericMessage {
214
225
  constructor(tooltipId) {
215
226
  super();
216
227
  this.tooltipId = tooltipId;
@@ -221,7 +232,27 @@ class CloseTooltipCommand extends GenericMessage {
221
232
  }
222
233
  CloseTooltipCommand.ID = '4896d52c-e34f-4994-bcfd-32832d12dbe4';
223
234
 
224
- class AddLayerCommand extends GenericMessage {
235
+ class StartDrawingCommand extends PostboyCallbackMessage {
236
+ constructor(type, style, format = FeatureOutputFormat.GeoJson) {
237
+ super();
238
+ this.type = type;
239
+ this.style = style;
240
+ this.format = format;
241
+ }
242
+ get id() {
243
+ return StartDrawingCommand.ID;
244
+ }
245
+ }
246
+ StartDrawingCommand.ID = 'da904f4b-a1c8-4db7-a6af-14d9ee18ec8c';
247
+
248
+ class CancelDrawingCommand extends PostboyGenericMessage {
249
+ get id() {
250
+ return CancelDrawingCommand.ID;
251
+ }
252
+ }
253
+ CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
254
+
255
+ class AddLayerCommand extends PostboyGenericMessage {
225
256
  constructor(layer) {
226
257
  super();
227
258
  this.layer = layer;
@@ -232,7 +263,7 @@ class AddLayerCommand extends GenericMessage {
232
263
  }
233
264
  AddLayerCommand.ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
234
265
 
235
- class PlaceLayerFeaturesCommand extends GenericMessage {
266
+ class PlaceLayerFeaturesCommand extends PostboyGenericMessage {
236
267
  constructor(layer, features) {
237
268
  super();
238
269
  this.layer = layer;
@@ -244,7 +275,7 @@ class PlaceLayerFeaturesCommand extends GenericMessage {
244
275
  }
245
276
  PlaceLayerFeaturesCommand.ID = '8caf86bc-869b-426f-b36d-4642f6b8aab0';
246
277
 
247
- class RemoveLayerCommand extends GenericMessage {
278
+ class RemoveLayerCommand extends PostboyGenericMessage {
248
279
  constructor(layer) {
249
280
  super();
250
281
  this.layer = layer;
@@ -255,7 +286,7 @@ class RemoveLayerCommand extends GenericMessage {
255
286
  }
256
287
  RemoveLayerCommand.ID = 'ab484e0e-e185-45cd-8434-12101f3c7eb1';
257
288
 
258
- class AddTileCommand extends GenericMessage {
289
+ class AddTileCommand extends PostboyGenericMessage {
259
290
  constructor(layer) {
260
291
  super();
261
292
  this.layer = layer;
@@ -266,7 +297,7 @@ class AddTileCommand extends GenericMessage {
266
297
  }
267
298
  AddTileCommand.ID = '25b7df28-72ce-4453-9fe6-54285a2fdc57';
268
299
 
269
- class RemoveTileCommand extends GenericMessage {
300
+ class RemoveTileCommand extends PostboyGenericMessage {
270
301
  constructor(layer) {
271
302
  super();
272
303
  this.layer = layer;
@@ -277,7 +308,7 @@ class RemoveTileCommand extends GenericMessage {
277
308
  }
278
309
  RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
279
310
 
280
- class FitToFeaturesCommand extends GenericMessage {
311
+ class FitToFeaturesCommand extends PostboyGenericMessage {
281
312
  constructor(features, zoomAfter = 0) {
282
313
  super();
283
314
  this.features = features;
@@ -289,17 +320,38 @@ class FitToFeaturesCommand extends GenericMessage {
289
320
  }
290
321
  FitToFeaturesCommand.ID = '76cdc091-3793-4b6c-82f7-1e0334cf08a8';
291
322
 
323
+ class GetLayerQuery extends PostboyCallbackMessage {
324
+ constructor(name) {
325
+ super();
326
+ this.name = name;
327
+ }
328
+ get id() {
329
+ return GetLayerQuery.ID;
330
+ }
331
+ }
332
+ GetLayerQuery.ID = '5c04c87b-8a93-4c2a-979e-d1e313d860ed';
333
+
334
+ class DrawingFinishedEvent extends PostboyGenericMessage {
335
+ constructor() {
336
+ super();
337
+ }
338
+ get id() {
339
+ return DrawingFinishedEvent.ID;
340
+ }
341
+ }
342
+ DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
343
+
292
344
  class MapPostboyService extends PostboyService {
293
345
  constructor() {
294
- super(...arguments);
295
- this.observe = (id) => this.subscribe(id);
346
+ super();
347
+ this.addLocker({ locker: StartDrawingCommand.ID, unlocker: DrawingFinishedEvent.ID, locking: [MapClickEvent.ID] });
296
348
  }
297
349
  }
298
- MapPostboyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPostboyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
350
+ MapPostboyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPostboyService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
299
351
  MapPostboyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPostboyService });
300
352
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPostboyService, decorators: [{
301
353
  type: Injectable
302
- }] });
354
+ }], ctorParameters: function () { return []; } });
303
355
 
304
356
  class MapManagementService {
305
357
  constructor(postboy) {
@@ -313,6 +365,7 @@ class MapManagementService {
313
365
  this.observePlaceFeatures();
314
366
  this.observeAddTile();
315
367
  this.observeRemoveTile();
368
+ this.observeLayerQuery();
316
369
  }
317
370
  observeRemoveTile() {
318
371
  this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
@@ -321,6 +374,9 @@ class MapManagementService {
321
374
  this.map.removeLayer(c.layer);
322
375
  });
323
376
  }
377
+ observeLayerQuery() {
378
+ this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => { var _a; return ev.finish((_a = this.layers[ev.name]) !== null && _a !== void 0 ? _a : null); });
379
+ }
324
380
  observeAddTile() {
325
381
  this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
326
382
  if (!this.map)
@@ -373,7 +429,16 @@ class MapStateService {
373
429
  this.postboy = postboy;
374
430
  }
375
431
  up() {
376
- this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => (this.map = m));
432
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe((ev) => {
433
+ var _a;
434
+ this.map = ev.map;
435
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.on('moveend', () => {
436
+ var _a, _b;
437
+ const zoom = Math.floor(((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView().getZoom()) || -1);
438
+ const extent = ((_b = this.map) === null || _b === void 0 ? void 0 : _b.getView().calculateExtent()) || [];
439
+ this.postboy.fire(new MapMoveEndEvent(zoom, extent));
440
+ });
441
+ });
377
442
  }
378
443
  }
379
444
  MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -464,10 +529,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
464
529
  type: Injectable
465
530
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
466
531
 
532
+ class DrawingService {
533
+ constructor(postboy) {
534
+ this.postboy = postboy;
535
+ }
536
+ up() {
537
+ this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
538
+ this.draw((l) => {
539
+ if (!l || !this.map) {
540
+ this.clearInteraction(l);
541
+ return;
542
+ }
543
+ const cancelSub = this.observeCancelation(ev, l);
544
+ this.drawInteraction = new Draw({
545
+ source: l.getSource(),
546
+ type: DrawingType[ev.type],
547
+ style: ev.style,
548
+ });
549
+ this.map.addInteraction(this.drawInteraction);
550
+ this.drawInteraction.on('drawend', (evt) => {
551
+ cancelSub.unsubscribe();
552
+ this.onEnd(evt, ev, l);
553
+ });
554
+ });
555
+ });
556
+ this.observeMapRender();
557
+ }
558
+ onEnd(evt, command, layer) {
559
+ command.finish(command.format === FeatureOutputFormat.GeoJson
560
+ ? new GeoJSON().writeFeature(evt.feature)
561
+ : new WKT().writeFeature(evt.feature));
562
+ this.clearInteraction(layer);
563
+ }
564
+ observeMapRender() {
565
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
566
+ this.map = m.map;
567
+ });
568
+ }
569
+ draw(action) {
570
+ const query = new GetLayerQuery(MapConstants.DrawingLayerId);
571
+ query.result.subscribe((l) => action(l));
572
+ this.postboy.fire(query);
573
+ }
574
+ observeCancelation(ev, layer) {
575
+ return this.postboy
576
+ .subscribe(CancelDrawingCommand.ID)
577
+ .pipe(first())
578
+ .subscribe(() => {
579
+ ev.finish(null);
580
+ this.clearInteraction(layer);
581
+ });
582
+ }
583
+ clearInteraction(layer) {
584
+ var _a;
585
+ if (!!this.drawInteraction) {
586
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeInteraction(this.drawInteraction);
587
+ layer === null || layer === void 0 ? void 0 : layer.setSource(new Vector({}));
588
+ }
589
+ setTimeout(() => this.postboy.fire(new DrawingFinishedEvent()), 300);
590
+ }
591
+ }
592
+ DrawingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DrawingService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
593
+ DrawingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DrawingService });
594
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DrawingService, decorators: [{
595
+ type: Injectable
596
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
597
+
467
598
  class MessageRegistratorService extends PostboyAbstractRegistrator {
468
- constructor(service, management, state, feature, interaction) {
599
+ constructor(service, management, state, feature, interaction, drawing) {
469
600
  super(service);
470
- this.registerServices([management, state, interaction, feature]);
601
+ this.registerServices([management, state, interaction, feature, drawing]);
471
602
  }
472
603
  _up() {
473
604
  this.registerReplay(MapRenderedEvent.ID);
@@ -479,147 +610,18 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
479
610
  this.registerSubject(MapClickEvent.ID);
480
611
  this.registerSubject(CloseTooltipCommand.ID);
481
612
  this.registerSubject(FitToFeaturesCommand.ID);
613
+ this.registerSubject(MapMoveEndEvent.ID);
614
+ this.registerSubject(CancelDrawingCommand.ID);
615
+ this.registerSubject(StartDrawingCommand.ID);
616
+ this.registerSubject(GetLayerQuery.ID);
617
+ this.registerSubject(DrawingFinishedEvent.ID);
482
618
  }
483
619
  }
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 });
620
+ 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 }, { token: DrawingService }], target: i0.ɵɵFactoryTarget.Injectable });
485
621
  MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService });
486
622
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, decorators: [{
487
623
  type: Injectable
488
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }]; } });
489
-
490
- class MapPlateFactory {
491
- build(settings) {
492
- return new Map({
493
- controls: [],
494
- view: new View({
495
- center: (settings === null || settings === void 0 ? void 0 : settings.center) || [0, 0],
496
- zoom: (settings === null || settings === void 0 ? void 0 : settings.zoom) || 4,
497
- minZoom: (settings === null || settings === void 0 ? void 0 : settings.minZoom) || 0,
498
- maxZoom: (settings === null || settings === void 0 ? void 0 : settings.maxZoom) || 19,
499
- }),
500
- layers: [],
501
- });
502
- }
503
- }
504
- MapPlateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
505
- MapPlateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, providedIn: 'root' });
506
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, decorators: [{
507
- type: Injectable,
508
- args: [{
509
- providedIn: 'root',
510
- }]
511
- }] });
512
-
513
- class OsmTileLayerComponent extends DestructibleComponent {
514
- constructor() {
515
- super();
516
- this._url = '';
517
- }
518
- set url(value) {
519
- if (!value || this._url === value)
520
- return;
521
- this._url = value;
522
- this.initLayer();
523
- }
524
- set map(value) {
525
- if (!value || this._map === value)
526
- return;
527
- this._map = value;
528
- this.initLayer();
529
- }
530
- ngOnInit() { }
531
- ngOnDestroy() {
532
- var _a, _b;
533
- if (this.layer) {
534
- (_a = this._map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.layer);
535
- }
536
- // @ts-ignore
537
- (_b = this.layer) === null || _b === void 0 ? void 0 : _b.setMap(null);
538
- }
539
- initLayer() {
540
- if (!this._url || !this._map)
541
- return;
542
- if (this.layer)
543
- this._map.removeLayer(this.layer);
544
- this.layer = new TileLayer({
545
- source: new OSM({
546
- url: this._url,
547
- }),
548
- });
549
- this.layer.set('name', 'osm-tile-layer');
550
- this._map.addLayer(this.layer);
551
- }
552
- }
553
- OsmTileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: OsmTileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
554
- OsmTileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: { url: "url", map: "map" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
555
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: OsmTileLayerComponent, decorators: [{
556
- type: Component,
557
- args: [{
558
- selector: 'lib-osm-tile-layer',
559
- template: '',
560
- styleUrls: [],
561
- changeDetection: ChangeDetectionStrategy.OnPush,
562
- }]
563
- }], ctorParameters: function () { return []; }, propDecorators: { url: [{
564
- type: Input
565
- }], map: [{
566
- type: Input
567
- }] } });
568
-
569
- class MapPlateComponent extends DestructibleComponent {
570
- constructor(elementRef, postboy, mapFactory, registrator, detector) {
571
- super();
572
- this.elementRef = elementRef;
573
- this.postboy = postboy;
574
- this.mapFactory = mapFactory;
575
- this.registrator = registrator;
576
- this.detector = detector;
577
- this.osmUrl = '';
578
- this._settings = new MapSettings();
579
- this.onDestroy = () => {
580
- this.registrator.down();
581
- };
582
- registrator.up();
583
- }
584
- set settings(value) {
585
- if (!value || this._settings.isSame(value))
586
- return;
587
- this._settings = value;
588
- this.setOsm();
589
- }
590
- ngOnInit() {
591
- useGeographic();
592
- this.map = this.mapFactory.build(this._settings);
593
- this.map.setTarget(this.elementRef.nativeElement);
594
- this.detector.detectChanges();
595
- this.map.once('postrender', () => {
596
- this.map.updateSize();
597
- this.postboy.fire(new MapRenderedEvent(this.map));
598
- });
599
- this.setOsm();
600
- }
601
- setOsm() {
602
- if (!this.map)
603
- return;
604
- this.osmUrl = `https://mt{0-3}.google.com/vt/lyrs=${MapLyrsLabel.get(this._settings.lyrs)}&hl=${this._settings.language}&x={x}&y={y}&z={z}`;
605
- this.detector.detectChanges();
606
- this.map.updateSize();
607
- }
608
- }
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 });
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 });
611
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
612
- type: Component,
613
- args: [{
614
- selector: 'lib-map-plate',
615
- templateUrl: './map-plate.component.html',
616
- styleUrls: ['./map-plate.component.scss'],
617
- changeDetection: ChangeDetectionStrategy.OnPush,
618
- providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService, MapFeatureService],
619
- }]
620
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
621
- type: Input
622
- }] } });
624
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
623
625
 
624
626
  class TileLayerSettings {
625
627
  constructor() {
@@ -757,40 +759,96 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
757
759
  type: Input
758
760
  }] } });
759
761
 
760
- class FeatureLayerSettings {
762
+ class OsmTileLayerComponent extends DestructibleComponent {
761
763
  constructor() {
762
- this.name = IdGenerator.get();
763
- this.zIndex = 1;
764
- this.maxZoom = 19;
765
- this.minZoom = 0;
766
- }
767
- static copy(model) {
768
- const result = new FeatureLayerSettings();
769
- result.name = model.name;
770
- result.maxZoom = model.maxZoom;
771
- result.minZoom = model.minZoom;
772
- result.zIndex = model.zIndex;
773
- result.style = model.style;
774
- return result;
775
- }
776
- setZIndex(zIndex) {
777
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex }));
778
- }
779
- setName(name) {
780
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { name }));
764
+ super();
765
+ this._url = '';
781
766
  }
782
- setMaxZoom(maxZoom) {
783
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
767
+ set url(value) {
768
+ if (!value || this._url === value)
769
+ return;
770
+ this._url = value;
771
+ this.initLayer();
784
772
  }
785
- setMinZoom(minZoom) {
786
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
773
+ set map(value) {
774
+ if (!value || this._map === value)
775
+ return;
776
+ this._map = value;
777
+ this.initLayer();
787
778
  }
788
- setStyle(style) {
789
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
779
+ ngOnInit() { }
780
+ ngOnDestroy() {
781
+ var _a, _b;
782
+ if (this.layer) {
783
+ (_a = this._map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.layer);
784
+ }
785
+ // @ts-ignore
786
+ (_b = this.layer) === null || _b === void 0 ? void 0 : _b.setMap(null);
790
787
  }
791
- isSame(model) {
792
- if (this.maxZoom !== model.maxZoom)
793
- return false;
788
+ initLayer() {
789
+ if (!this._url || !this._map)
790
+ return;
791
+ if (this.layer)
792
+ this._map.removeLayer(this.layer);
793
+ this.layer = new TileLayer({
794
+ source: new OSM({
795
+ url: this._url,
796
+ }),
797
+ });
798
+ this.layer.set('name', 'osm-tile-layer');
799
+ this._map.addLayer(this.layer);
800
+ }
801
+ }
802
+ OsmTileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: OsmTileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
803
+ OsmTileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: { url: "url", map: "map" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
804
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: OsmTileLayerComponent, decorators: [{
805
+ type: Component,
806
+ args: [{
807
+ selector: 'lib-osm-tile-layer',
808
+ template: '',
809
+ styleUrls: [],
810
+ changeDetection: ChangeDetectionStrategy.OnPush,
811
+ }]
812
+ }], ctorParameters: function () { return []; }, propDecorators: { url: [{
813
+ type: Input
814
+ }], map: [{
815
+ type: Input
816
+ }] } });
817
+
818
+ class FeatureLayerSettings {
819
+ constructor() {
820
+ this.name = IdGenerator.get();
821
+ this.zIndex = 1;
822
+ this.maxZoom = 19;
823
+ this.minZoom = 0;
824
+ }
825
+ static copy(model) {
826
+ const result = new FeatureLayerSettings();
827
+ result.name = model.name;
828
+ result.maxZoom = model.maxZoom;
829
+ result.minZoom = model.minZoom;
830
+ result.zIndex = model.zIndex;
831
+ result.style = model.style;
832
+ return result;
833
+ }
834
+ setZIndex(zIndex) {
835
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex }));
836
+ }
837
+ setName(name) {
838
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { name }));
839
+ }
840
+ setMaxZoom(maxZoom) {
841
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
842
+ }
843
+ setMinZoom(minZoom) {
844
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
845
+ }
846
+ setStyle(style) {
847
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
848
+ }
849
+ isSame(model) {
850
+ if (this.maxZoom !== model.maxZoom)
851
+ return false;
794
852
  if (this.minZoom !== model.minZoom)
795
853
  return false;
796
854
  if (this.zIndex !== model.zIndex)
@@ -872,6 +930,295 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
872
930
  type: Input
873
931
  }] } });
874
932
 
933
+ class ClusterLayerSettings {
934
+ constructor() {
935
+ this.name = IdGenerator.get();
936
+ this.zIndex = 1;
937
+ this.maxZoom = 19;
938
+ this.minZoom = 0;
939
+ this.distance = 20;
940
+ this.bbox = false;
941
+ this.clusterCancel = 14;
942
+ }
943
+ static copy(model) {
944
+ const result = new ClusterLayerSettings();
945
+ result.name = model.name;
946
+ result.maxZoom = model.maxZoom;
947
+ result.minZoom = model.minZoom;
948
+ result.zIndex = model.zIndex;
949
+ result.bbox = model.bbox;
950
+ result.clusterCancel = model.clusterCancel;
951
+ result.distance = model.distance;
952
+ result.style = model.style;
953
+ return result;
954
+ }
955
+ setZIndex(zIndex) {
956
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex }));
957
+ }
958
+ setDistance(distance) {
959
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { distance }));
960
+ }
961
+ setName(name) {
962
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { name }));
963
+ }
964
+ setMaxZoom(maxZoom) {
965
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
966
+ }
967
+ setMinZoom(minZoom) {
968
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
969
+ }
970
+ setClusterCancel(clusterCancel) {
971
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { clusterCancel }));
972
+ }
973
+ setBbox(bbox) {
974
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { bbox }));
975
+ }
976
+ setStyle(style) {
977
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
978
+ }
979
+ isSame(model) {
980
+ if (this.maxZoom !== model.maxZoom)
981
+ return false;
982
+ if (this.minZoom !== model.minZoom)
983
+ return false;
984
+ if (this.zIndex !== model.zIndex)
985
+ return false;
986
+ if (this.name !== model.name)
987
+ return false;
988
+ if (this.distance !== model.distance)
989
+ return false;
990
+ if (this.clusterCancel !== model.clusterCancel)
991
+ return false;
992
+ if (this.bbox !== model.bbox)
993
+ return false;
994
+ if (this.style !== model.style)
995
+ return false;
996
+ return true;
997
+ }
998
+ }
999
+
1000
+ class ClusterLayerManager {
1001
+ constructor(settings, layer, postboy) {
1002
+ this.settings = settings;
1003
+ this.layer = layer;
1004
+ this.postboy = postboy;
1005
+ this.observeClick();
1006
+ this.observeMapMovement();
1007
+ }
1008
+ observeMapMovement() {
1009
+ combineLatest([
1010
+ this.postboy.subscribe(MapMoveEndEvent.ID).pipe(auditTime(250)),
1011
+ this.postboy.subscribe(MapRenderedEvent.ID),
1012
+ ]).subscribe(([movement, renderEvent]) => {
1013
+ this.checkClusterNecessity(renderEvent.map);
1014
+ });
1015
+ }
1016
+ observeClick() {
1017
+ this.postboy.subscribe(MapClickEvent.ID).subscribe((m) => {
1018
+ var _a, _b;
1019
+ if (((_b = (_a = m.features[this.settings.name]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 1) {
1020
+ this.postboy.fire(new FitToFeaturesCommand(m.features[this.settings.name], -1));
1021
+ }
1022
+ });
1023
+ }
1024
+ checkClusterNecessity(map) {
1025
+ var _a, _b, _c;
1026
+ let zoom = (_a = map.getView().getZoom()) !== null && _a !== void 0 ? _a : 0;
1027
+ const distance = zoom > this.settings.clusterCancel ? 0 : this.settings.distance;
1028
+ (_c = (_b = this.layer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.setDistance(distance);
1029
+ }
1030
+ }
1031
+
1032
+ class ClusterLayerFactory {
1033
+ build(settings, postboy) {
1034
+ const source = new Vector({
1035
+ strategy: settings.bbox ? bbox : undefined,
1036
+ });
1037
+ const cluster = new Cluster({
1038
+ distance: settings.distance,
1039
+ source: source,
1040
+ geometryFunction: (feature) => {
1041
+ var _a, _b;
1042
+ const geom = feature.getGeometry();
1043
+ if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Point') {
1044
+ return geom;
1045
+ }
1046
+ else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Polygon') {
1047
+ return (_a = geom) === null || _a === void 0 ? void 0 : _a.getInteriorPoint();
1048
+ }
1049
+ else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'MultiPolygon') {
1050
+ return (_b = fromExtent(geom.getExtent())) === null || _b === void 0 ? void 0 : _b.getInteriorPoint();
1051
+ }
1052
+ return undefined;
1053
+ },
1054
+ });
1055
+ const layer = new Vector$1({
1056
+ source: cluster,
1057
+ maxZoom: settings.maxZoom || undefined,
1058
+ minZoom: settings.minZoom || undefined,
1059
+ zIndex: settings.zIndex || 0,
1060
+ });
1061
+ layer.setStyle(this.styleFunc(settings));
1062
+ layer.set('name', settings.name);
1063
+ return new ClusterLayerManager(settings, layer, postboy);
1064
+ }
1065
+ styleFunc(settings) {
1066
+ return (feature) => {
1067
+ const features = feature.get('features');
1068
+ if (!settings.style)
1069
+ return undefined;
1070
+ return settings.style(features.map((f) => (Object.assign({ id: f.getId() }, f.get(MapConstants.FeatureInfo)))));
1071
+ };
1072
+ }
1073
+ }
1074
+ ClusterLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1075
+ ClusterLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerFactory, providedIn: 'root' });
1076
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerFactory, decorators: [{
1077
+ type: Injectable,
1078
+ args: [{
1079
+ providedIn: 'root',
1080
+ }]
1081
+ }] });
1082
+
1083
+ class ClusterLayerComponent extends DestructibleComponent {
1084
+ constructor(postboy, factory) {
1085
+ super();
1086
+ this.postboy = postboy;
1087
+ this.factory = factory;
1088
+ this.manager = null;
1089
+ this._settings = new ClusterLayerSettings();
1090
+ this.onDestroy = () => this.removeLayer();
1091
+ }
1092
+ ngOnInit() {
1093
+ this.postboy
1094
+ .subscribe(MapRenderedEvent.ID)
1095
+ .pipe(filter((m) => !!m), first())
1096
+ .subscribe((m) => this.initLayer());
1097
+ }
1098
+ set settings(value) {
1099
+ if (!value || this._settings.isSame(value))
1100
+ return;
1101
+ this._settings = value;
1102
+ this.initLayer();
1103
+ }
1104
+ initLayer() {
1105
+ this.removeLayer();
1106
+ this.manager = this.factory.build(this._settings, this.postboy);
1107
+ this.postboy.fire(new AddLayerCommand(this.manager.layer));
1108
+ }
1109
+ removeLayer() {
1110
+ var _a;
1111
+ if ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.layer)
1112
+ this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
1113
+ }
1114
+ }
1115
+ 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 });
1116
+ 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 });
1117
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ClusterLayerComponent, decorators: [{
1118
+ type: Component,
1119
+ args: [{
1120
+ selector: 'lib-cluster-layer',
1121
+ template: '',
1122
+ styleUrls: [],
1123
+ changeDetection: ChangeDetectionStrategy.OnPush,
1124
+ }]
1125
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
1126
+ type: Input
1127
+ }] } });
1128
+
1129
+ class MapPlateFactory {
1130
+ build(settings) {
1131
+ return new Map({
1132
+ controls: [],
1133
+ view: new View({
1134
+ center: (settings === null || settings === void 0 ? void 0 : settings.center) || [0, 0],
1135
+ zoom: (settings === null || settings === void 0 ? void 0 : settings.zoom) || 4,
1136
+ minZoom: (settings === null || settings === void 0 ? void 0 : settings.minZoom) || 0,
1137
+ maxZoom: (settings === null || settings === void 0 ? void 0 : settings.maxZoom) || 19,
1138
+ }),
1139
+ layers: [],
1140
+ });
1141
+ }
1142
+ }
1143
+ MapPlateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1144
+ MapPlateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, providedIn: 'root' });
1145
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, decorators: [{
1146
+ type: Injectable,
1147
+ args: [{
1148
+ providedIn: 'root',
1149
+ }]
1150
+ }] });
1151
+
1152
+ class MapPlateComponent extends DestructibleComponent {
1153
+ constructor(elementRef, postboy, mapFactory, registrator, detector) {
1154
+ super();
1155
+ this.elementRef = elementRef;
1156
+ this.postboy = postboy;
1157
+ this.mapFactory = mapFactory;
1158
+ this.registrator = registrator;
1159
+ this.detector = detector;
1160
+ this.osmUrl = '';
1161
+ this._settings = new MapSettings();
1162
+ this.drawingLayerSettings = new FeatureLayerSettings().setName(MapConstants.DrawingLayerId);
1163
+ this.onDestroy = () => {
1164
+ this.registrator.down();
1165
+ };
1166
+ registrator.up();
1167
+ }
1168
+ set settings(value) {
1169
+ if (!value || this._settings.isSame(value))
1170
+ return;
1171
+ this._settings = value;
1172
+ this.setOsm();
1173
+ }
1174
+ ngOnInit() {
1175
+ useGeographic();
1176
+ this.map = this.mapFactory.build(this._settings);
1177
+ this.map.setTarget(this.elementRef.nativeElement);
1178
+ this.detector.detectChanges();
1179
+ this.map.once('postrender', () => {
1180
+ this.map.updateSize();
1181
+ this.postboy.fire(new MapRenderedEvent(this.map));
1182
+ });
1183
+ this.setOsm();
1184
+ }
1185
+ setOsm() {
1186
+ if (!this.map)
1187
+ return;
1188
+ this.osmUrl = `https://mt{0-3}.google.com/vt/lyrs=${MapLyrsLabel.get(this._settings.lyrs)}&hl=${this._settings.language}&x={x}&y={y}&z={z}`;
1189
+ this.detector.detectChanges();
1190
+ this.map.updateSize();
1191
+ }
1192
+ }
1193
+ 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 });
1194
+ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [
1195
+ MessageRegistratorService,
1196
+ MapStateService,
1197
+ MapManagementService,
1198
+ MapClickService,
1199
+ MapFeatureService,
1200
+ DrawingService,
1201
+ ], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\r\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\r\n<lib-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></lib-feature-layer>\r\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"] }, { type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: ["settings"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1202
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
1203
+ type: Component,
1204
+ args: [{
1205
+ selector: 'lib-map-plate',
1206
+ templateUrl: './map-plate.component.html',
1207
+ styleUrls: ['./map-plate.component.scss'],
1208
+ changeDetection: ChangeDetectionStrategy.OnPush,
1209
+ providers: [
1210
+ MessageRegistratorService,
1211
+ MapStateService,
1212
+ MapManagementService,
1213
+ MapClickService,
1214
+ MapFeatureService,
1215
+ DrawingService,
1216
+ ],
1217
+ }]
1218
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1219
+ type: Input
1220
+ }] } });
1221
+
875
1222
  class MarkersComponent extends DestructibleComponent {
876
1223
  constructor(postboy) {
877
1224
  super();
@@ -1034,8 +1381,7 @@ class PolygonsComponent extends DestructibleComponent {
1034
1381
  .subscribe(() => this.putPolygons());
1035
1382
  }
1036
1383
  putPolygons() {
1037
- var _a;
1038
- if (!((_a = this._polygons) === null || _a === void 0 ? void 0 : _a.length))
1384
+ if (!this._polygons)
1039
1385
  return;
1040
1386
  this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
1041
1387
  }
@@ -1056,180 +1402,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
1056
1402
  type: Input
1057
1403
  }] } });
1058
1404
 
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
-
1233
1405
  class MapModule {
1234
1406
  }
1235
1407
  MapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -1338,5 +1510,5 @@ class TextStyleHelper {
1338
1510
  * Generated bundle index. Do not edit.
1339
1511
  */
1340
1512
 
1341
- export { CallbackMessage, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
1513
+ export { CancelDrawingCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
1342
1514
  //# sourceMappingURL=maps-components-src-map.js.map