@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
  }
@@ -164,21 +173,18 @@ class PolygonModel {
164
173
  }
165
174
  }
166
175
 
167
- class GenericMessage {
168
- }
169
- class CallbackMessage extends GenericMessage {
170
- constructor() {
171
- super(...arguments);
172
- this.result$ = new Subject();
173
- this.result = this.result$.asObservable();
174
- }
175
- finish(value) {
176
- this.result$.next(value);
177
- this.result$.complete();
178
- }
179
- }
176
+ var DrawingType;
177
+ (function (DrawingType) {
178
+ DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
179
+ })(DrawingType || (DrawingType = {}));
180
180
 
181
- class MapRenderedEvent extends GenericMessage {
181
+ var FeatureOutputFormat;
182
+ (function (FeatureOutputFormat) {
183
+ FeatureOutputFormat[FeatureOutputFormat["GeoJson"] = 1] = "GeoJson";
184
+ FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
185
+ })(FeatureOutputFormat || (FeatureOutputFormat = {}));
186
+
187
+ class MapRenderedEvent extends PostboyGenericMessage {
182
188
  constructor(map) {
183
189
  super();
184
190
  this.map = map;
@@ -189,11 +195,12 @@ class MapRenderedEvent extends GenericMessage {
189
195
  }
190
196
  MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
191
197
 
192
- class MapClickEvent extends GenericMessage {
193
- constructor(coordinates, entities) {
198
+ class MapClickEvent extends PostboyGenericMessage {
199
+ constructor(coordinates, entities, features) {
194
200
  super();
195
201
  this.coordinates = coordinates;
196
202
  this.entities = entities;
203
+ this.features = features;
197
204
  }
198
205
  get id() {
199
206
  return MapClickEvent.ID;
@@ -201,7 +208,19 @@ class MapClickEvent extends GenericMessage {
201
208
  }
202
209
  MapClickEvent.ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
203
210
 
204
- class CloseTooltipCommand extends GenericMessage {
211
+ class MapMoveEndEvent extends PostboyGenericMessage {
212
+ constructor(zoom, extent) {
213
+ super();
214
+ this.zoom = zoom;
215
+ this.extent = extent;
216
+ }
217
+ get id() {
218
+ return MapMoveEndEvent.ID;
219
+ }
220
+ }
221
+ MapMoveEndEvent.ID = 'f21f783e-b5af-4489-9fec-8027fd07a8ad';
222
+
223
+ class CloseTooltipCommand extends PostboyGenericMessage {
205
224
  constructor(tooltipId) {
206
225
  super();
207
226
  this.tooltipId = tooltipId;
@@ -212,7 +231,27 @@ class CloseTooltipCommand extends GenericMessage {
212
231
  }
213
232
  CloseTooltipCommand.ID = '4896d52c-e34f-4994-bcfd-32832d12dbe4';
214
233
 
215
- class AddLayerCommand extends GenericMessage {
234
+ class StartDrawingCommand extends PostboyCallbackMessage {
235
+ constructor(type, style, format = FeatureOutputFormat.GeoJson) {
236
+ super();
237
+ this.type = type;
238
+ this.style = style;
239
+ this.format = format;
240
+ }
241
+ get id() {
242
+ return StartDrawingCommand.ID;
243
+ }
244
+ }
245
+ StartDrawingCommand.ID = 'da904f4b-a1c8-4db7-a6af-14d9ee18ec8c';
246
+
247
+ class CancelDrawingCommand extends PostboyGenericMessage {
248
+ get id() {
249
+ return CancelDrawingCommand.ID;
250
+ }
251
+ }
252
+ CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
253
+
254
+ class AddLayerCommand extends PostboyGenericMessage {
216
255
  constructor(layer) {
217
256
  super();
218
257
  this.layer = layer;
@@ -223,7 +262,7 @@ class AddLayerCommand extends GenericMessage {
223
262
  }
224
263
  AddLayerCommand.ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
225
264
 
226
- class PlaceLayerFeaturesCommand extends GenericMessage {
265
+ class PlaceLayerFeaturesCommand extends PostboyGenericMessage {
227
266
  constructor(layer, features) {
228
267
  super();
229
268
  this.layer = layer;
@@ -235,7 +274,7 @@ class PlaceLayerFeaturesCommand extends GenericMessage {
235
274
  }
236
275
  PlaceLayerFeaturesCommand.ID = '8caf86bc-869b-426f-b36d-4642f6b8aab0';
237
276
 
238
- class RemoveLayerCommand extends GenericMessage {
277
+ class RemoveLayerCommand extends PostboyGenericMessage {
239
278
  constructor(layer) {
240
279
  super();
241
280
  this.layer = layer;
@@ -246,7 +285,7 @@ class RemoveLayerCommand extends GenericMessage {
246
285
  }
247
286
  RemoveLayerCommand.ID = 'ab484e0e-e185-45cd-8434-12101f3c7eb1';
248
287
 
249
- class AddTileCommand extends GenericMessage {
288
+ class AddTileCommand extends PostboyGenericMessage {
250
289
  constructor(layer) {
251
290
  super();
252
291
  this.layer = layer;
@@ -257,7 +296,7 @@ class AddTileCommand extends GenericMessage {
257
296
  }
258
297
  AddTileCommand.ID = '25b7df28-72ce-4453-9fe6-54285a2fdc57';
259
298
 
260
- class RemoveTileCommand extends GenericMessage {
299
+ class RemoveTileCommand extends PostboyGenericMessage {
261
300
  constructor(layer) {
262
301
  super();
263
302
  this.layer = layer;
@@ -268,17 +307,50 @@ class RemoveTileCommand extends GenericMessage {
268
307
  }
269
308
  RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
270
309
 
310
+ class FitToFeaturesCommand extends PostboyGenericMessage {
311
+ constructor(features, zoomAfter = 0) {
312
+ super();
313
+ this.features = features;
314
+ this.zoomAfter = zoomAfter;
315
+ }
316
+ get id() {
317
+ return FitToFeaturesCommand.ID;
318
+ }
319
+ }
320
+ FitToFeaturesCommand.ID = '76cdc091-3793-4b6c-82f7-1e0334cf08a8';
321
+
322
+ class GetLayerQuery extends PostboyCallbackMessage {
323
+ constructor(name) {
324
+ super();
325
+ this.name = name;
326
+ }
327
+ get id() {
328
+ return GetLayerQuery.ID;
329
+ }
330
+ }
331
+ GetLayerQuery.ID = '5c04c87b-8a93-4c2a-979e-d1e313d860ed';
332
+
333
+ class DrawingFinishedEvent extends PostboyGenericMessage {
334
+ constructor() {
335
+ super();
336
+ }
337
+ get id() {
338
+ return DrawingFinishedEvent.ID;
339
+ }
340
+ }
341
+ DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
342
+
271
343
  class MapPostboyService extends PostboyService {
272
344
  constructor() {
273
- super(...arguments);
274
- this.observe = (id) => this.subscribe(id);
345
+ super();
346
+ this.addLocker({ locker: StartDrawingCommand.ID, unlocker: DrawingFinishedEvent.ID, locking: [MapClickEvent.ID] });
275
347
  }
276
348
  }
277
- MapPostboyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
349
+ MapPostboyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
278
350
  MapPostboyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService });
279
351
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService, decorators: [{
280
352
  type: Injectable
281
- }] });
353
+ }], ctorParameters: function () { return []; } });
282
354
 
283
355
  class MapManagementService {
284
356
  constructor(postboy) {
@@ -292,6 +364,7 @@ class MapManagementService {
292
364
  this.observePlaceFeatures();
293
365
  this.observeAddTile();
294
366
  this.observeRemoveTile();
367
+ this.observeLayerQuery();
295
368
  }
296
369
  observeRemoveTile() {
297
370
  this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
@@ -300,6 +373,9 @@ class MapManagementService {
300
373
  this.map.removeLayer(c.layer);
301
374
  });
302
375
  }
376
+ observeLayerQuery() {
377
+ this.postboy.subscribe(GetLayerQuery.ID).subscribe((ev) => ev.finish(this.layers[ev.name] ?? null));
378
+ }
303
379
  observeAddTile() {
304
380
  this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
305
381
  if (!this.map)
@@ -324,8 +400,11 @@ class MapManagementService {
324
400
  this.postboy.subscribe(PlaceLayerFeaturesCommand.ID).subscribe((c) => {
325
401
  if (!this.layers[c.layer])
326
402
  return;
327
- this.layers[c.layer]?.getSource()?.clear();
328
- this.layers[c.layer].getSource()?.addFeatures(c.features);
403
+ let source = this.layers[c.layer]?.getSource();
404
+ if (!!source['getSource'])
405
+ source = source?.getSource();
406
+ source?.clear();
407
+ source?.addFeatures(c.features);
329
408
  });
330
409
  }
331
410
  observeRemoveLayer() {
@@ -348,7 +427,14 @@ class MapStateService {
348
427
  this.postboy = postboy;
349
428
  }
350
429
  up() {
351
- this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => (this.map = m));
430
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe((ev) => {
431
+ this.map = ev.map;
432
+ this.map?.on('moveend', () => {
433
+ const zoom = Math.floor(this.map?.getView().getZoom() || -1);
434
+ const extent = this.map?.getView().calculateExtent() || [];
435
+ this.postboy.fire(new MapMoveEndEvent(zoom, extent));
436
+ });
437
+ });
352
438
  }
353
439
  }
354
440
  MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -357,6 +443,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
357
443
  type: Injectable
358
444
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
359
445
 
446
+ class MapFeatureService {
447
+ constructor(postboy) {
448
+ this.postboy = postboy;
449
+ }
450
+ up() {
451
+ this.observeMapRender();
452
+ this.observeFitToFeatures();
453
+ }
454
+ observeMapRender() {
455
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
456
+ this.map = m.map;
457
+ });
458
+ }
459
+ observeFitToFeatures() {
460
+ this.postboy.subscribe(FitToFeaturesCommand.ID).subscribe((m) => {
461
+ this.fitToGeometries(m.features.map((f) => f.getGeometry()), m.zoomAfter);
462
+ });
463
+ }
464
+ fitToGeometries(geometries, zoomAfter) {
465
+ if (!geometries?.length || !this.map)
466
+ return;
467
+ const extent = createEmpty();
468
+ geometries.forEach((g) => extend(extent, g.getExtent()));
469
+ this.map.getView().fit(extent);
470
+ this.map.getView().setZoom(this.map.getView().getZoom() + zoomAfter);
471
+ }
472
+ }
473
+ MapFeatureService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapFeatureService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
474
+ MapFeatureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapFeatureService });
475
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapFeatureService, decorators: [{
476
+ type: Injectable
477
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
478
+
360
479
  class MapClickService {
361
480
  constructor(postboy) {
362
481
  this.postboy = postboy;
@@ -373,7 +492,7 @@ class MapClickService {
373
492
  });
374
493
  }
375
494
  onClick(ev) {
376
- const model = new MapClickEvent(ev.coordinate, {});
495
+ const model = new MapClickEvent(ev.coordinate, {}, {});
377
496
  this.map?.forEachFeatureAtPixel(ev.pixel, (f, l) => {
378
497
  this.getFeatureCollectionWithInner([f])
379
498
  .filter((f) => f.getId() != null)
@@ -381,7 +500,10 @@ class MapClickService {
381
500
  let layerName = l.get('name');
382
501
  if (!model.entities[layerName])
383
502
  model.entities[layerName] = [];
384
- model.entities[layerName].push(f.getId());
503
+ if (!model.features[layerName])
504
+ model.features[layerName] = [];
505
+ model.entities[layerName].push({ id: fs.getId(), ...fs.get(MapConstants.FeatureInfo) });
506
+ model.features[layerName].push(fs);
385
507
  });
386
508
  });
387
509
  return model;
@@ -401,10 +523,75 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
401
523
  type: Injectable
402
524
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
403
525
 
526
+ class DrawingService {
527
+ constructor(postboy) {
528
+ this.postboy = postboy;
529
+ }
530
+ up() {
531
+ this.postboy.subscribe(StartDrawingCommand.ID).subscribe((ev) => {
532
+ this.draw((l) => {
533
+ if (!l || !this.map) {
534
+ this.clearInteraction(l);
535
+ return;
536
+ }
537
+ const cancelSub = this.observeCancelation(ev, l);
538
+ this.drawInteraction = new Draw({
539
+ source: l.getSource(),
540
+ type: DrawingType[ev.type],
541
+ style: ev.style,
542
+ });
543
+ this.map.addInteraction(this.drawInteraction);
544
+ this.drawInteraction.on('drawend', (evt) => {
545
+ cancelSub.unsubscribe();
546
+ this.onEnd(evt, ev, l);
547
+ });
548
+ });
549
+ });
550
+ this.observeMapRender();
551
+ }
552
+ onEnd(evt, command, layer) {
553
+ command.finish(command.format === FeatureOutputFormat.GeoJson
554
+ ? new GeoJSON().writeFeature(evt.feature)
555
+ : new WKT().writeFeature(evt.feature));
556
+ this.clearInteraction(layer);
557
+ }
558
+ observeMapRender() {
559
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
560
+ this.map = m.map;
561
+ });
562
+ }
563
+ draw(action) {
564
+ const query = new GetLayerQuery(MapConstants.DrawingLayerId);
565
+ query.result.subscribe((l) => action(l));
566
+ this.postboy.fire(query);
567
+ }
568
+ observeCancelation(ev, layer) {
569
+ return this.postboy
570
+ .subscribe(CancelDrawingCommand.ID)
571
+ .pipe(first())
572
+ .subscribe(() => {
573
+ ev.finish(null);
574
+ this.clearInteraction(layer);
575
+ });
576
+ }
577
+ clearInteraction(layer) {
578
+ if (!!this.drawInteraction) {
579
+ this.map?.removeInteraction(this.drawInteraction);
580
+ layer?.setSource(new Vector({}));
581
+ }
582
+ setTimeout(() => this.postboy.fire(new DrawingFinishedEvent()), 300);
583
+ }
584
+ }
585
+ DrawingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
586
+ DrawingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingService });
587
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DrawingService, decorators: [{
588
+ type: Injectable
589
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
590
+
404
591
  class MessageRegistratorService extends PostboyAbstractRegistrator {
405
- constructor(service, management, state, interaction) {
592
+ constructor(service, management, state, feature, interaction, drawing) {
406
593
  super(service);
407
- this.registerServices([management, state, interaction]);
594
+ this.registerServices([management, state, interaction, feature, drawing]);
408
595
  }
409
596
  _up() {
410
597
  this.registerReplay(MapRenderedEvent.ID);
@@ -415,135 +602,19 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
415
602
  this.registerSubject(RemoveTileCommand.ID);
416
603
  this.registerSubject(MapClickEvent.ID);
417
604
  this.registerSubject(CloseTooltipCommand.ID);
605
+ this.registerSubject(FitToFeaturesCommand.ID);
606
+ this.registerSubject(MapMoveEndEvent.ID);
607
+ this.registerSubject(CancelDrawingCommand.ID);
608
+ this.registerSubject(StartDrawingCommand.ID);
609
+ this.registerSubject(GetLayerQuery.ID);
610
+ this.registerSubject(DrawingFinishedEvent.ID);
418
611
  }
419
612
  }
420
- 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 });
613
+ 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 });
421
614
  MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
422
615
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
423
616
  type: Injectable
424
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapClickService }]; } });
425
-
426
- class MapPlateFactory {
427
- build(settings) {
428
- return new Map({
429
- controls: [],
430
- view: new View({
431
- center: settings?.center || [0, 0],
432
- zoom: settings?.zoom || 4,
433
- minZoom: settings?.minZoom || 0,
434
- maxZoom: settings?.maxZoom || 19,
435
- }),
436
- layers: [],
437
- });
438
- }
439
- }
440
- MapPlateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
441
- MapPlateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, providedIn: 'root' });
442
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, decorators: [{
443
- type: Injectable,
444
- args: [{
445
- providedIn: 'root',
446
- }]
447
- }] });
448
-
449
- class OsmTileLayerComponent extends DestructibleComponent {
450
- constructor() {
451
- super();
452
- this._url = '';
453
- }
454
- set url(value) {
455
- if (!value || this._url === value)
456
- return;
457
- this._url = value;
458
- this.initLayer();
459
- }
460
- set map(value) {
461
- if (!value || this._map === value)
462
- return;
463
- this._map = value;
464
- this.initLayer();
465
- }
466
- ngOnInit() { }
467
- ngOnDestroy() {
468
- if (this.layer) {
469
- this._map?.removeLayer(this.layer);
470
- }
471
- // @ts-ignore
472
- this.layer?.setMap(null);
473
- }
474
- initLayer() {
475
- if (!this._url || !this._map)
476
- return;
477
- if (this.layer)
478
- this._map.removeLayer(this.layer);
479
- this.layer = new TileLayer({
480
- source: new OSM({
481
- url: this._url,
482
- }),
483
- });
484
- this.layer.set('name', 'osm-tile-layer');
485
- this._map.addLayer(this.layer);
486
- }
487
- }
488
- OsmTileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OsmTileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
489
- 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 });
490
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OsmTileLayerComponent, decorators: [{
491
- type: Component,
492
- args: [{ selector: 'lib-osm-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
493
- }], ctorParameters: function () { return []; }, propDecorators: { url: [{
494
- type: Input
495
- }], map: [{
496
- type: Input
497
- }] } });
498
-
499
- class MapPlateComponent extends DestructibleComponent {
500
- constructor(elementRef, postboy, mapFactory, registrator, detector) {
501
- super();
502
- this.elementRef = elementRef;
503
- this.postboy = postboy;
504
- this.mapFactory = mapFactory;
505
- this.registrator = registrator;
506
- this.detector = detector;
507
- this.osmUrl = '';
508
- this._settings = new MapSettings();
509
- this.onDestroy = () => {
510
- this.registrator.down();
511
- };
512
- registrator.up();
513
- }
514
- set settings(value) {
515
- if (!value || this._settings.isSame(value))
516
- return;
517
- this._settings = value;
518
- this.setOsm();
519
- }
520
- ngOnInit() {
521
- useGeographic();
522
- this.map = this.mapFactory.build(this._settings);
523
- this.map.setTarget(this.elementRef.nativeElement);
524
- this.detector.detectChanges();
525
- this.map.once('postrender', () => {
526
- this.map.updateSize();
527
- this.postboy.fire(new MapRenderedEvent(this.map));
528
- });
529
- this.setOsm();
530
- }
531
- setOsm() {
532
- if (!this.map)
533
- return;
534
- 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}`;
535
- this.detector.detectChanges();
536
- this.map.updateSize();
537
- }
538
- }
539
- 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 });
540
- 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 });
541
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
542
- type: Component,
543
- 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"] }]
544
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
545
- type: Input
546
- }] } });
617
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }]; } });
547
618
 
548
619
  class TileLayerSettings {
549
620
  constructor() {
@@ -676,6 +747,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
676
747
  type: Input
677
748
  }] } });
678
749
 
750
+ class OsmTileLayerComponent extends DestructibleComponent {
751
+ constructor() {
752
+ super();
753
+ this._url = '';
754
+ }
755
+ set url(value) {
756
+ if (!value || this._url === value)
757
+ return;
758
+ this._url = value;
759
+ this.initLayer();
760
+ }
761
+ set map(value) {
762
+ if (!value || this._map === value)
763
+ return;
764
+ this._map = value;
765
+ this.initLayer();
766
+ }
767
+ ngOnInit() { }
768
+ ngOnDestroy() {
769
+ if (this.layer) {
770
+ this._map?.removeLayer(this.layer);
771
+ }
772
+ // @ts-ignore
773
+ this.layer?.setMap(null);
774
+ }
775
+ initLayer() {
776
+ if (!this._url || !this._map)
777
+ return;
778
+ if (this.layer)
779
+ this._map.removeLayer(this.layer);
780
+ this.layer = new TileLayer({
781
+ source: new OSM({
782
+ url: this._url,
783
+ }),
784
+ });
785
+ this.layer.set('name', 'osm-tile-layer');
786
+ this._map.addLayer(this.layer);
787
+ }
788
+ }
789
+ OsmTileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OsmTileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
790
+ 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 });
791
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OsmTileLayerComponent, decorators: [{
792
+ type: Component,
793
+ args: [{ selector: 'lib-osm-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
794
+ }], ctorParameters: function () { return []; }, propDecorators: { url: [{
795
+ type: Input
796
+ }], map: [{
797
+ type: Input
798
+ }] } });
799
+
679
800
  class FeatureLayerSettings {
680
801
  constructor() {
681
802
  this.name = IdGenerator.get();
@@ -786,6 +907,280 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
786
907
  type: Input
787
908
  }] } });
788
909
 
910
+ class ClusterLayerSettings {
911
+ constructor() {
912
+ this.name = IdGenerator.get();
913
+ this.zIndex = 1;
914
+ this.maxZoom = 19;
915
+ this.minZoom = 0;
916
+ this.distance = 20;
917
+ this.bbox = false;
918
+ this.clusterCancel = 14;
919
+ }
920
+ static copy(model) {
921
+ const result = new ClusterLayerSettings();
922
+ result.name = model.name;
923
+ result.maxZoom = model.maxZoom;
924
+ result.minZoom = model.minZoom;
925
+ result.zIndex = model.zIndex;
926
+ result.bbox = model.bbox;
927
+ result.clusterCancel = model.clusterCancel;
928
+ result.distance = model.distance;
929
+ result.style = model.style;
930
+ return result;
931
+ }
932
+ setZIndex(zIndex) {
933
+ return ClusterLayerSettings.copy({ ...this, zIndex });
934
+ }
935
+ setDistance(distance) {
936
+ return ClusterLayerSettings.copy({ ...this, distance });
937
+ }
938
+ setName(name) {
939
+ return ClusterLayerSettings.copy({ ...this, name });
940
+ }
941
+ setMaxZoom(maxZoom) {
942
+ return ClusterLayerSettings.copy({ ...this, maxZoom });
943
+ }
944
+ setMinZoom(minZoom) {
945
+ return ClusterLayerSettings.copy({ ...this, minZoom });
946
+ }
947
+ setClusterCancel(clusterCancel) {
948
+ return ClusterLayerSettings.copy({ ...this, clusterCancel });
949
+ }
950
+ setBbox(bbox) {
951
+ return ClusterLayerSettings.copy({ ...this, bbox });
952
+ }
953
+ setStyle(style) {
954
+ return ClusterLayerSettings.copy({ ...this, style });
955
+ }
956
+ isSame(model) {
957
+ if (this.maxZoom !== model.maxZoom)
958
+ return false;
959
+ if (this.minZoom !== model.minZoom)
960
+ return false;
961
+ if (this.zIndex !== model.zIndex)
962
+ return false;
963
+ if (this.name !== model.name)
964
+ return false;
965
+ if (this.distance !== model.distance)
966
+ return false;
967
+ if (this.clusterCancel !== model.clusterCancel)
968
+ return false;
969
+ if (this.bbox !== model.bbox)
970
+ return false;
971
+ if (this.style !== model.style)
972
+ return false;
973
+ return true;
974
+ }
975
+ }
976
+
977
+ class ClusterLayerManager {
978
+ constructor(settings, layer, postboy) {
979
+ this.settings = settings;
980
+ this.layer = layer;
981
+ this.postboy = postboy;
982
+ this.observeClick();
983
+ this.observeMapMovement();
984
+ }
985
+ observeMapMovement() {
986
+ combineLatest([
987
+ this.postboy.subscribe(MapMoveEndEvent.ID).pipe(auditTime(250)),
988
+ this.postboy.subscribe(MapRenderedEvent.ID),
989
+ ]).subscribe(([movement, renderEvent]) => {
990
+ this.checkClusterNecessity(renderEvent.map);
991
+ });
992
+ }
993
+ observeClick() {
994
+ this.postboy.subscribe(MapClickEvent.ID).subscribe((m) => {
995
+ if ((m.features[this.settings.name]?.length ?? 0) > 1) {
996
+ this.postboy.fire(new FitToFeaturesCommand(m.features[this.settings.name], -1));
997
+ }
998
+ });
999
+ }
1000
+ checkClusterNecessity(map) {
1001
+ let zoom = map.getView().getZoom() ?? 0;
1002
+ const distance = zoom > this.settings.clusterCancel ? 0 : this.settings.distance;
1003
+ this.layer?.getSource()?.setDistance(distance);
1004
+ }
1005
+ }
1006
+
1007
+ class ClusterLayerFactory {
1008
+ build(settings, postboy) {
1009
+ const source = new Vector({
1010
+ strategy: settings.bbox ? bbox : undefined,
1011
+ });
1012
+ const cluster = new Cluster({
1013
+ distance: settings.distance,
1014
+ source: source,
1015
+ geometryFunction: (feature) => {
1016
+ const geom = feature.getGeometry();
1017
+ if (geom?.getType() == 'Point') {
1018
+ return geom;
1019
+ }
1020
+ else if (geom?.getType() == 'Polygon') {
1021
+ return geom?.getInteriorPoint();
1022
+ }
1023
+ else if (geom?.getType() == 'MultiPolygon') {
1024
+ return fromExtent(geom.getExtent())?.getInteriorPoint();
1025
+ }
1026
+ return undefined;
1027
+ },
1028
+ });
1029
+ const layer = new Vector$1({
1030
+ source: cluster,
1031
+ maxZoom: settings.maxZoom || undefined,
1032
+ minZoom: settings.minZoom || undefined,
1033
+ zIndex: settings.zIndex || 0,
1034
+ });
1035
+ layer.setStyle(this.styleFunc(settings));
1036
+ layer.set('name', settings.name);
1037
+ return new ClusterLayerManager(settings, layer, postboy);
1038
+ }
1039
+ styleFunc(settings) {
1040
+ return (feature) => {
1041
+ const features = feature.get('features');
1042
+ if (!settings.style)
1043
+ return undefined;
1044
+ return settings.style(features.map((f) => ({ id: f.getId(), ...f.get(MapConstants.FeatureInfo) })));
1045
+ };
1046
+ }
1047
+ }
1048
+ ClusterLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1049
+ ClusterLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, providedIn: 'root' });
1050
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerFactory, decorators: [{
1051
+ type: Injectable,
1052
+ args: [{
1053
+ providedIn: 'root',
1054
+ }]
1055
+ }] });
1056
+
1057
+ class ClusterLayerComponent extends DestructibleComponent {
1058
+ constructor(postboy, factory) {
1059
+ super();
1060
+ this.postboy = postboy;
1061
+ this.factory = factory;
1062
+ this.manager = null;
1063
+ this._settings = new ClusterLayerSettings();
1064
+ this.onDestroy = () => this.removeLayer();
1065
+ }
1066
+ ngOnInit() {
1067
+ this.postboy
1068
+ .subscribe(MapRenderedEvent.ID)
1069
+ .pipe(filter((m) => !!m), first())
1070
+ .subscribe((m) => this.initLayer());
1071
+ }
1072
+ set settings(value) {
1073
+ if (!value || this._settings.isSame(value))
1074
+ return;
1075
+ this._settings = value;
1076
+ this.initLayer();
1077
+ }
1078
+ initLayer() {
1079
+ this.removeLayer();
1080
+ this.manager = this.factory.build(this._settings, this.postboy);
1081
+ this.postboy.fire(new AddLayerCommand(this.manager.layer));
1082
+ }
1083
+ removeLayer() {
1084
+ if (this.manager?.layer)
1085
+ this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
1086
+ }
1087
+ }
1088
+ 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 });
1089
+ 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 });
1090
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ClusterLayerComponent, decorators: [{
1091
+ type: Component,
1092
+ args: [{ selector: 'lib-cluster-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
1093
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
1094
+ type: Input
1095
+ }] } });
1096
+
1097
+ class MapPlateFactory {
1098
+ build(settings) {
1099
+ return new Map({
1100
+ controls: [],
1101
+ view: new View({
1102
+ center: settings?.center || [0, 0],
1103
+ zoom: settings?.zoom || 4,
1104
+ minZoom: settings?.minZoom || 0,
1105
+ maxZoom: settings?.maxZoom || 19,
1106
+ }),
1107
+ layers: [],
1108
+ });
1109
+ }
1110
+ }
1111
+ MapPlateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1112
+ MapPlateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, providedIn: 'root' });
1113
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateFactory, decorators: [{
1114
+ type: Injectable,
1115
+ args: [{
1116
+ providedIn: 'root',
1117
+ }]
1118
+ }] });
1119
+
1120
+ class MapPlateComponent extends DestructibleComponent {
1121
+ constructor(elementRef, postboy, mapFactory, registrator, detector) {
1122
+ super();
1123
+ this.elementRef = elementRef;
1124
+ this.postboy = postboy;
1125
+ this.mapFactory = mapFactory;
1126
+ this.registrator = registrator;
1127
+ this.detector = detector;
1128
+ this.osmUrl = '';
1129
+ this._settings = new MapSettings();
1130
+ this.drawingLayerSettings = new FeatureLayerSettings().setName(MapConstants.DrawingLayerId);
1131
+ this.onDestroy = () => {
1132
+ this.registrator.down();
1133
+ };
1134
+ registrator.up();
1135
+ }
1136
+ set settings(value) {
1137
+ if (!value || this._settings.isSame(value))
1138
+ return;
1139
+ this._settings = value;
1140
+ this.setOsm();
1141
+ }
1142
+ ngOnInit() {
1143
+ useGeographic();
1144
+ this.map = this.mapFactory.build(this._settings);
1145
+ this.map.setTarget(this.elementRef.nativeElement);
1146
+ this.detector.detectChanges();
1147
+ this.map.once('postrender', () => {
1148
+ this.map.updateSize();
1149
+ this.postboy.fire(new MapRenderedEvent(this.map));
1150
+ });
1151
+ this.setOsm();
1152
+ }
1153
+ setOsm() {
1154
+ if (!this.map)
1155
+ return;
1156
+ 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}`;
1157
+ this.detector.detectChanges();
1158
+ this.map.updateSize();
1159
+ }
1160
+ }
1161
+ 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 });
1162
+ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [
1163
+ MessageRegistratorService,
1164
+ MapStateService,
1165
+ MapManagementService,
1166
+ MapClickService,
1167
+ MapFeatureService,
1168
+ DrawingService,
1169
+ ], 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 });
1170
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
1171
+ type: Component,
1172
+ args: [{ selector: 'lib-map-plate', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
1173
+ MessageRegistratorService,
1174
+ MapStateService,
1175
+ MapManagementService,
1176
+ MapClickService,
1177
+ MapFeatureService,
1178
+ DrawingService,
1179
+ ], 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"] }]
1180
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1181
+ type: Input
1182
+ }] } });
1183
+
789
1184
  class MarkersComponent extends DestructibleComponent {
790
1185
  constructor(postboy) {
791
1186
  super();
@@ -934,7 +1329,7 @@ class PolygonsComponent extends DestructibleComponent {
934
1329
  .subscribe(() => this.putPolygons());
935
1330
  }
936
1331
  putPolygons() {
937
- if (!this._polygons?.length)
1332
+ if (!this._polygons)
938
1333
  return;
939
1334
  this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
940
1335
  }
@@ -960,12 +1355,14 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
960
1355
  FeatureLayerComponent,
961
1356
  MarkersComponent,
962
1357
  TooltipComponent,
963
- PolygonsComponent], imports: [CommonModule], exports: [MapPlateComponent,
1358
+ PolygonsComponent,
1359
+ ClusterLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
964
1360
  FeatureLayerComponent,
965
1361
  MarkersComponent,
966
1362
  TileLayerComponent,
967
1363
  TooltipComponent,
968
- PolygonsComponent] });
1364
+ PolygonsComponent,
1365
+ ClusterLayerComponent] });
969
1366
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
970
1367
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
971
1368
  type: NgModule,
@@ -980,6 +1377,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
980
1377
  MarkersComponent,
981
1378
  TooltipComponent,
982
1379
  PolygonsComponent,
1380
+ ClusterLayerComponent,
983
1381
  ],
984
1382
  exports: [
985
1383
  MapPlateComponent,
@@ -988,6 +1386,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
988
1386
  TileLayerComponent,
989
1387
  TooltipComponent,
990
1388
  PolygonsComponent,
1389
+ ClusterLayerComponent,
991
1390
  ],
992
1391
  }]
993
1392
  }] });
@@ -1013,6 +1412,10 @@ class MarkerStyleHelper {
1013
1412
  }),
1014
1413
  });
1015
1414
  }
1415
+ static withText(style, text) {
1416
+ style.setText(text);
1417
+ return style;
1418
+ }
1016
1419
  }
1017
1420
 
1018
1421
  class PolygonStyleHelper {
@@ -1029,6 +1432,19 @@ class PolygonStyleHelper {
1029
1432
  }
1030
1433
  }
1031
1434
 
1435
+ class TextStyleHelper {
1436
+ static get(text, font, color) {
1437
+ return new Text({
1438
+ text: text,
1439
+ font: font,
1440
+ textAlign: 'center',
1441
+ fill: new Fill({
1442
+ color: color,
1443
+ }),
1444
+ });
1445
+ }
1446
+ }
1447
+
1032
1448
  /*
1033
1449
  * Public API Surface of maps
1034
1450
  */
@@ -1037,5 +1453,5 @@ class PolygonStyleHelper {
1037
1453
  * Generated bundle index. Do not edit.
1038
1454
  */
1039
1455
 
1040
- 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 };
1456
+ 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 };
1041
1457
  //# sourceMappingURL=maps-components-src-map.mjs.map