@artstesh/maps 4.0.6 → 4.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/esm2020/map/helpers/index.mjs +2 -1
  2. package/dist/esm2020/map/helpers/marker-style.helper.mjs +5 -1
  3. package/dist/esm2020/map/helpers/text-style.helper.mjs +14 -0
  4. package/dist/esm2020/map/map-plate/features/polygons/polygons.component.mjs +2 -2
  5. package/dist/esm2020/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.mjs +59 -0
  6. package/dist/esm2020/map/map-plate/layers/cluster-layer/cluster-layer.component.mjs +50 -0
  7. package/dist/esm2020/map/map-plate/layers/cluster-layer/cluster-layer.manager.mjs +35 -0
  8. package/dist/esm2020/map/map-plate/layers/cluster-layer/cluster-layer.settings.mjs +68 -0
  9. package/dist/esm2020/map/map-plate/layers/index.mjs +3 -1
  10. package/dist/esm2020/map/map-plate/layers/tile-layer/tile-layer.component.mjs +1 -1
  11. package/dist/esm2020/map/map-plate/map-plate.component.mjs +23 -3
  12. package/dist/esm2020/map/map.module.mjs +8 -3
  13. package/dist/esm2020/map/messages/commands/add-layer.command.mjs +3 -3
  14. package/dist/esm2020/map/messages/commands/add-tile.command.mjs +3 -3
  15. package/dist/esm2020/map/messages/commands/cancel-drawing.command.mjs +8 -0
  16. package/dist/esm2020/map/messages/commands/close-tooltip.command.mjs +3 -3
  17. package/dist/esm2020/map/messages/commands/fit-to-features.command.mjs +13 -0
  18. package/dist/esm2020/map/messages/commands/place-layer-features.command.mjs +3 -3
  19. package/dist/esm2020/map/messages/commands/remove-layer.command.mjs +3 -3
  20. package/dist/esm2020/map/messages/commands/remove-tile.command.mjs +3 -3
  21. package/dist/esm2020/map/messages/commands/start-drawing.command.mjs +15 -0
  22. package/dist/esm2020/map/messages/events/drawing-finished.event.mjs +11 -0
  23. package/dist/esm2020/map/messages/events/map-click.event.mjs +5 -4
  24. package/dist/esm2020/map/messages/events/map-move-end.event.mjs +13 -0
  25. package/dist/esm2020/map/messages/events/map-rendered.event.mjs +3 -3
  26. package/dist/esm2020/map/messages/index.mjs +4 -2
  27. package/dist/esm2020/map/messages/queries/get-layer.query.mjs +12 -0
  28. package/dist/esm2020/map/models/drawing-type.enum.mjs +5 -0
  29. package/dist/esm2020/map/models/feature-format.enum.mjs +6 -0
  30. package/dist/esm2020/map/models/i-identified.mjs +2 -0
  31. package/dist/esm2020/map/models/index.mjs +3 -1
  32. package/dist/esm2020/map/models/map.constants.mjs +5 -0
  33. package/dist/esm2020/map/models/marker-model.mjs +3 -2
  34. package/dist/esm2020/map/services/drawing/drawing.service.mjs +79 -0
  35. package/dist/esm2020/map/services/map-click.service.mjs +7 -3
  36. package/dist/esm2020/map/services/map-feature.service.mjs +39 -0
  37. package/dist/esm2020/map/services/map-management.service.mjs +11 -3
  38. package/dist/esm2020/map/services/map-postboy.service.mjs +8 -5
  39. package/dist/esm2020/map/services/map-state.service.mjs +10 -2
  40. package/dist/esm2020/map/services/message-registrator.service.mjs +20 -6
  41. package/dist/esm2020/src/map/helpers/index.mjs +2 -1
  42. package/dist/esm2020/src/map/helpers/marker-style.helper.mjs +5 -1
  43. package/dist/esm2020/src/map/helpers/text-style.helper.mjs +14 -0
  44. package/dist/esm2020/src/map/map-plate/features/polygons/polygons.component.mjs +2 -2
  45. package/dist/esm2020/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.mjs +59 -0
  46. package/dist/esm2020/src/map/map-plate/layers/cluster-layer/cluster-layer.component.mjs +50 -0
  47. package/dist/esm2020/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.mjs +35 -0
  48. package/dist/esm2020/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.mjs +68 -0
  49. package/dist/esm2020/src/map/map-plate/layers/index.mjs +3 -1
  50. package/dist/esm2020/src/map/map-plate/layers/tile-layer/tile-layer.component.mjs +1 -1
  51. package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +23 -3
  52. package/dist/esm2020/src/map/map.module.mjs +8 -3
  53. package/dist/esm2020/src/map/messages/commands/add-layer.command.mjs +3 -3
  54. package/dist/esm2020/src/map/messages/commands/add-tile.command.mjs +3 -3
  55. package/dist/esm2020/src/map/messages/commands/cancel-drawing.command.mjs +8 -0
  56. package/dist/esm2020/src/map/messages/commands/close-tooltip.command.mjs +3 -3
  57. package/dist/esm2020/src/map/messages/commands/fit-to-features.command.mjs +13 -0
  58. package/dist/esm2020/src/map/messages/commands/place-layer-features.command.mjs +3 -3
  59. package/dist/esm2020/src/map/messages/commands/remove-layer.command.mjs +3 -3
  60. package/dist/esm2020/src/map/messages/commands/remove-tile.command.mjs +3 -3
  61. package/dist/esm2020/src/map/messages/commands/start-drawing.command.mjs +15 -0
  62. package/dist/esm2020/src/map/messages/events/drawing-finished.event.mjs +11 -0
  63. package/dist/esm2020/src/map/messages/events/map-click.event.mjs +5 -4
  64. package/dist/esm2020/src/map/messages/events/map-move-end.event.mjs +13 -0
  65. package/dist/esm2020/src/map/messages/events/map-rendered.event.mjs +3 -3
  66. package/dist/esm2020/src/map/messages/index.mjs +4 -2
  67. package/dist/esm2020/src/map/messages/queries/get-layer.query.mjs +12 -0
  68. package/dist/esm2020/src/map/models/drawing-type.enum.mjs +5 -0
  69. package/dist/esm2020/src/map/models/feature-format.enum.mjs +6 -0
  70. package/dist/esm2020/src/map/models/i-identified.mjs +2 -0
  71. package/dist/esm2020/src/map/models/index.mjs +3 -1
  72. package/dist/esm2020/src/map/models/map.constants.mjs +5 -0
  73. package/dist/esm2020/src/map/models/marker-model.mjs +3 -2
  74. package/dist/esm2020/src/map/services/drawing/drawing.service.mjs +79 -0
  75. package/dist/esm2020/src/map/services/map-click.service.mjs +7 -3
  76. package/dist/esm2020/src/map/services/map-feature.service.mjs +39 -0
  77. package/dist/esm2020/src/map/services/map-management.service.mjs +11 -3
  78. package/dist/esm2020/src/map/services/map-postboy.service.mjs +8 -5
  79. package/dist/esm2020/src/map/services/map-state.service.mjs +10 -2
  80. package/dist/esm2020/src/map/services/message-registrator.service.mjs +20 -6
  81. package/dist/fesm2015/maps-components-src-map.mjs +596 -174
  82. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  83. package/dist/fesm2015/maps-components.mjs +596 -174
  84. package/dist/fesm2015/maps-components.mjs.map +1 -1
  85. package/dist/fesm2020/maps-components-src-map.mjs +587 -171
  86. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  87. package/dist/fesm2020/maps-components.mjs +587 -171
  88. package/dist/fesm2020/maps-components.mjs.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/esm2020/map/messages/generic-message.mjs +0 -15
  162. package/dist/esm2020/src/map/messages/generic-message.mjs +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
@@ -5,20 +5,24 @@ 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
181
 
182
- class MapRenderedEvent extends GenericMessage {
182
+ var FeatureOutputFormat;
183
+ (function (FeatureOutputFormat) {
184
+ FeatureOutputFormat[FeatureOutputFormat["GeoJson"] = 1] = "GeoJson";
185
+ FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
186
+ })(FeatureOutputFormat || (FeatureOutputFormat = {}));
187
+
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: "15.2.10", ngImport: i0, type: MapPostboyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
350
+ MapPostboyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
279
351
  MapPostboyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService });
280
352
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", 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;
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 = source === null || source === void 0 ? void 0 : source.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: "15.2.10", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -359,6 +447,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", 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: "15.2.10", ngImport: i0, type: MapFeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
478
+ MapFeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapFeatureService });
479
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", 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: "15.2.10", 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: "15.2.10", ngImport: i0, type: DrawingService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
593
+ DrawingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingService });
594
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", 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,136 +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: "15.2.10", 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: "15.2.10", 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: "15.2.10", ngImport: i0, type: MessageRegistratorService });
426
622
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", 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: "15.2.10", ngImport: i0, type: MapPlateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
445
- MapPlateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, providedIn: 'root' });
446
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", 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: "15.2.10", ngImport: i0, type: OsmTileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
494
- OsmTileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", 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: "15.2.10", ngImport: i0, type: OsmTileLayerComponent, decorators: [{
496
- type: Component,
497
- args: [{ selector: 'lib-osm-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
498
- }], ctorParameters: function () { return []; }, propDecorators: { url: [{
499
- type: Input
500
- }], map: [{
501
- type: Input
502
- }] } });
503
-
504
- class MapPlateComponent extends DestructibleComponent {
505
- constructor(elementRef, postboy, mapFactory, registrator, detector) {
506
- super();
507
- this.elementRef = elementRef;
508
- this.postboy = postboy;
509
- this.mapFactory = mapFactory;
510
- this.registrator = registrator;
511
- this.detector = detector;
512
- this.osmUrl = '';
513
- this._settings = new MapSettings();
514
- this.onDestroy = () => {
515
- this.registrator.down();
516
- };
517
- registrator.up();
518
- }
519
- set settings(value) {
520
- if (!value || this._settings.isSame(value))
521
- return;
522
- this._settings = value;
523
- this.setOsm();
524
- }
525
- ngOnInit() {
526
- useGeographic();
527
- this.map = this.mapFactory.build(this._settings);
528
- this.map.setTarget(this.elementRef.nativeElement);
529
- this.detector.detectChanges();
530
- this.map.once('postrender', () => {
531
- this.map.updateSize();
532
- this.postboy.fire(new MapRenderedEvent(this.map));
533
- });
534
- this.setOsm();
535
- }
536
- setOsm() {
537
- if (!this.map)
538
- return;
539
- 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}`;
540
- this.detector.detectChanges();
541
- this.map.updateSize();
542
- }
543
- }
544
- MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
545
- MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
546
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
547
- type: Component,
548
- args: [{ selector: 'lib-map-plate', changeDetection: ChangeDetectionStrategy.OnPush, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService], template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"] }]
549
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
550
- type: Input
551
- }] } });
624
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
552
625
 
553
626
  class TileLayerSettings {
554
627
  constructor() {
@@ -681,6 +754,57 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
681
754
  type: Input
682
755
  }] } });
683
756
 
757
+ class OsmTileLayerComponent extends DestructibleComponent {
758
+ constructor() {
759
+ super();
760
+ this._url = '';
761
+ }
762
+ set url(value) {
763
+ if (!value || this._url === value)
764
+ return;
765
+ this._url = value;
766
+ this.initLayer();
767
+ }
768
+ set map(value) {
769
+ if (!value || this._map === value)
770
+ return;
771
+ this._map = value;
772
+ this.initLayer();
773
+ }
774
+ ngOnInit() { }
775
+ ngOnDestroy() {
776
+ var _a, _b;
777
+ if (this.layer) {
778
+ (_a = this._map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.layer);
779
+ }
780
+ // @ts-ignore
781
+ (_b = this.layer) === null || _b === void 0 ? void 0 : _b.setMap(null);
782
+ }
783
+ initLayer() {
784
+ if (!this._url || !this._map)
785
+ return;
786
+ if (this.layer)
787
+ this._map.removeLayer(this.layer);
788
+ this.layer = new TileLayer({
789
+ source: new OSM({
790
+ url: this._url,
791
+ }),
792
+ });
793
+ this.layer.set('name', 'osm-tile-layer');
794
+ this._map.addLayer(this.layer);
795
+ }
796
+ }
797
+ OsmTileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OsmTileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
798
+ OsmTileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: { url: "url", map: "map" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
799
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OsmTileLayerComponent, decorators: [{
800
+ type: Component,
801
+ args: [{ selector: 'lib-osm-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
802
+ }], ctorParameters: function () { return []; }, propDecorators: { url: [{
803
+ type: Input
804
+ }], map: [{
805
+ type: Input
806
+ }] } });
807
+
684
808
  class FeatureLayerSettings {
685
809
  constructor() {
686
810
  this.name = IdGenerator.get();
@@ -791,6 +915,284 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
791
915
  type: Input
792
916
  }] } });
793
917
 
918
+ class ClusterLayerSettings {
919
+ constructor() {
920
+ this.name = IdGenerator.get();
921
+ this.zIndex = 1;
922
+ this.maxZoom = 19;
923
+ this.minZoom = 0;
924
+ this.distance = 20;
925
+ this.bbox = false;
926
+ this.clusterCancel = 14;
927
+ }
928
+ static copy(model) {
929
+ const result = new ClusterLayerSettings();
930
+ result.name = model.name;
931
+ result.maxZoom = model.maxZoom;
932
+ result.minZoom = model.minZoom;
933
+ result.zIndex = model.zIndex;
934
+ result.bbox = model.bbox;
935
+ result.clusterCancel = model.clusterCancel;
936
+ result.distance = model.distance;
937
+ result.style = model.style;
938
+ return result;
939
+ }
940
+ setZIndex(zIndex) {
941
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex }));
942
+ }
943
+ setDistance(distance) {
944
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { distance }));
945
+ }
946
+ setName(name) {
947
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { name }));
948
+ }
949
+ setMaxZoom(maxZoom) {
950
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
951
+ }
952
+ setMinZoom(minZoom) {
953
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
954
+ }
955
+ setClusterCancel(clusterCancel) {
956
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { clusterCancel }));
957
+ }
958
+ setBbox(bbox) {
959
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { bbox }));
960
+ }
961
+ setStyle(style) {
962
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
963
+ }
964
+ isSame(model) {
965
+ if (this.maxZoom !== model.maxZoom)
966
+ return false;
967
+ if (this.minZoom !== model.minZoom)
968
+ return false;
969
+ if (this.zIndex !== model.zIndex)
970
+ return false;
971
+ if (this.name !== model.name)
972
+ return false;
973
+ if (this.distance !== model.distance)
974
+ return false;
975
+ if (this.clusterCancel !== model.clusterCancel)
976
+ return false;
977
+ if (this.bbox !== model.bbox)
978
+ return false;
979
+ if (this.style !== model.style)
980
+ return false;
981
+ return true;
982
+ }
983
+ }
984
+
985
+ class ClusterLayerManager {
986
+ constructor(settings, layer, postboy) {
987
+ this.settings = settings;
988
+ this.layer = layer;
989
+ this.postboy = postboy;
990
+ this.observeClick();
991
+ this.observeMapMovement();
992
+ }
993
+ observeMapMovement() {
994
+ combineLatest([
995
+ this.postboy.subscribe(MapMoveEndEvent.ID).pipe(auditTime(250)),
996
+ this.postboy.subscribe(MapRenderedEvent.ID),
997
+ ]).subscribe(([movement, renderEvent]) => {
998
+ this.checkClusterNecessity(renderEvent.map);
999
+ });
1000
+ }
1001
+ observeClick() {
1002
+ this.postboy.subscribe(MapClickEvent.ID).subscribe((m) => {
1003
+ var _a, _b;
1004
+ if (((_b = (_a = m.features[this.settings.name]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 1) {
1005
+ this.postboy.fire(new FitToFeaturesCommand(m.features[this.settings.name], -1));
1006
+ }
1007
+ });
1008
+ }
1009
+ checkClusterNecessity(map) {
1010
+ var _a, _b, _c;
1011
+ let zoom = (_a = map.getView().getZoom()) !== null && _a !== void 0 ? _a : 0;
1012
+ const distance = zoom > this.settings.clusterCancel ? 0 : this.settings.distance;
1013
+ (_c = (_b = this.layer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.setDistance(distance);
1014
+ }
1015
+ }
1016
+
1017
+ class ClusterLayerFactory {
1018
+ build(settings, postboy) {
1019
+ const source = new Vector({
1020
+ strategy: settings.bbox ? bbox : undefined,
1021
+ });
1022
+ const cluster = new Cluster({
1023
+ distance: settings.distance,
1024
+ source: source,
1025
+ geometryFunction: (feature) => {
1026
+ var _a;
1027
+ const geom = feature.getGeometry();
1028
+ if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Point') {
1029
+ return geom;
1030
+ }
1031
+ else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Polygon') {
1032
+ return geom === null || geom === void 0 ? void 0 : geom.getInteriorPoint();
1033
+ }
1034
+ else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'MultiPolygon') {
1035
+ return (_a = fromExtent(geom.getExtent())) === null || _a === void 0 ? void 0 : _a.getInteriorPoint();
1036
+ }
1037
+ return undefined;
1038
+ },
1039
+ });
1040
+ const layer = new Vector$1({
1041
+ source: cluster,
1042
+ maxZoom: settings.maxZoom || undefined,
1043
+ minZoom: settings.minZoom || undefined,
1044
+ zIndex: settings.zIndex || 0,
1045
+ });
1046
+ layer.setStyle(this.styleFunc(settings));
1047
+ layer.set('name', settings.name);
1048
+ return new ClusterLayerManager(settings, layer, postboy);
1049
+ }
1050
+ styleFunc(settings) {
1051
+ return (feature) => {
1052
+ const features = feature.get('features');
1053
+ if (!settings.style)
1054
+ return undefined;
1055
+ return settings.style(features.map((f) => (Object.assign({ id: f.getId() }, f.get(MapConstants.FeatureInfo)))));
1056
+ };
1057
+ }
1058
+ }
1059
+ ClusterLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1060
+ ClusterLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, providedIn: 'root' });
1061
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, decorators: [{
1062
+ type: Injectable,
1063
+ args: [{
1064
+ providedIn: 'root',
1065
+ }]
1066
+ }] });
1067
+
1068
+ class ClusterLayerComponent extends DestructibleComponent {
1069
+ constructor(postboy, factory) {
1070
+ super();
1071
+ this.postboy = postboy;
1072
+ this.factory = factory;
1073
+ this.manager = null;
1074
+ this._settings = new ClusterLayerSettings();
1075
+ this.onDestroy = () => this.removeLayer();
1076
+ }
1077
+ ngOnInit() {
1078
+ this.postboy
1079
+ .subscribe(MapRenderedEvent.ID)
1080
+ .pipe(filter((m) => !!m), first())
1081
+ .subscribe((m) => this.initLayer());
1082
+ }
1083
+ set settings(value) {
1084
+ if (!value || this._settings.isSame(value))
1085
+ return;
1086
+ this._settings = value;
1087
+ this.initLayer();
1088
+ }
1089
+ initLayer() {
1090
+ this.removeLayer();
1091
+ this.manager = this.factory.build(this._settings, this.postboy);
1092
+ this.postboy.fire(new AddLayerCommand(this.manager.layer));
1093
+ }
1094
+ removeLayer() {
1095
+ var _a;
1096
+ if ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.layer)
1097
+ this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
1098
+ }
1099
+ }
1100
+ ClusterLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerComponent, deps: [{ token: MapPostboyService }, { token: ClusterLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
1101
+ ClusterLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ClusterLayerComponent, selector: "lib-cluster-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1102
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerComponent, decorators: [{
1103
+ type: Component,
1104
+ args: [{ selector: 'lib-cluster-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
1105
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
1106
+ type: Input
1107
+ }] } });
1108
+
1109
+ class MapPlateFactory {
1110
+ build(settings) {
1111
+ return new Map({
1112
+ controls: [],
1113
+ view: new View({
1114
+ center: (settings === null || settings === void 0 ? void 0 : settings.center) || [0, 0],
1115
+ zoom: (settings === null || settings === void 0 ? void 0 : settings.zoom) || 4,
1116
+ minZoom: (settings === null || settings === void 0 ? void 0 : settings.minZoom) || 0,
1117
+ maxZoom: (settings === null || settings === void 0 ? void 0 : settings.maxZoom) || 19,
1118
+ }),
1119
+ layers: [],
1120
+ });
1121
+ }
1122
+ }
1123
+ MapPlateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1124
+ MapPlateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, providedIn: 'root' });
1125
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, decorators: [{
1126
+ type: Injectable,
1127
+ args: [{
1128
+ providedIn: 'root',
1129
+ }]
1130
+ }] });
1131
+
1132
+ class MapPlateComponent extends DestructibleComponent {
1133
+ constructor(elementRef, postboy, mapFactory, registrator, detector) {
1134
+ super();
1135
+ this.elementRef = elementRef;
1136
+ this.postboy = postboy;
1137
+ this.mapFactory = mapFactory;
1138
+ this.registrator = registrator;
1139
+ this.detector = detector;
1140
+ this.osmUrl = '';
1141
+ this._settings = new MapSettings();
1142
+ this.drawingLayerSettings = new FeatureLayerSettings().setName(MapConstants.DrawingLayerId);
1143
+ this.onDestroy = () => {
1144
+ this.registrator.down();
1145
+ };
1146
+ registrator.up();
1147
+ }
1148
+ set settings(value) {
1149
+ if (!value || this._settings.isSame(value))
1150
+ return;
1151
+ this._settings = value;
1152
+ this.setOsm();
1153
+ }
1154
+ ngOnInit() {
1155
+ useGeographic();
1156
+ this.map = this.mapFactory.build(this._settings);
1157
+ this.map.setTarget(this.elementRef.nativeElement);
1158
+ this.detector.detectChanges();
1159
+ this.map.once('postrender', () => {
1160
+ this.map.updateSize();
1161
+ this.postboy.fire(new MapRenderedEvent(this.map));
1162
+ });
1163
+ this.setOsm();
1164
+ }
1165
+ setOsm() {
1166
+ if (!this.map)
1167
+ return;
1168
+ 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}`;
1169
+ this.detector.detectChanges();
1170
+ this.map.updateSize();
1171
+ }
1172
+ }
1173
+ MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1174
+ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [
1175
+ MessageRegistratorService,
1176
+ MapStateService,
1177
+ MapManagementService,
1178
+ MapClickService,
1179
+ MapFeatureService,
1180
+ DrawingService,
1181
+ ], 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"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }, { kind: "component", type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: ["settings"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1182
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
1183
+ type: Component,
1184
+ args: [{ selector: 'lib-map-plate', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
1185
+ MessageRegistratorService,
1186
+ MapStateService,
1187
+ MapManagementService,
1188
+ MapClickService,
1189
+ MapFeatureService,
1190
+ DrawingService,
1191
+ ], 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"] }]
1192
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1193
+ type: Input
1194
+ }] } });
1195
+
794
1196
  class MarkersComponent extends DestructibleComponent {
795
1197
  constructor(postboy) {
796
1198
  super();
@@ -943,8 +1345,7 @@ class PolygonsComponent extends DestructibleComponent {
943
1345
  .subscribe(() => this.putPolygons());
944
1346
  }
945
1347
  putPolygons() {
946
- var _a;
947
- if (!((_a = this._polygons) === null || _a === void 0 ? void 0 : _a.length))
1348
+ if (!this._polygons)
948
1349
  return;
949
1350
  this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
950
1351
  }
@@ -970,12 +1371,14 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
970
1371
  FeatureLayerComponent,
971
1372
  MarkersComponent,
972
1373
  TooltipComponent,
973
- PolygonsComponent], imports: [CommonModule], exports: [MapPlateComponent,
1374
+ PolygonsComponent,
1375
+ ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
974
1376
  FeatureLayerComponent,
975
1377
  MarkersComponent,
976
1378
  TileLayerComponent,
977
1379
  TooltipComponent,
978
- PolygonsComponent] });
1380
+ PolygonsComponent,
1381
+ ClusterLayerComponent] });
979
1382
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
980
1383
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
981
1384
  type: NgModule,
@@ -990,6 +1393,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
990
1393
  MarkersComponent,
991
1394
  TooltipComponent,
992
1395
  PolygonsComponent,
1396
+ ClusterLayerComponent,
993
1397
  ],
994
1398
  exports: [
995
1399
  MapPlateComponent,
@@ -998,6 +1402,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
998
1402
  TileLayerComponent,
999
1403
  TooltipComponent,
1000
1404
  PolygonsComponent,
1405
+ ClusterLayerComponent,
1001
1406
  ],
1002
1407
  }]
1003
1408
  }] });
@@ -1023,6 +1428,10 @@ class MarkerStyleHelper {
1023
1428
  }),
1024
1429
  });
1025
1430
  }
1431
+ static withText(style, text) {
1432
+ style.setText(text);
1433
+ return style;
1434
+ }
1026
1435
  }
1027
1436
 
1028
1437
  class PolygonStyleHelper {
@@ -1039,6 +1448,19 @@ class PolygonStyleHelper {
1039
1448
  }
1040
1449
  }
1041
1450
 
1451
+ class TextStyleHelper {
1452
+ static get(text, font, color) {
1453
+ return new Text({
1454
+ text: text,
1455
+ font: font,
1456
+ textAlign: 'center',
1457
+ fill: new Fill({
1458
+ color: color,
1459
+ }),
1460
+ });
1461
+ }
1462
+ }
1463
+
1042
1464
  /*
1043
1465
  * Public API Surface of maps
1044
1466
  */
@@ -1051,5 +1473,5 @@ class PolygonStyleHelper {
1051
1473
  * Generated bundle index. Do not edit.
1052
1474
  */
1053
1475
 
1054
- export { CallbackMessage, CloseTooltipCommand, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
1476
+ 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 };
1055
1477
  //# sourceMappingURL=maps-components.mjs.map