@artstesh/maps 1.0.6 → 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 (164) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +784 -286
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +784 -286
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/helpers/index.js +2 -1
  6. package/dist/esm2015/map/helpers/marker-style.helper.js +5 -1
  7. package/dist/esm2015/map/helpers/text-style.helper.js +14 -0
  8. package/dist/esm2015/map/map-plate/features/polygons/polygons.component.js +2 -3
  9. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.js +60 -0
  10. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.component.js +56 -0
  11. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.manager.js +37 -0
  12. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.settings.js +68 -0
  13. package/dist/esm2015/map/map-plate/layers/index.js +3 -1
  14. package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.component.js +1 -1
  15. package/dist/esm2015/map/map-plate/map-plate.component.js +24 -4
  16. package/dist/esm2015/map/map.module.js +8 -3
  17. package/dist/esm2015/map/messages/commands/add-layer.command.js +3 -3
  18. package/dist/esm2015/map/messages/commands/add-tile.command.js +3 -3
  19. package/dist/esm2015/map/messages/commands/cancel-drawing.command.js +8 -0
  20. package/dist/esm2015/map/messages/commands/close-tooltip.command.js +3 -3
  21. package/dist/esm2015/map/messages/commands/fit-to-features.command.js +13 -0
  22. package/dist/esm2015/map/messages/commands/place-layer-features.command.js +3 -3
  23. package/dist/esm2015/map/messages/commands/remove-layer.command.js +3 -3
  24. package/dist/esm2015/map/messages/commands/remove-tile.command.js +3 -3
  25. package/dist/esm2015/map/messages/commands/start-drawing.command.js +15 -0
  26. package/dist/esm2015/map/messages/events/drawing-finished.event.js +11 -0
  27. package/dist/esm2015/map/messages/events/map-click.event.js +5 -4
  28. package/dist/esm2015/map/messages/events/map-move-end.event.js +13 -0
  29. package/dist/esm2015/map/messages/events/map-rendered.event.js +3 -3
  30. package/dist/esm2015/map/messages/index.js +4 -2
  31. package/dist/esm2015/map/messages/queries/get-layer.query.js +12 -0
  32. package/dist/esm2015/map/models/drawing-type.enum.js +5 -0
  33. package/dist/esm2015/map/models/feature-format.enum.js +6 -0
  34. package/dist/esm2015/map/models/i-identified.js +2 -0
  35. package/dist/esm2015/map/models/index.js +3 -1
  36. package/dist/esm2015/map/models/map.constants.js +5 -0
  37. package/dist/esm2015/map/models/marker-model.js +3 -2
  38. package/dist/esm2015/map/services/drawing/drawing.service.js +80 -0
  39. package/dist/esm2015/map/services/map-click.service.js +7 -3
  40. package/dist/esm2015/map/services/map-feature.service.js +39 -0
  41. package/dist/esm2015/map/services/map-management.service.js +12 -4
  42. package/dist/esm2015/map/services/map-postboy.service.js +8 -5
  43. package/dist/esm2015/map/services/map-state.service.js +12 -2
  44. package/dist/esm2015/map/services/message-registrator.service.js +20 -6
  45. package/dist/esm2015/src/map/helpers/index.js +2 -1
  46. package/dist/esm2015/src/map/helpers/marker-style.helper.js +5 -1
  47. package/dist/esm2015/src/map/helpers/text-style.helper.js +14 -0
  48. package/dist/esm2015/src/map/map-plate/features/polygons/polygons.component.js +2 -3
  49. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.js +60 -0
  50. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.component.js +56 -0
  51. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.js +37 -0
  52. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.js +68 -0
  53. package/dist/esm2015/src/map/map-plate/layers/index.js +3 -1
  54. package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.component.js +1 -1
  55. package/dist/esm2015/src/map/map-plate/map-plate.component.js +24 -4
  56. package/dist/esm2015/src/map/map.module.js +8 -3
  57. package/dist/esm2015/src/map/messages/commands/add-layer.command.js +3 -3
  58. package/dist/esm2015/src/map/messages/commands/add-tile.command.js +3 -3
  59. package/dist/esm2015/src/map/messages/commands/cancel-drawing.command.js +8 -0
  60. package/dist/esm2015/src/map/messages/commands/close-tooltip.command.js +3 -3
  61. package/dist/esm2015/src/map/messages/commands/fit-to-features.command.js +13 -0
  62. package/dist/esm2015/src/map/messages/commands/place-layer-features.command.js +3 -3
  63. package/dist/esm2015/src/map/messages/commands/remove-layer.command.js +3 -3
  64. package/dist/esm2015/src/map/messages/commands/remove-tile.command.js +3 -3
  65. package/dist/esm2015/src/map/messages/commands/start-drawing.command.js +15 -0
  66. package/dist/esm2015/src/map/messages/events/drawing-finished.event.js +11 -0
  67. package/dist/esm2015/src/map/messages/events/map-click.event.js +5 -4
  68. package/dist/esm2015/src/map/messages/events/map-move-end.event.js +13 -0
  69. package/dist/esm2015/src/map/messages/events/map-rendered.event.js +3 -3
  70. package/dist/esm2015/src/map/messages/index.js +4 -2
  71. package/dist/esm2015/src/map/messages/queries/get-layer.query.js +12 -0
  72. package/dist/esm2015/src/map/models/drawing-type.enum.js +5 -0
  73. package/dist/esm2015/src/map/models/feature-format.enum.js +6 -0
  74. package/dist/esm2015/src/map/models/i-identified.js +2 -0
  75. package/dist/esm2015/src/map/models/index.js +3 -1
  76. package/dist/esm2015/src/map/models/map.constants.js +5 -0
  77. package/dist/esm2015/src/map/models/marker-model.js +3 -2
  78. package/dist/esm2015/src/map/services/drawing/drawing.service.js +80 -0
  79. package/dist/esm2015/src/map/services/map-click.service.js +7 -3
  80. package/dist/esm2015/src/map/services/map-feature.service.js +39 -0
  81. package/dist/esm2015/src/map/services/map-management.service.js +12 -4
  82. package/dist/esm2015/src/map/services/map-postboy.service.js +8 -5
  83. package/dist/esm2015/src/map/services/map-state.service.js +12 -2
  84. package/dist/esm2015/src/map/services/message-registrator.service.js +20 -6
  85. package/dist/fesm2015/maps-components-src-map.js +613 -186
  86. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  87. package/dist/fesm2015/maps-components.js +613 -186
  88. package/dist/fesm2015/maps-components.js.map +1 -1
  89. package/dist/map/helpers/index.d.ts +1 -0
  90. package/dist/map/helpers/marker-style.helper.d.ts +2 -0
  91. package/dist/map/helpers/text-style.helper.d.ts +4 -0
  92. package/dist/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.d.ts +11 -0
  93. package/dist/map/map-plate/layers/cluster-layer/cluster-layer.component.d.ts +21 -0
  94. package/dist/map/map-plate/layers/cluster-layer/cluster-layer.manager.d.ts +13 -0
  95. package/dist/map/map-plate/layers/cluster-layer/cluster-layer.settings.d.ts +22 -0
  96. package/dist/map/map-plate/layers/index.d.ts +2 -0
  97. package/dist/map/map-plate/map-plate.component.d.ts +2 -0
  98. package/dist/map/map.module.d.ts +3 -2
  99. package/dist/map/messages/commands/add-layer.command.d.ts +6 -5
  100. package/dist/map/messages/commands/add-tile.command.d.ts +3 -3
  101. package/dist/map/messages/commands/cancel-drawing.command.d.ts +5 -0
  102. package/dist/map/messages/commands/close-tooltip.command.d.ts +3 -3
  103. package/dist/map/messages/commands/fit-to-features.command.d.ts +10 -0
  104. package/dist/map/messages/commands/place-layer-features.command.d.ts +3 -3
  105. package/dist/map/messages/commands/remove-layer.command.d.ts +3 -3
  106. package/dist/map/messages/commands/remove-tile.command.d.ts +3 -3
  107. package/dist/map/messages/commands/start-drawing.command.d.ts +11 -0
  108. package/dist/map/messages/events/drawing-finished.event.d.ts +6 -0
  109. package/dist/map/messages/events/map-click.event.d.ts +13 -5
  110. package/dist/map/messages/events/map-move-end.event.d.ts +8 -0
  111. package/dist/map/messages/events/map-rendered.event.d.ts +3 -3
  112. package/dist/map/messages/index.d.ts +3 -1
  113. package/dist/map/messages/queries/get-layer.query.d.ts +10 -0
  114. package/dist/map/models/drawing-type.enum.d.ts +3 -0
  115. package/dist/map/models/feature-format.enum.d.ts +4 -0
  116. package/dist/map/models/i-identified.d.ts +3 -0
  117. package/dist/map/models/index.d.ts +2 -0
  118. package/dist/map/models/map.constants.d.ts +4 -0
  119. package/dist/map/services/drawing/drawing.service.d.ts +17 -0
  120. package/dist/map/services/map-feature.service.d.ts +14 -0
  121. package/dist/map/services/map-management.service.d.ts +1 -0
  122. package/dist/map/services/map-postboy.service.d.ts +1 -2
  123. package/dist/map/services/message-registrator.service.d.ts +3 -1
  124. package/dist/package.json +1 -1
  125. package/dist/src/map/helpers/index.d.ts +1 -0
  126. package/dist/src/map/helpers/marker-style.helper.d.ts +2 -0
  127. package/dist/src/map/helpers/text-style.helper.d.ts +4 -0
  128. package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.d.ts +11 -0
  129. package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.component.d.ts +21 -0
  130. package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.d.ts +13 -0
  131. package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.d.ts +22 -0
  132. package/dist/src/map/map-plate/layers/index.d.ts +2 -0
  133. package/dist/src/map/map-plate/map-plate.component.d.ts +2 -0
  134. package/dist/src/map/map.module.d.ts +3 -2
  135. package/dist/src/map/messages/commands/add-layer.command.d.ts +6 -5
  136. package/dist/src/map/messages/commands/add-tile.command.d.ts +3 -3
  137. package/dist/src/map/messages/commands/cancel-drawing.command.d.ts +5 -0
  138. package/dist/src/map/messages/commands/close-tooltip.command.d.ts +3 -3
  139. package/dist/src/map/messages/commands/fit-to-features.command.d.ts +10 -0
  140. package/dist/src/map/messages/commands/place-layer-features.command.d.ts +3 -3
  141. package/dist/src/map/messages/commands/remove-layer.command.d.ts +3 -3
  142. package/dist/src/map/messages/commands/remove-tile.command.d.ts +3 -3
  143. package/dist/src/map/messages/commands/start-drawing.command.d.ts +11 -0
  144. package/dist/src/map/messages/events/drawing-finished.event.d.ts +6 -0
  145. package/dist/src/map/messages/events/map-click.event.d.ts +13 -5
  146. package/dist/src/map/messages/events/map-move-end.event.d.ts +8 -0
  147. package/dist/src/map/messages/events/map-rendered.event.d.ts +3 -3
  148. package/dist/src/map/messages/index.d.ts +3 -1
  149. package/dist/src/map/messages/queries/get-layer.query.d.ts +10 -0
  150. package/dist/src/map/models/drawing-type.enum.d.ts +3 -0
  151. package/dist/src/map/models/feature-format.enum.d.ts +4 -0
  152. package/dist/src/map/models/i-identified.d.ts +3 -0
  153. package/dist/src/map/models/index.d.ts +2 -0
  154. package/dist/src/map/models/map.constants.d.ts +4 -0
  155. package/dist/src/map/services/drawing/drawing.service.d.ts +17 -0
  156. package/dist/src/map/services/map-feature.service.d.ts +14 -0
  157. package/dist/src/map/services/map-management.service.d.ts +1 -0
  158. package/dist/src/map/services/map-postboy.service.d.ts +1 -2
  159. package/dist/src/map/services/message-registrator.service.d.ts +3 -1
  160. package/package.json +2 -2
  161. package/dist/esm2015/map/messages/generic-message.js +0 -15
  162. package/dist/esm2015/src/map/messages/generic-message.js +0 -15
  163. package/dist/map/messages/generic-message.d.ts +0 -9
  164. package/dist/src/map/messages/generic-message.d.ts +0 -9
@@ -1,24 +1,28 @@
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
- import { getCenter } 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';
8
+ import { getCenter, createEmpty, extend } from 'ol/extent';
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';
17
+ import { bbox } from 'ol/loadingstrategy';
18
+ import { fromExtent } from 'ol/geom/Polygon';
19
+ import Cluster from 'ol/source/Cluster';
20
+ import { combineLatest } from 'rxjs';
21
+ import Map from 'ol/Map';
22
+ import View from 'ol/View';
19
23
  import Overlay from 'ol/Overlay';
20
24
  import Style from 'ol/style/Style';
21
- import { Icon, Circle, Fill, Stroke } from 'ol/style';
25
+ import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
22
26
 
23
27
  class DestructibleComponent {
24
28
  constructor() {
@@ -122,6 +126,11 @@ class IdGenerator {
122
126
  }
123
127
  IdGenerator.collection = 'ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789'.split('');
124
128
 
129
+ class MapConstants {
130
+ }
131
+ MapConstants.FeatureInfo = 'f-info';
132
+ MapConstants.DrawingLayerId = '93a981756ec7';
133
+
125
134
  class MarkerModel {
126
135
  constructor(lat, lng, id, info) {
127
136
  this.lat = lat;
@@ -137,7 +146,7 @@ class MarkerModel {
137
146
  const feature = new Feature(new Point([this.lng, this.lat]));
138
147
  feature.setId(this.id);
139
148
  if (this.info)
140
- feature.set('info', this.info);
149
+ feature.set(MapConstants.FeatureInfo, this.info);
141
150
  return feature;
142
151
  }
143
152
  }
@@ -165,21 +174,18 @@ class PolygonModel {
165
174
  }
166
175
  }
167
176
 
168
- class GenericMessage {
169
- }
170
- class CallbackMessage extends GenericMessage {
171
- constructor() {
172
- super(...arguments);
173
- this.result$ = new Subject();
174
- this.result = this.result$.asObservable();
175
- }
176
- finish(value) {
177
- this.result$.next(value);
178
- this.result$.complete();
179
- }
180
- }
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 = {}));
181
187
 
182
- class MapRenderedEvent extends GenericMessage {
188
+ class MapRenderedEvent extends PostboyGenericMessage {
183
189
  constructor(map) {
184
190
  super();
185
191
  this.map = map;
@@ -190,11 +196,12 @@ class MapRenderedEvent extends GenericMessage {
190
196
  }
191
197
  MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
192
198
 
193
- class MapClickEvent extends GenericMessage {
194
- constructor(coordinates, entities) {
199
+ class MapClickEvent extends PostboyGenericMessage {
200
+ constructor(coordinates, entities, features) {
195
201
  super();
196
202
  this.coordinates = coordinates;
197
203
  this.entities = entities;
204
+ this.features = features;
198
205
  }
199
206
  get id() {
200
207
  return MapClickEvent.ID;
@@ -202,7 +209,19 @@ class MapClickEvent extends GenericMessage {
202
209
  }
203
210
  MapClickEvent.ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
204
211
 
205
- 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 {
206
225
  constructor(tooltipId) {
207
226
  super();
208
227
  this.tooltipId = tooltipId;
@@ -213,7 +232,27 @@ class CloseTooltipCommand extends GenericMessage {
213
232
  }
214
233
  CloseTooltipCommand.ID = '4896d52c-e34f-4994-bcfd-32832d12dbe4';
215
234
 
216
- 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 {
217
256
  constructor(layer) {
218
257
  super();
219
258
  this.layer = layer;
@@ -224,7 +263,7 @@ class AddLayerCommand extends GenericMessage {
224
263
  }
225
264
  AddLayerCommand.ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
226
265
 
227
- class PlaceLayerFeaturesCommand extends GenericMessage {
266
+ class PlaceLayerFeaturesCommand extends PostboyGenericMessage {
228
267
  constructor(layer, features) {
229
268
  super();
230
269
  this.layer = layer;
@@ -236,7 +275,7 @@ class PlaceLayerFeaturesCommand extends GenericMessage {
236
275
  }
237
276
  PlaceLayerFeaturesCommand.ID = '8caf86bc-869b-426f-b36d-4642f6b8aab0';
238
277
 
239
- class RemoveLayerCommand extends GenericMessage {
278
+ class RemoveLayerCommand extends PostboyGenericMessage {
240
279
  constructor(layer) {
241
280
  super();
242
281
  this.layer = layer;
@@ -247,7 +286,7 @@ class RemoveLayerCommand extends GenericMessage {
247
286
  }
248
287
  RemoveLayerCommand.ID = 'ab484e0e-e185-45cd-8434-12101f3c7eb1';
249
288
 
250
- class AddTileCommand extends GenericMessage {
289
+ class AddTileCommand extends PostboyGenericMessage {
251
290
  constructor(layer) {
252
291
  super();
253
292
  this.layer = layer;
@@ -258,7 +297,7 @@ class AddTileCommand extends GenericMessage {
258
297
  }
259
298
  AddTileCommand.ID = '25b7df28-72ce-4453-9fe6-54285a2fdc57';
260
299
 
261
- class RemoveTileCommand extends GenericMessage {
300
+ class RemoveTileCommand extends PostboyGenericMessage {
262
301
  constructor(layer) {
263
302
  super();
264
303
  this.layer = layer;
@@ -269,17 +308,50 @@ class RemoveTileCommand extends GenericMessage {
269
308
  }
270
309
  RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
271
310
 
311
+ class FitToFeaturesCommand extends PostboyGenericMessage {
312
+ constructor(features, zoomAfter = 0) {
313
+ super();
314
+ this.features = features;
315
+ this.zoomAfter = zoomAfter;
316
+ }
317
+ get id() {
318
+ return FitToFeaturesCommand.ID;
319
+ }
320
+ }
321
+ FitToFeaturesCommand.ID = '76cdc091-3793-4b6c-82f7-1e0334cf08a8';
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
+
272
344
  class MapPostboyService extends PostboyService {
273
345
  constructor() {
274
- super(...arguments);
275
- this.observe = (id) => this.subscribe(id);
346
+ super();
347
+ this.addLocker({ locker: StartDrawingCommand.ID, unlocker: DrawingFinishedEvent.ID, locking: [MapClickEvent.ID] });
276
348
  }
277
349
  }
278
- 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 });
279
351
  MapPostboyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPostboyService });
280
352
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPostboyService, decorators: [{
281
353
  type: Injectable
282
- }] });
354
+ }], ctorParameters: function () { return []; } });
283
355
 
284
356
  class MapManagementService {
285
357
  constructor(postboy) {
@@ -293,6 +365,7 @@ class MapManagementService {
293
365
  this.observePlaceFeatures();
294
366
  this.observeAddTile();
295
367
  this.observeRemoveTile();
368
+ this.observeLayerQuery();
296
369
  }
297
370
  observeRemoveTile() {
298
371
  this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
@@ -301,6 +374,9 @@ class MapManagementService {
301
374
  this.map.removeLayer(c.layer);
302
375
  });
303
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
+ }
304
380
  observeAddTile() {
305
381
  this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
306
382
  if (!this.map)
@@ -323,11 +399,14 @@ class MapManagementService {
323
399
  }
324
400
  observePlaceFeatures() {
325
401
  this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
326
- var _a, _b, _c;
402
+ var _a, _b;
327
403
  if (!this.layers[c.layer])
328
404
  return;
329
- (_b = (_a = this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear();
330
- (_c = this.layers[c.layer].getSource()) === null || _c === void 0 ? void 0 : _c.addFeatures(c.features);
405
+ let source = (_a = this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource();
406
+ if (!!source['getSource'])
407
+ source = (_b = source) === null || _b === void 0 ? void 0 : _b.getSource();
408
+ source === null || source === void 0 ? void 0 : source.clear();
409
+ source === null || source === void 0 ? void 0 : source.addFeatures(c.features);
331
410
  });
332
411
  }
333
412
  observeRemoveLayer() {
@@ -350,7 +429,16 @@ class MapStateService {
350
429
  this.postboy = postboy;
351
430
  }
352
431
  up() {
353
- 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
+ });
354
442
  }
355
443
  }
356
444
  MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -359,6 +447,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
359
447
  type: Injectable
360
448
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
361
449
 
450
+ class MapFeatureService {
451
+ constructor(postboy) {
452
+ this.postboy = postboy;
453
+ }
454
+ up() {
455
+ this.observeMapRender();
456
+ this.observeFitToFeatures();
457
+ }
458
+ observeMapRender() {
459
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
460
+ this.map = m.map;
461
+ });
462
+ }
463
+ observeFitToFeatures() {
464
+ this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((m) => {
465
+ this.fitToGeometries(m.features.map((f) => f.getGeometry()), m.zoomAfter);
466
+ });
467
+ }
468
+ fitToGeometries(geometries, zoomAfter) {
469
+ if (!(geometries === null || geometries === void 0 ? void 0 : geometries.length) || !this.map)
470
+ return;
471
+ const extent = createEmpty();
472
+ geometries.forEach((g) => extend(extent, g.getExtent()));
473
+ this.map.getView().fit(extent);
474
+ this.map.getView().setZoom(this.map.getView().getZoom() + zoomAfter);
475
+ }
476
+ }
477
+ MapFeatureService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapFeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
478
+ MapFeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapFeatureService });
479
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapFeatureService, decorators: [{
480
+ type: Injectable
481
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
482
+
362
483
  class MapClickService {
363
484
  constructor(postboy) {
364
485
  this.postboy = postboy;
@@ -377,7 +498,7 @@ class MapClickService {
377
498
  }
378
499
  onClick(ev) {
379
500
  var _a;
380
- const model = new MapClickEvent(ev.coordinate, {});
501
+ const model = new MapClickEvent(ev.coordinate, {}, {});
381
502
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.forEachFeatureAtPixel(ev.pixel, (f, l) => {
382
503
  this.getFeatureCollectionWithInner([f])
383
504
  .filter((f) => f.getId() != null)
@@ -385,7 +506,10 @@ class MapClickService {
385
506
  let layerName = l.get('name');
386
507
  if (!model.entities[layerName])
387
508
  model.entities[layerName] = [];
388
- model.entities[layerName].push(f.getId());
509
+ if (!model.features[layerName])
510
+ model.features[layerName] = [];
511
+ model.entities[layerName].push(Object.assign({ id: fs.getId() }, fs.get(MapConstants.FeatureInfo)));
512
+ model.features[layerName].push(fs);
389
513
  });
390
514
  });
391
515
  return model;
@@ -405,10 +529,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
405
529
  type: Injectable
406
530
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
407
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
+
408
598
  class MessageRegistratorService extends PostboyAbstractRegistrator {
409
- constructor(service, management, state, interaction) {
599
+ constructor(service, management, state, feature, interaction, drawing) {
410
600
  super(service);
411
- this.registerServices([management, state, interaction]);
601
+ this.registerServices([management, state, interaction, feature, drawing]);
412
602
  }
413
603
  _up() {
414
604
  this.registerReplay(MapRenderedEvent.ID);
@@ -419,147 +609,19 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
419
609
  this.registerSubject(RemoveTileCommand.ID);
420
610
  this.registerSubject(MapClickEvent.ID);
421
611
  this.registerSubject(CloseTooltipCommand.ID);
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);
422
618
  }
423
619
  }
424
- MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
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 });
425
621
  MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService });
426
622
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, decorators: [{
427
623
  type: Injectable
428
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapClickService }]; } });
429
-
430
- class MapPlateFactory {
431
- build(settings) {
432
- return new Map({
433
- controls: [],
434
- view: new View({
435
- center: (settings === null || settings === void 0 ? void 0 : settings.center) || [0, 0],
436
- zoom: (settings === null || settings === void 0 ? void 0 : settings.zoom) || 4,
437
- minZoom: (settings === null || settings === void 0 ? void 0 : settings.minZoom) || 0,
438
- maxZoom: (settings === null || settings === void 0 ? void 0 : settings.maxZoom) || 19,
439
- }),
440
- layers: [],
441
- });
442
- }
443
- }
444
- MapPlateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
445
- MapPlateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, providedIn: 'root' });
446
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateFactory, decorators: [{
447
- type: Injectable,
448
- args: [{
449
- providedIn: 'root',
450
- }]
451
- }] });
452
-
453
- class OsmTileLayerComponent extends DestructibleComponent {
454
- constructor() {
455
- super();
456
- this._url = '';
457
- }
458
- set url(value) {
459
- if (!value || this._url === value)
460
- return;
461
- this._url = value;
462
- this.initLayer();
463
- }
464
- set map(value) {
465
- if (!value || this._map === value)
466
- return;
467
- this._map = value;
468
- this.initLayer();
469
- }
470
- ngOnInit() { }
471
- ngOnDestroy() {
472
- var _a, _b;
473
- if (this.layer) {
474
- (_a = this._map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.layer);
475
- }
476
- // @ts-ignore
477
- (_b = this.layer) === null || _b === void 0 ? void 0 : _b.setMap(null);
478
- }
479
- initLayer() {
480
- if (!this._url || !this._map)
481
- return;
482
- if (this.layer)
483
- this._map.removeLayer(this.layer);
484
- this.layer = new TileLayer({
485
- source: new OSM({
486
- url: this._url,
487
- }),
488
- });
489
- this.layer.set('name', 'osm-tile-layer');
490
- this._map.addLayer(this.layer);
491
- }
492
- }
493
- OsmTileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: OsmTileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
494
- 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 });
495
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: OsmTileLayerComponent, decorators: [{
496
- type: Component,
497
- args: [{
498
- selector: 'lib-osm-tile-layer',
499
- template: '',
500
- styleUrls: [],
501
- changeDetection: ChangeDetectionStrategy.OnPush,
502
- }]
503
- }], ctorParameters: function () { return []; }, propDecorators: { url: [{
504
- type: Input
505
- }], map: [{
506
- type: Input
507
- }] } });
508
-
509
- class MapPlateComponent extends DestructibleComponent {
510
- constructor(elementRef, postboy, mapFactory, registrator, detector) {
511
- super();
512
- this.elementRef = elementRef;
513
- this.postboy = postboy;
514
- this.mapFactory = mapFactory;
515
- this.registrator = registrator;
516
- this.detector = detector;
517
- this.osmUrl = '';
518
- this._settings = new MapSettings();
519
- this.onDestroy = () => {
520
- this.registrator.down();
521
- };
522
- registrator.up();
523
- }
524
- set settings(value) {
525
- if (!value || this._settings.isSame(value))
526
- return;
527
- this._settings = value;
528
- this.setOsm();
529
- }
530
- ngOnInit() {
531
- useGeographic();
532
- this.map = this.mapFactory.build(this._settings);
533
- this.map.setTarget(this.elementRef.nativeElement);
534
- this.detector.detectChanges();
535
- this.map.once('postrender', () => {
536
- this.map.updateSize();
537
- this.postboy.fire(new MapRenderedEvent(this.map));
538
- });
539
- this.setOsm();
540
- }
541
- setOsm() {
542
- if (!this.map)
543
- return;
544
- 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}`;
545
- this.detector.detectChanges();
546
- this.map.updateSize();
547
- }
548
- }
549
- MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
550
- MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
551
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
552
- type: Component,
553
- args: [{
554
- selector: 'lib-map-plate',
555
- templateUrl: './map-plate.component.html',
556
- styleUrls: ['./map-plate.component.scss'],
557
- changeDetection: ChangeDetectionStrategy.OnPush,
558
- providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService],
559
- }]
560
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
561
- type: Input
562
- }] } });
624
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
563
625
 
564
626
  class TileLayerSettings {
565
627
  constructor() {
@@ -697,6 +759,62 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
697
759
  type: Input
698
760
  }] } });
699
761
 
762
+ class OsmTileLayerComponent extends DestructibleComponent {
763
+ constructor() {
764
+ super();
765
+ this._url = '';
766
+ }
767
+ set url(value) {
768
+ if (!value || this._url === value)
769
+ return;
770
+ this._url = value;
771
+ this.initLayer();
772
+ }
773
+ set map(value) {
774
+ if (!value || this._map === value)
775
+ return;
776
+ this._map = value;
777
+ this.initLayer();
778
+ }
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);
787
+ }
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
+
700
818
  class FeatureLayerSettings {
701
819
  constructor() {
702
820
  this.name = IdGenerator.get();
@@ -812,6 +930,295 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
812
930
  type: Input
813
931
  }] } });
814
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
+
815
1222
  class MarkersComponent extends DestructibleComponent {
816
1223
  constructor(postboy) {
817
1224
  super();
@@ -974,8 +1381,7 @@ class PolygonsComponent extends DestructibleComponent {
974
1381
  .subscribe(() => this.putPolygons());
975
1382
  }
976
1383
  putPolygons() {
977
- var _a;
978
- if (!((_a = this._polygons) === null || _a === void 0 ? void 0 : _a.length))
1384
+ if (!this._polygons)
979
1385
  return;
980
1386
  this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
981
1387
  }
@@ -1006,12 +1412,14 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.
1006
1412
  FeatureLayerComponent,
1007
1413
  MarkersComponent,
1008
1414
  TooltipComponent,
1009
- PolygonsComponent], imports: [CommonModule], exports: [MapPlateComponent,
1415
+ PolygonsComponent,
1416
+ ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
1010
1417
  FeatureLayerComponent,
1011
1418
  MarkersComponent,
1012
1419
  TileLayerComponent,
1013
1420
  TooltipComponent,
1014
- PolygonsComponent] });
1421
+ PolygonsComponent,
1422
+ ClusterLayerComponent] });
1015
1423
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, imports: [[CommonModule]] });
1016
1424
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, decorators: [{
1017
1425
  type: NgModule,
@@ -1026,6 +1434,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
1026
1434
  MarkersComponent,
1027
1435
  TooltipComponent,
1028
1436
  PolygonsComponent,
1437
+ ClusterLayerComponent,
1029
1438
  ],
1030
1439
  exports: [
1031
1440
  MapPlateComponent,
@@ -1034,6 +1443,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
1034
1443
  TileLayerComponent,
1035
1444
  TooltipComponent,
1036
1445
  PolygonsComponent,
1446
+ ClusterLayerComponent,
1037
1447
  ],
1038
1448
  }]
1039
1449
  }] });
@@ -1059,6 +1469,10 @@ class MarkerStyleHelper {
1059
1469
  }),
1060
1470
  });
1061
1471
  }
1472
+ static withText(style, text) {
1473
+ style.setText(text);
1474
+ return style;
1475
+ }
1062
1476
  }
1063
1477
 
1064
1478
  class PolygonStyleHelper {
@@ -1075,6 +1489,19 @@ class PolygonStyleHelper {
1075
1489
  }
1076
1490
  }
1077
1491
 
1492
+ class TextStyleHelper {
1493
+ static get(text, font, color) {
1494
+ return new Text({
1495
+ text: text,
1496
+ font: font,
1497
+ textAlign: 'center',
1498
+ fill: new Fill({
1499
+ color: color,
1500
+ }),
1501
+ });
1502
+ }
1503
+ }
1504
+
1078
1505
  /*
1079
1506
  * Public API Surface of maps
1080
1507
  */
@@ -1087,5 +1514,5 @@ class PolygonStyleHelper {
1087
1514
  * Generated bundle index. Do not edit.
1088
1515
  */
1089
1516
 
1090
- export { CallbackMessage, CloseTooltipCommand, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
1517
+ 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 };
1091
1518
  //# sourceMappingURL=maps-components.js.map