@artstesh/maps 1.0.7 → 1.0.9

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 (144) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +797 -484
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +797 -484
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/helpers/index.js +2 -1
  6. package/dist/esm2015/map/helpers/stringify-feature.helper.js +58 -0
  7. package/dist/esm2015/map/helpers/text-style.helper.js +1 -1
  8. package/dist/esm2015/map/map-plate/features/polygons/polygons.component.js +2 -3
  9. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.js +1 -1
  10. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.manager.js +20 -2
  11. package/dist/esm2015/map/map-plate/layers/cluster-layer/cluster-layer.settings.js +8 -1
  12. package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.component.js +1 -1
  13. package/dist/esm2015/map/map-plate/map-plate.component.js +26 -4
  14. package/dist/esm2015/map/messages/commands/add-layer.command.js +3 -3
  15. package/dist/esm2015/map/messages/commands/add-tile.command.js +3 -3
  16. package/dist/esm2015/map/messages/commands/cancel-drawing.command.js +8 -0
  17. package/dist/esm2015/map/messages/commands/close-tooltip.command.js +3 -3
  18. package/dist/esm2015/map/messages/commands/fit-to-features.command.js +3 -3
  19. package/dist/esm2015/map/messages/commands/place-layer-features.command.js +3 -3
  20. package/dist/esm2015/map/messages/commands/remove-layer.command.js +3 -3
  21. package/dist/esm2015/map/messages/commands/remove-tile.command.js +3 -3
  22. package/dist/esm2015/map/messages/commands/start-drawing.command.js +15 -0
  23. package/dist/esm2015/map/messages/events/drawing-finished.event.js +11 -0
  24. package/dist/esm2015/map/messages/events/map-click.event.js +3 -3
  25. package/dist/esm2015/map/messages/events/map-move-end.event.js +13 -0
  26. package/dist/esm2015/map/messages/events/map-rendered.event.js +3 -3
  27. package/dist/esm2015/map/messages/index.js +4 -2
  28. package/dist/esm2015/map/messages/queries/generate-draw.query.js +14 -0
  29. package/dist/esm2015/map/messages/queries/get-layer.query.js +12 -0
  30. package/dist/esm2015/map/models/drawing-type.enum.js +6 -0
  31. package/dist/esm2015/map/models/feature-format.enum.js +6 -0
  32. package/dist/esm2015/map/models/index.js +3 -1
  33. package/dist/esm2015/map/models/map.constants.js +2 -1
  34. package/dist/esm2015/map/services/drawing/drawing-generation.service.js +28 -0
  35. package/dist/esm2015/map/services/drawing/drawing.service.js +81 -0
  36. package/dist/esm2015/map/services/map-management.service.js +6 -1
  37. package/dist/esm2015/map/services/map-postboy.service.js +8 -5
  38. package/dist/esm2015/map/services/map-state.service.js +12 -2
  39. package/dist/esm2015/map/services/message-registrator.service.js +19 -5
  40. package/dist/esm2015/src/map/helpers/index.js +2 -1
  41. package/dist/esm2015/src/map/helpers/stringify-feature.helper.js +58 -0
  42. package/dist/esm2015/src/map/helpers/text-style.helper.js +1 -1
  43. package/dist/esm2015/src/map/map-plate/features/polygons/polygons.component.js +2 -3
  44. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer-factory.service.js +1 -1
  45. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.js +20 -2
  46. package/dist/esm2015/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.js +8 -1
  47. package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.component.js +1 -1
  48. package/dist/esm2015/src/map/map-plate/map-plate.component.js +26 -4
  49. package/dist/esm2015/src/map/messages/commands/add-layer.command.js +3 -3
  50. package/dist/esm2015/src/map/messages/commands/add-tile.command.js +3 -3
  51. package/dist/esm2015/src/map/messages/commands/cancel-drawing.command.js +8 -0
  52. package/dist/esm2015/src/map/messages/commands/close-tooltip.command.js +3 -3
  53. package/dist/esm2015/src/map/messages/commands/fit-to-features.command.js +3 -3
  54. package/dist/esm2015/src/map/messages/commands/place-layer-features.command.js +3 -3
  55. package/dist/esm2015/src/map/messages/commands/remove-layer.command.js +3 -3
  56. package/dist/esm2015/src/map/messages/commands/remove-tile.command.js +3 -3
  57. package/dist/esm2015/src/map/messages/commands/start-drawing.command.js +15 -0
  58. package/dist/esm2015/src/map/messages/events/drawing-finished.event.js +11 -0
  59. package/dist/esm2015/src/map/messages/events/map-click.event.js +3 -3
  60. package/dist/esm2015/src/map/messages/events/map-move-end.event.js +13 -0
  61. package/dist/esm2015/src/map/messages/events/map-rendered.event.js +3 -3
  62. package/dist/esm2015/src/map/messages/index.js +4 -2
  63. package/dist/esm2015/src/map/messages/queries/generate-draw.query.js +14 -0
  64. package/dist/esm2015/src/map/messages/queries/get-layer.query.js +12 -0
  65. package/dist/esm2015/src/map/models/drawing-type.enum.js +6 -0
  66. package/dist/esm2015/src/map/models/feature-format.enum.js +6 -0
  67. package/dist/esm2015/src/map/models/index.js +3 -1
  68. package/dist/esm2015/src/map/models/map.constants.js +2 -1
  69. package/dist/esm2015/src/map/services/drawing/drawing-generation.service.js +28 -0
  70. package/dist/esm2015/src/map/services/drawing/drawing.service.js +81 -0
  71. package/dist/esm2015/src/map/services/map-management.service.js +6 -1
  72. package/dist/esm2015/src/map/services/map-postboy.service.js +8 -5
  73. package/dist/esm2015/src/map/services/map-state.service.js +12 -2
  74. package/dist/esm2015/src/map/services/message-registrator.service.js +19 -5
  75. package/dist/fesm2015/maps-components-src-map.js +638 -374
  76. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  77. package/dist/fesm2015/maps-components.js +638 -374
  78. package/dist/fesm2015/maps-components.js.map +1 -1
  79. package/dist/map/helpers/index.d.ts +1 -0
  80. package/dist/map/helpers/stringify-feature.helper.d.ts +8 -0
  81. package/dist/map/map-plate/layers/cluster-layer/cluster-layer.manager.d.ts +2 -0
  82. package/dist/map/map-plate/layers/cluster-layer/cluster-layer.settings.d.ts +2 -0
  83. package/dist/map/map-plate/map-plate.component.d.ts +2 -0
  84. package/dist/map/messages/commands/add-layer.command.d.ts +3 -3
  85. package/dist/map/messages/commands/add-tile.command.d.ts +3 -3
  86. package/dist/map/messages/commands/cancel-drawing.command.d.ts +5 -0
  87. package/dist/map/messages/commands/close-tooltip.command.d.ts +3 -3
  88. package/dist/map/messages/commands/fit-to-features.command.d.ts +3 -3
  89. package/dist/map/messages/commands/place-layer-features.command.d.ts +3 -3
  90. package/dist/map/messages/commands/remove-layer.command.d.ts +3 -3
  91. package/dist/map/messages/commands/remove-tile.command.d.ts +3 -3
  92. package/dist/map/messages/commands/start-drawing.command.d.ts +11 -0
  93. package/dist/map/messages/events/drawing-finished.event.d.ts +6 -0
  94. package/dist/map/messages/events/map-click.event.d.ts +3 -3
  95. package/dist/map/messages/events/map-move-end.event.d.ts +8 -0
  96. package/dist/map/messages/events/map-rendered.event.d.ts +3 -3
  97. package/dist/map/messages/index.d.ts +3 -1
  98. package/dist/map/messages/queries/generate-draw.query.d.ts +14 -0
  99. package/dist/map/messages/queries/get-layer.query.d.ts +10 -0
  100. package/dist/map/models/drawing-type.enum.d.ts +4 -0
  101. package/dist/map/models/feature-format.enum.d.ts +4 -0
  102. package/dist/map/models/index.d.ts +2 -0
  103. package/dist/map/models/map.constants.d.ts +1 -0
  104. package/dist/map/services/drawing/drawing-generation.service.d.ts +10 -0
  105. package/dist/map/services/drawing/drawing.service.d.ts +17 -0
  106. package/dist/map/services/map-management.service.d.ts +1 -0
  107. package/dist/map/services/map-postboy.service.d.ts +1 -2
  108. package/dist/map/services/message-registrator.service.d.ts +3 -1
  109. package/dist/package.json +1 -1
  110. package/dist/src/map/helpers/index.d.ts +1 -0
  111. package/dist/src/map/helpers/stringify-feature.helper.d.ts +8 -0
  112. package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.manager.d.ts +2 -0
  113. package/dist/src/map/map-plate/layers/cluster-layer/cluster-layer.settings.d.ts +2 -0
  114. package/dist/src/map/map-plate/map-plate.component.d.ts +2 -0
  115. package/dist/src/map/messages/commands/add-layer.command.d.ts +3 -3
  116. package/dist/src/map/messages/commands/add-tile.command.d.ts +3 -3
  117. package/dist/src/map/messages/commands/cancel-drawing.command.d.ts +5 -0
  118. package/dist/src/map/messages/commands/close-tooltip.command.d.ts +3 -3
  119. package/dist/src/map/messages/commands/fit-to-features.command.d.ts +3 -3
  120. package/dist/src/map/messages/commands/place-layer-features.command.d.ts +3 -3
  121. package/dist/src/map/messages/commands/remove-layer.command.d.ts +3 -3
  122. package/dist/src/map/messages/commands/remove-tile.command.d.ts +3 -3
  123. package/dist/src/map/messages/commands/start-drawing.command.d.ts +11 -0
  124. package/dist/src/map/messages/events/drawing-finished.event.d.ts +6 -0
  125. package/dist/src/map/messages/events/map-click.event.d.ts +3 -3
  126. package/dist/src/map/messages/events/map-move-end.event.d.ts +8 -0
  127. package/dist/src/map/messages/events/map-rendered.event.d.ts +3 -3
  128. package/dist/src/map/messages/index.d.ts +3 -1
  129. package/dist/src/map/messages/queries/generate-draw.query.d.ts +14 -0
  130. package/dist/src/map/messages/queries/get-layer.query.d.ts +10 -0
  131. package/dist/src/map/models/drawing-type.enum.d.ts +4 -0
  132. package/dist/src/map/models/feature-format.enum.d.ts +4 -0
  133. package/dist/src/map/models/index.d.ts +2 -0
  134. package/dist/src/map/models/map.constants.d.ts +1 -0
  135. package/dist/src/map/services/drawing/drawing-generation.service.d.ts +10 -0
  136. package/dist/src/map/services/drawing/drawing.service.d.ts +17 -0
  137. package/dist/src/map/services/map-management.service.d.ts +1 -0
  138. package/dist/src/map/services/map-postboy.service.d.ts +1 -2
  139. package/dist/src/map/services/message-registrator.service.d.ts +3 -1
  140. package/package.json +2 -2
  141. package/dist/esm2015/map/messages/generic-message.js +0 -15
  142. package/dist/esm2015/src/map/messages/generic-message.js +0 -15
  143. package/dist/map/messages/generic-message.d.ts +0 -9
  144. package/dist/src/map/messages/generic-message.d.ts +0 -9
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('ol'), require('ol/geom'), require('ol/format'), require('ol/extent'), require('ol/proj'), require('rxjs'), require('@artstesh/postboy'), require('ol/Map'), require('ol/View'), require('ol/layer/Tile'), require('ol/source/OSM'), require('rxjs/operators'), require('ol/source'), require('ol/layer'), require('ol/Overlay'), require('ol/loadingstrategy'), require('ol/geom/Polygon'), require('ol/source/Cluster'), require('ol/style/Style'), require('ol/style')) :
3
- typeof define === 'function' && define.amd ? define('maps-components', ['exports', '@angular/core', '@angular/common', 'ol', 'ol/geom', 'ol/format', 'ol/extent', 'ol/proj', 'rxjs', '@artstesh/postboy', 'ol/Map', 'ol/View', 'ol/layer/Tile', 'ol/source/OSM', 'rxjs/operators', 'ol/source', 'ol/layer', 'ol/Overlay', 'ol/loadingstrategy', 'ol/geom/Polygon', 'ol/source/Cluster', 'ol/style/Style', 'ol/style'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["maps-components"] = {}, global.ng.core, global.ng.common, global.ol, global.geom, global.format, global.extent, global.proj, global.rxjs, global.postboy, global.Map, global.View, global.TileLayer, global.OSM, global.rxjs.operators, global.source, global.layer, global.Overlay, global.loadingstrategy, global.Polygon, global.Cluster, global.Style, global.style));
5
- })(this, (function (exports, i0, i5, ol, geom, format, extent, proj, rxjs, postboy, Map, View, TileLayer, OSM, operators, source, layer, Overlay, loadingstrategy, Polygon, Cluster, Style, style) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('ol'), require('ol/geom'), require('ol/format'), require('ol/extent'), require('ol/proj'), require('@artstesh/postboy'), require('rxjs/operators'), require('ol/source'), require('ol/interaction'), require('ol/interaction/Draw'), require('ol/layer/Tile'), require('ol/source/OSM'), require('ol/layer'), require('ol/loadingstrategy'), require('ol/geom/Polygon'), require('ol/source/Cluster'), require('rxjs'), require('ol/Map'), require('ol/View'), require('ol/Overlay'), require('ol/style/Style'), require('ol/style'), require('ol/proj/epsg4326')) :
3
+ typeof define === 'function' && define.amd ? define('maps-components', ['exports', '@angular/core', '@angular/common', 'ol', 'ol/geom', 'ol/format', 'ol/extent', 'ol/proj', '@artstesh/postboy', 'rxjs/operators', 'ol/source', 'ol/interaction', 'ol/interaction/Draw', 'ol/layer/Tile', 'ol/source/OSM', 'ol/layer', 'ol/loadingstrategy', 'ol/geom/Polygon', 'ol/source/Cluster', 'rxjs', 'ol/Map', 'ol/View', 'ol/Overlay', 'ol/style/Style', 'ol/style', 'ol/proj/epsg4326'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["maps-components"] = {}, global.ng.core, global.ng.common, global.ol, global.geom, global.format, global.extent, global.proj, global.postboy, global.rxjs.operators, global.source, global.interaction, global.Draw, global.TileLayer, global.OSM, global.layer, global.loadingstrategy, global.Polygon, global.Cluster, global.rxjs, global.Map, global.View, global.Overlay, global.Style, global.style, global.epsg4326));
5
+ })(this, (function (exports, i0, i6, ol, geom, format, extent, proj, postboy, operators, source, interaction, Draw, TileLayer, OSM, layer, loadingstrategy, Polygon, Cluster, rxjs, Map, View, Overlay, Style, style, epsg4326) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -25,13 +25,14 @@
25
25
  }
26
26
 
27
27
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
- var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
29
- var Map__default = /*#__PURE__*/_interopDefaultLegacy(Map);
30
- var View__default = /*#__PURE__*/_interopDefaultLegacy(View);
28
+ var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
31
29
  var TileLayer__default = /*#__PURE__*/_interopDefaultLegacy(TileLayer);
32
30
  var OSM__default = /*#__PURE__*/_interopDefaultLegacy(OSM);
33
- var Overlay__default = /*#__PURE__*/_interopDefaultLegacy(Overlay);
31
+ var Polygon__default = /*#__PURE__*/_interopDefaultLegacy(Polygon);
34
32
  var Cluster__default = /*#__PURE__*/_interopDefaultLegacy(Cluster);
33
+ var Map__default = /*#__PURE__*/_interopDefaultLegacy(Map);
34
+ var View__default = /*#__PURE__*/_interopDefaultLegacy(View);
35
+ var Overlay__default = /*#__PURE__*/_interopDefaultLegacy(Overlay);
35
36
  var Style__default = /*#__PURE__*/_interopDefaultLegacy(Style);
36
37
 
37
38
  var DestructibleComponent = /** @class */ (function () {
@@ -614,7 +615,8 @@
614
615
  }
615
616
  return MapConstants;
616
617
  }());
617
- MapConstants.FeatureInfo = 'f-info';
618
+ MapConstants.FeatureInfo = 'f-info';
619
+ MapConstants.DrawingLayerId = '93a981756ec7';
618
620
 
619
621
  var MarkerModel = /** @class */ (function () {
620
622
  function MarkerModel(lat, lng, id, info) {
@@ -670,25 +672,17 @@
670
672
  return PolygonModel;
671
673
  }());
672
674
 
673
- var GenericMessage = /** @class */ (function () {
674
- function GenericMessage() {
675
- }
676
- return GenericMessage;
677
- }());
678
- var CallbackMessage = /** @class */ (function (_super) {
679
- __extends(CallbackMessage, _super);
680
- function CallbackMessage() {
681
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
682
- _this.result$ = new rxjs.Subject();
683
- _this.result = _this.result$.asObservable();
684
- return _this;
685
- }
686
- CallbackMessage.prototype.finish = function (value) {
687
- this.result$.next(value);
688
- this.result$.complete();
689
- };
690
- return CallbackMessage;
691
- }(GenericMessage));
675
+ exports.DrawingType = void 0;
676
+ (function (DrawingType) {
677
+ DrawingType[DrawingType["Polygon"] = 1] = "Polygon";
678
+ DrawingType[DrawingType["Circle"] = 2] = "Circle";
679
+ })(exports.DrawingType || (exports.DrawingType = {}));
680
+
681
+ exports.FeatureOutputFormat = void 0;
682
+ (function (FeatureOutputFormat) {
683
+ FeatureOutputFormat[FeatureOutputFormat["GeoJson"] = 1] = "GeoJson";
684
+ FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
685
+ })(exports.FeatureOutputFormat || (exports.FeatureOutputFormat = {}));
692
686
 
693
687
  var MapRenderedEvent = /** @class */ (function (_super) {
694
688
  __extends(MapRenderedEvent, _super);
@@ -705,7 +699,7 @@
705
699
  configurable: true
706
700
  });
707
701
  return MapRenderedEvent;
708
- }(GenericMessage));
702
+ }(postboy.PostboyGenericMessage));
709
703
  MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
710
704
 
711
705
  var MapClickEvent = /** @class */ (function (_super) {
@@ -725,9 +719,28 @@
725
719
  configurable: true
726
720
  });
727
721
  return MapClickEvent;
728
- }(GenericMessage));
722
+ }(postboy.PostboyGenericMessage));
729
723
  MapClickEvent.ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
730
724
 
725
+ var MapMoveEndEvent = /** @class */ (function (_super) {
726
+ __extends(MapMoveEndEvent, _super);
727
+ function MapMoveEndEvent(zoom, extent) {
728
+ var _this = _super.call(this) || this;
729
+ _this.zoom = zoom;
730
+ _this.extent = extent;
731
+ return _this;
732
+ }
733
+ Object.defineProperty(MapMoveEndEvent.prototype, "id", {
734
+ get: function () {
735
+ return MapMoveEndEvent.ID;
736
+ },
737
+ enumerable: false,
738
+ configurable: true
739
+ });
740
+ return MapMoveEndEvent;
741
+ }(postboy.PostboyGenericMessage));
742
+ MapMoveEndEvent.ID = 'f21f783e-b5af-4489-9fec-8027fd07a8ad';
743
+
731
744
  var CloseTooltipCommand = /** @class */ (function (_super) {
732
745
  __extends(CloseTooltipCommand, _super);
733
746
  function CloseTooltipCommand(tooltipId) {
@@ -743,9 +756,46 @@
743
756
  configurable: true
744
757
  });
745
758
  return CloseTooltipCommand;
746
- }(GenericMessage));
759
+ }(postboy.PostboyGenericMessage));
747
760
  CloseTooltipCommand.ID = '4896d52c-e34f-4994-bcfd-32832d12dbe4';
748
761
 
762
+ var StartDrawingCommand = /** @class */ (function (_super) {
763
+ __extends(StartDrawingCommand, _super);
764
+ function StartDrawingCommand(type, style, format) {
765
+ if (format === void 0) { format = exports.FeatureOutputFormat.GeoJson; }
766
+ var _this = _super.call(this) || this;
767
+ _this.type = type;
768
+ _this.style = style;
769
+ _this.format = format;
770
+ return _this;
771
+ }
772
+ Object.defineProperty(StartDrawingCommand.prototype, "id", {
773
+ get: function () {
774
+ return StartDrawingCommand.ID;
775
+ },
776
+ enumerable: false,
777
+ configurable: true
778
+ });
779
+ return StartDrawingCommand;
780
+ }(postboy.PostboyCallbackMessage));
781
+ StartDrawingCommand.ID = 'da904f4b-a1c8-4db7-a6af-14d9ee18ec8c';
782
+
783
+ var CancelDrawingCommand = /** @class */ (function (_super) {
784
+ __extends(CancelDrawingCommand, _super);
785
+ function CancelDrawingCommand() {
786
+ return _super !== null && _super.apply(this, arguments) || this;
787
+ }
788
+ Object.defineProperty(CancelDrawingCommand.prototype, "id", {
789
+ get: function () {
790
+ return CancelDrawingCommand.ID;
791
+ },
792
+ enumerable: false,
793
+ configurable: true
794
+ });
795
+ return CancelDrawingCommand;
796
+ }(postboy.PostboyGenericMessage));
797
+ CancelDrawingCommand.ID = '7d38d983-feba-4176-a66b-18175e5ecd6b';
798
+
749
799
  var AddLayerCommand = /** @class */ (function (_super) {
750
800
  __extends(AddLayerCommand, _super);
751
801
  function AddLayerCommand(layer) {
@@ -761,7 +811,7 @@
761
811
  configurable: true
762
812
  });
763
813
  return AddLayerCommand;
764
- }(GenericMessage));
814
+ }(postboy.PostboyGenericMessage));
765
815
  AddLayerCommand.ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
766
816
 
767
817
  var PlaceLayerFeaturesCommand = /** @class */ (function (_super) {
@@ -780,7 +830,7 @@
780
830
  configurable: true
781
831
  });
782
832
  return PlaceLayerFeaturesCommand;
783
- }(GenericMessage));
833
+ }(postboy.PostboyGenericMessage));
784
834
  PlaceLayerFeaturesCommand.ID = '8caf86bc-869b-426f-b36d-4642f6b8aab0';
785
835
 
786
836
  var RemoveLayerCommand = /** @class */ (function (_super) {
@@ -798,7 +848,7 @@
798
848
  configurable: true
799
849
  });
800
850
  return RemoveLayerCommand;
801
- }(GenericMessage));
851
+ }(postboy.PostboyGenericMessage));
802
852
  RemoveLayerCommand.ID = 'ab484e0e-e185-45cd-8434-12101f3c7eb1';
803
853
 
804
854
  var AddTileCommand = /** @class */ (function (_super) {
@@ -816,7 +866,7 @@
816
866
  configurable: true
817
867
  });
818
868
  return AddTileCommand;
819
- }(GenericMessage));
869
+ }(postboy.PostboyGenericMessage));
820
870
  AddTileCommand.ID = '25b7df28-72ce-4453-9fe6-54285a2fdc57';
821
871
 
822
872
  var RemoveTileCommand = /** @class */ (function (_super) {
@@ -834,7 +884,7 @@
834
884
  configurable: true
835
885
  });
836
886
  return RemoveTileCommand;
837
- }(GenericMessage));
887
+ }(postboy.PostboyGenericMessage));
838
888
  RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
839
889
 
840
890
  var FitToFeaturesCommand = /** @class */ (function (_super) {
@@ -854,23 +904,77 @@
854
904
  configurable: true
855
905
  });
856
906
  return FitToFeaturesCommand;
857
- }(GenericMessage));
907
+ }(postboy.PostboyGenericMessage));
858
908
  FitToFeaturesCommand.ID = '76cdc091-3793-4b6c-82f7-1e0334cf08a8';
859
909
 
910
+ var GetLayerQuery = /** @class */ (function (_super) {
911
+ __extends(GetLayerQuery, _super);
912
+ function GetLayerQuery(name) {
913
+ var _this = _super.call(this) || this;
914
+ _this.name = name;
915
+ return _this;
916
+ }
917
+ Object.defineProperty(GetLayerQuery.prototype, "id", {
918
+ get: function () {
919
+ return GetLayerQuery.ID;
920
+ },
921
+ enumerable: false,
922
+ configurable: true
923
+ });
924
+ return GetLayerQuery;
925
+ }(postboy.PostboyCallbackMessage));
926
+ GetLayerQuery.ID = '5c04c87b-8a93-4c2a-979e-d1e313d860ed';
927
+
928
+ var DrawingFinishedEvent = /** @class */ (function (_super) {
929
+ __extends(DrawingFinishedEvent, _super);
930
+ function DrawingFinishedEvent() {
931
+ return _super.call(this) || this;
932
+ }
933
+ Object.defineProperty(DrawingFinishedEvent.prototype, "id", {
934
+ get: function () {
935
+ return DrawingFinishedEvent.ID;
936
+ },
937
+ enumerable: false,
938
+ configurable: true
939
+ });
940
+ return DrawingFinishedEvent;
941
+ }(postboy.PostboyGenericMessage));
942
+ DrawingFinishedEvent.ID = 'c724b68e-b4eb-4783-90f1-a8e31973fd36';
943
+
944
+ var GenerateDrawQuery = /** @class */ (function (_super) {
945
+ __extends(GenerateDrawQuery, _super);
946
+ function GenerateDrawQuery(layer, style, type) {
947
+ var _this = _super.call(this) || this;
948
+ _this.layer = layer;
949
+ _this.style = style;
950
+ _this.type = type;
951
+ return _this;
952
+ }
953
+ Object.defineProperty(GenerateDrawQuery.prototype, "id", {
954
+ get: function () {
955
+ return GenerateDrawQuery.ID;
956
+ },
957
+ enumerable: false,
958
+ configurable: true
959
+ });
960
+ return GenerateDrawQuery;
961
+ }(postboy.PostboyCallbackMessage));
962
+ GenerateDrawQuery.ID = 'f01c99ba-0953-4ab5-82f9-04e6fbb678c1';
963
+
860
964
  var MapPostboyService = /** @class */ (function (_super) {
861
965
  __extends(MapPostboyService, _super);
862
966
  function MapPostboyService() {
863
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
864
- _this.observe = function (id) { return _this.subscribe(id); };
967
+ var _this = _super.call(this) || this;
968
+ _this.addLocker({ locker: StartDrawingCommand.ID, unlocker: DrawingFinishedEvent.ID, locking: [MapClickEvent.ID] });
865
969
  return _this;
866
970
  }
867
971
  return MapPostboyService;
868
972
  }(postboy.PostboyService));
869
- MapPostboyService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPostboyService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
973
+ MapPostboyService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPostboyService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
870
974
  MapPostboyService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPostboyService });
871
975
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPostboyService, decorators: [{
872
976
  type: i0.Injectable
873
- }] });
977
+ }], ctorParameters: function () { return []; } });
874
978
 
875
979
  var MapManagementService = /** @class */ (function () {
876
980
  function MapManagementService(postboy) {
@@ -884,6 +988,7 @@
884
988
  this.observePlaceFeatures();
885
989
  this.observeAddTile();
886
990
  this.observeRemoveTile();
991
+ this.observeLayerQuery();
887
992
  };
888
993
  MapManagementService.prototype.observeRemoveTile = function () {
889
994
  var _this = this;
@@ -893,6 +998,10 @@
893
998
  _this.map.removeLayer(c.layer);
894
999
  });
895
1000
  };
1001
+ MapManagementService.prototype.observeLayerQuery = function () {
1002
+ var _this = this;
1003
+ this.postboy.subscribe(GetLayerQuery.ID).subscribe(function (ev) { var _a; return ev.finish((_a = _this.layers[ev.name]) !== null && _a !== void 0 ? _a : null); });
1004
+ };
896
1005
  MapManagementService.prototype.observeAddTile = function () {
897
1006
  var _this = this;
898
1007
  this.postboy.subscribe(AddTileCommand.ID).subscribe(function (c) {
@@ -952,7 +1061,16 @@
952
1061
  }
953
1062
  MapStateService.prototype.up = function () {
954
1063
  var _this = this;
955
- this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (m) { return (_this.map = m); });
1064
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (ev) {
1065
+ var _a;
1066
+ _this.map = ev.map;
1067
+ (_a = _this.map) === null || _a === void 0 ? void 0 : _a.on('moveend', function () {
1068
+ var _a, _b;
1069
+ var zoom = Math.floor(((_a = _this.map) === null || _a === void 0 ? void 0 : _a.getView().getZoom()) || -1);
1070
+ var extent = ((_b = _this.map) === null || _b === void 0 ? void 0 : _b.getView().calculateExtent()) || [];
1071
+ _this.postboy.fire(new MapMoveEndEvent(zoom, extent));
1072
+ });
1073
+ });
956
1074
  };
957
1075
  return MapStateService;
958
1076
  }());
@@ -1050,11 +1168,105 @@
1050
1168
  type: i0.Injectable
1051
1169
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1052
1170
 
1171
+ var DrawingService = /** @class */ (function () {
1172
+ function DrawingService(postboy) {
1173
+ this.postboy = postboy;
1174
+ }
1175
+ DrawingService.prototype.up = function () {
1176
+ var _this = this;
1177
+ this.postboy.subscribe(StartDrawingCommand.ID).subscribe(function (ev) {
1178
+ _this.draw(function (l) {
1179
+ if (!l || !_this.map) {
1180
+ _this.clearInteraction(l);
1181
+ return;
1182
+ }
1183
+ var drawQuery = new GenerateDrawQuery(l, ev.style, ev.type);
1184
+ drawQuery.result.subscribe(function (draw) {
1185
+ var _a;
1186
+ var cancelSub = _this.observeCancelation(ev, l);
1187
+ _this.drawInteraction = draw;
1188
+ (_a = _this.map) === null || _a === void 0 ? void 0 : _a.addInteraction(_this.drawInteraction);
1189
+ _this.drawInteraction.on('drawend', function (evt) {
1190
+ cancelSub.unsubscribe();
1191
+ _this.onEnd(evt, ev, l);
1192
+ });
1193
+ });
1194
+ _this.postboy.fire(drawQuery);
1195
+ });
1196
+ });
1197
+ this.observeMapRender();
1198
+ };
1199
+ DrawingService.prototype.onEnd = function (evt, command, layer) {
1200
+ command.finish(command.format === exports.FeatureOutputFormat.GeoJson
1201
+ ? new format.GeoJSON().writeFeature(evt.feature)
1202
+ : new format.WKT().writeFeature(evt.feature));
1203
+ this.clearInteraction(layer);
1204
+ };
1205
+ DrawingService.prototype.observeMapRender = function () {
1206
+ var _this = this;
1207
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (m) {
1208
+ _this.map = m.map;
1209
+ });
1210
+ };
1211
+ DrawingService.prototype.draw = function (action) {
1212
+ var query = new GetLayerQuery(MapConstants.DrawingLayerId);
1213
+ query.result.subscribe(function (l) { return action(l); });
1214
+ this.postboy.fire(query);
1215
+ };
1216
+ DrawingService.prototype.observeCancelation = function (ev, layer) {
1217
+ var _this = this;
1218
+ return this.postboy
1219
+ .subscribe(CancelDrawingCommand.ID)
1220
+ .pipe(operators.first())
1221
+ .subscribe(function () {
1222
+ ev.finish(null);
1223
+ _this.clearInteraction(layer);
1224
+ });
1225
+ };
1226
+ DrawingService.prototype.clearInteraction = function (layer) {
1227
+ var _this = this;
1228
+ var _a;
1229
+ if (!!this.drawInteraction) {
1230
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeInteraction(this.drawInteraction);
1231
+ layer === null || layer === void 0 ? void 0 : layer.setSource(new source.Vector({}));
1232
+ }
1233
+ setTimeout(function () { return _this.postboy.fire(new DrawingFinishedEvent()); }, 300);
1234
+ };
1235
+ return DrawingService;
1236
+ }());
1237
+ DrawingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1238
+ DrawingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingService });
1239
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingService, decorators: [{
1240
+ type: i0.Injectable
1241
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1242
+
1243
+ var DrawingGenerationService = /** @class */ (function () {
1244
+ function DrawingGenerationService(postboy) {
1245
+ this.postboy = postboy;
1246
+ }
1247
+ DrawingGenerationService.prototype.up = function () {
1248
+ this.postboy.subscribe(GenerateDrawQuery.ID).subscribe(function (ev) {
1249
+ ev.finish(new interaction.Draw({
1250
+ source: ev.layer.getSource(),
1251
+ type: exports.DrawingType[ev.type],
1252
+ style: ev.style,
1253
+ geometryFunction: ev.type !== exports.DrawingType.Circle ? undefined : Draw.createRegularPolygon(32),
1254
+ }));
1255
+ });
1256
+ };
1257
+ return DrawingGenerationService;
1258
+ }());
1259
+ DrawingGenerationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingGenerationService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1260
+ DrawingGenerationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingGenerationService });
1261
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DrawingGenerationService, decorators: [{
1262
+ type: i0.Injectable
1263
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1264
+
1053
1265
  var MessageRegistratorService = /** @class */ (function (_super) {
1054
1266
  __extends(MessageRegistratorService, _super);
1055
- function MessageRegistratorService(service, management, state, feature, interaction) {
1267
+ function MessageRegistratorService(service, management, state, feature, interaction, drawing, drawGenerator) {
1056
1268
  var _this = _super.call(this, service) || this;
1057
- _this.registerServices([management, state, interaction, feature]);
1269
+ _this.registerServices([management, state, interaction, feature, drawing, drawGenerator]);
1058
1270
  return _this;
1059
1271
  }
1060
1272
  MessageRegistratorService.prototype._up = function () {
@@ -1067,286 +1279,330 @@
1067
1279
  this.registerSubject(MapClickEvent.ID);
1068
1280
  this.registerSubject(CloseTooltipCommand.ID);
1069
1281
  this.registerSubject(FitToFeaturesCommand.ID);
1282
+ this.registerSubject(MapMoveEndEvent.ID);
1283
+ this.registerSubject(CancelDrawingCommand.ID);
1284
+ this.registerSubject(StartDrawingCommand.ID);
1285
+ this.registerSubject(GetLayerQuery.ID);
1286
+ this.registerSubject(DrawingFinishedEvent.ID);
1287
+ this.registerSubject(GenerateDrawQuery.ID);
1070
1288
  };
1071
1289
  return MessageRegistratorService;
1072
1290
  }(postboy.PostboyAbstractRegistrator));
1073
- MessageRegistratorService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1291
+ MessageRegistratorService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: DrawingGenerationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1074
1292
  MessageRegistratorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService });
1075
1293
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, decorators: [{
1076
1294
  type: i0.Injectable
1077
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }]; } });
1295
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: DrawingGenerationService }]; } });
1078
1296
 
1079
- var MapPlateFactory = /** @class */ (function () {
1080
- function MapPlateFactory() {
1297
+ var TileLayerSettings = /** @class */ (function () {
1298
+ function TileLayerSettings() {
1299
+ this.maxZoom = 19;
1300
+ this.minZoom = 0;
1301
+ this.opacity = 0.6;
1302
+ this.url = '';
1303
+ this.projection = 'EPSG:3857';
1081
1304
  }
1082
- MapPlateFactory.prototype.build = function (settings) {
1083
- return new Map__default["default"]({
1084
- controls: [],
1085
- view: new View__default["default"]({
1086
- center: (settings === null || settings === void 0 ? void 0 : settings.center) || [0, 0],
1087
- zoom: (settings === null || settings === void 0 ? void 0 : settings.zoom) || 4,
1088
- minZoom: (settings === null || settings === void 0 ? void 0 : settings.minZoom) || 0,
1089
- maxZoom: (settings === null || settings === void 0 ? void 0 : settings.maxZoom) || 19,
1090
- }),
1091
- layers: [],
1305
+ TileLayerSettings.copy = function (model) {
1306
+ var result = new TileLayerSettings();
1307
+ result.maxZoom = model.maxZoom;
1308
+ result.minZoom = model.minZoom;
1309
+ result.projection = model.projection;
1310
+ result.opacity = model.opacity;
1311
+ result.url = model.url;
1312
+ return result;
1313
+ };
1314
+ TileLayerSettings.prototype.setUrl = function (url) {
1315
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url: url }));
1316
+ };
1317
+ TileLayerSettings.prototype.setMaxZoom = function (maxZoom) {
1318
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom: maxZoom }));
1319
+ };
1320
+ TileLayerSettings.prototype.setMinZoom = function (minZoom) {
1321
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom: minZoom }));
1322
+ };
1323
+ TileLayerSettings.prototype.setOpacity = function (opacity) {
1324
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { opacity: opacity }));
1325
+ };
1326
+ TileLayerSettings.prototype.setProjection = function (projection) {
1327
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { projection: projection }));
1328
+ };
1329
+ TileLayerSettings.prototype.isSame = function (model) {
1330
+ if (this.maxZoom !== model.maxZoom)
1331
+ return false;
1332
+ if (this.minZoom !== model.minZoom)
1333
+ return false;
1334
+ if (this.url !== model.url)
1335
+ return false;
1336
+ if (this.projection !== model.projection)
1337
+ return false;
1338
+ if (this.opacity !== model.opacity)
1339
+ return false;
1340
+ return true;
1341
+ };
1342
+ return TileLayerSettings;
1343
+ }());
1344
+
1345
+ var TileLayerFactory = /** @class */ (function () {
1346
+ function TileLayerFactory() {
1347
+ }
1348
+ TileLayerFactory.prototype.build = function (settings) {
1349
+ var source$1 = new source.XYZ({
1350
+ tileSize: 256,
1351
+ maxZoom: settings.maxZoom || 14,
1352
+ minZoom: settings.minZoom || 1,
1353
+ projection: proj.get(settings.projection),
1354
+ tileUrlFunction: this.getTileFunc(settings),
1355
+ crossOrigin: 'Anonymous',
1092
1356
  });
1357
+ return new TileLayer__default["default"]({ source: source$1, opacity: settings.opacity });
1093
1358
  };
1094
- return MapPlateFactory;
1359
+ TileLayerFactory.prototype.getTileFunc = function (settings) {
1360
+ var _this = this;
1361
+ return function (tileCoord) {
1362
+ var zoom = tileCoord[0];
1363
+ var x = tileCoord[1];
1364
+ var y = tileCoord[2];
1365
+ var normalizedCoord = _this.getNormalizedCoord({ x: x, y: y }, zoom);
1366
+ var bound = 1 << zoom;
1367
+ return settings.url
1368
+ .replace('{x}', String((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.x) || x))
1369
+ .replace('{z}', String(zoom))
1370
+ .replace('{y}', String(bound - ((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.y) || y) - 1));
1371
+ };
1372
+ };
1373
+ TileLayerFactory.prototype.getNormalizedCoord = function (coord, zoom) {
1374
+ var y = coord.y;
1375
+ var x = coord.x;
1376
+ var tileRange = 1 << zoom;
1377
+ if (y < 0 || y >= tileRange)
1378
+ return null;
1379
+ if (x < 0 || x >= tileRange)
1380
+ x = ((x % tileRange) + tileRange) % tileRange;
1381
+ return { x: x, y: y };
1382
+ };
1383
+ return TileLayerFactory;
1095
1384
  }());
1096
- MapPlateFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1097
- MapPlateFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateFactory, providedIn: 'root' });
1098
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateFactory, decorators: [{
1385
+ TileLayerFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1386
+ TileLayerFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, providedIn: 'root' });
1387
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, decorators: [{
1099
1388
  type: i0.Injectable,
1100
1389
  args: [{
1101
1390
  providedIn: 'root',
1102
1391
  }]
1103
1392
  }] });
1104
1393
 
1105
- var OsmTileLayerComponent = /** @class */ (function (_super) {
1106
- __extends(OsmTileLayerComponent, _super);
1107
- function OsmTileLayerComponent() {
1394
+ var TileLayerComponent = /** @class */ (function (_super) {
1395
+ __extends(TileLayerComponent, _super);
1396
+ function TileLayerComponent(postboy, factory) {
1108
1397
  var _this = _super.call(this) || this;
1109
- _this._url = '';
1398
+ _this.postboy = postboy;
1399
+ _this.factory = factory;
1400
+ _this._settings = new TileLayerSettings();
1401
+ _this.onDestroy = function () { return _this.removeLayer(); };
1110
1402
  return _this;
1111
1403
  }
1112
- Object.defineProperty(OsmTileLayerComponent.prototype, "url", {
1113
- set: function (value) {
1114
- if (!value || this._url === value)
1115
- return;
1116
- this._url = value;
1117
- this.initLayer();
1118
- },
1119
- enumerable: false,
1120
- configurable: true
1121
- });
1122
- Object.defineProperty(OsmTileLayerComponent.prototype, "map", {
1404
+ TileLayerComponent.prototype.ngOnInit = function () {
1405
+ var _this = this;
1406
+ this.postboy
1407
+ .subscribe(MapRenderedEvent.ID)
1408
+ .pipe(operators.filter(function (m) { return !!m; }), operators.first())
1409
+ .subscribe(function (m) { return _this.initLayer(); });
1410
+ };
1411
+ Object.defineProperty(TileLayerComponent.prototype, "settings", {
1123
1412
  set: function (value) {
1124
- if (!value || this._map === value)
1413
+ if (!value || this._settings.isSame(value))
1125
1414
  return;
1126
- this._map = value;
1415
+ this._settings = value;
1127
1416
  this.initLayer();
1128
1417
  },
1129
1418
  enumerable: false,
1130
1419
  configurable: true
1131
1420
  });
1132
- OsmTileLayerComponent.prototype.ngOnInit = function () { };
1133
- OsmTileLayerComponent.prototype.ngOnDestroy = function () {
1134
- var _a, _b;
1135
- if (this.layer) {
1136
- (_a = this._map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.layer);
1137
- }
1138
- // @ts-ignore
1139
- (_b = this.layer) === null || _b === void 0 ? void 0 : _b.setMap(null);
1421
+ TileLayerComponent.prototype.initLayer = function () {
1422
+ this.removeLayer();
1423
+ this.layer = this.factory.build(this._settings);
1424
+ this.postboy.fire(new AddTileCommand(this.layer));
1140
1425
  };
1141
- OsmTileLayerComponent.prototype.initLayer = function () {
1142
- if (!this._url || !this._map)
1143
- return;
1426
+ TileLayerComponent.prototype.removeLayer = function () {
1144
1427
  if (this.layer)
1145
- this._map.removeLayer(this.layer);
1146
- this.layer = new TileLayer__default["default"]({
1147
- source: new OSM__default["default"]({
1148
- url: this._url,
1149
- }),
1150
- });
1151
- this.layer.set('name', 'osm-tile-layer');
1152
- this._map.addLayer(this.layer);
1428
+ this.postboy.fire(new RemoveTileCommand(this.layer));
1153
1429
  };
1154
- return OsmTileLayerComponent;
1430
+ return TileLayerComponent;
1155
1431
  }(DestructibleComponent));
1156
- OsmTileLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: OsmTileLayerComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
1157
- OsmTileLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: { url: "url", map: "map" }, usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1158
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: OsmTileLayerComponent, decorators: [{
1432
+ TileLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerComponent, deps: [{ token: MapPostboyService }, { token: TileLayerFactory }], target: i0__namespace.ɵɵFactoryTarget.Component });
1433
+ TileLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TileLayerComponent, selector: "lib-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1434
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerComponent, decorators: [{
1159
1435
  type: i0.Component,
1160
1436
  args: [{
1161
- selector: 'lib-osm-tile-layer',
1437
+ selector: 'lib-tile-layer',
1162
1438
  template: '',
1163
1439
  styleUrls: [],
1164
1440
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1165
1441
  }]
1166
- }], ctorParameters: function () { return []; }, propDecorators: { url: [{
1167
- type: i0.Input
1168
- }], map: [{
1442
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: TileLayerFactory }]; }, propDecorators: { settings: [{
1169
1443
  type: i0.Input
1170
1444
  }] } });
1171
1445
 
1172
- var MapPlateComponent = /** @class */ (function (_super) {
1173
- __extends(MapPlateComponent, _super);
1174
- function MapPlateComponent(elementRef, postboy, mapFactory, registrator, detector) {
1446
+ var OsmTileLayerComponent = /** @class */ (function (_super) {
1447
+ __extends(OsmTileLayerComponent, _super);
1448
+ function OsmTileLayerComponent() {
1175
1449
  var _this = _super.call(this) || this;
1176
- _this.elementRef = elementRef;
1177
- _this.postboy = postboy;
1178
- _this.mapFactory = mapFactory;
1179
- _this.registrator = registrator;
1180
- _this.detector = detector;
1181
- _this.osmUrl = '';
1182
- _this._settings = new MapSettings();
1183
- _this.onDestroy = function () {
1184
- _this.registrator.down();
1185
- };
1186
- registrator.up();
1450
+ _this._url = '';
1187
1451
  return _this;
1188
1452
  }
1189
- Object.defineProperty(MapPlateComponent.prototype, "settings", {
1453
+ Object.defineProperty(OsmTileLayerComponent.prototype, "url", {
1190
1454
  set: function (value) {
1191
- if (!value || this._settings.isSame(value))
1455
+ if (!value || this._url === value)
1192
1456
  return;
1193
- this._settings = value;
1194
- this.setOsm();
1457
+ this._url = value;
1458
+ this.initLayer();
1195
1459
  },
1196
1460
  enumerable: false,
1197
1461
  configurable: true
1198
1462
  });
1199
- MapPlateComponent.prototype.ngOnInit = function () {
1200
- var _this = this;
1201
- proj.useGeographic();
1202
- this.map = this.mapFactory.build(this._settings);
1203
- this.map.setTarget(this.elementRef.nativeElement);
1204
- this.detector.detectChanges();
1205
- this.map.once('postrender', function () {
1206
- _this.map.updateSize();
1207
- _this.postboy.fire(new MapRenderedEvent(_this.map));
1208
- });
1209
- this.setOsm();
1463
+ Object.defineProperty(OsmTileLayerComponent.prototype, "map", {
1464
+ set: function (value) {
1465
+ if (!value || this._map === value)
1466
+ return;
1467
+ this._map = value;
1468
+ this.initLayer();
1469
+ },
1470
+ enumerable: false,
1471
+ configurable: true
1472
+ });
1473
+ OsmTileLayerComponent.prototype.ngOnInit = function () { };
1474
+ OsmTileLayerComponent.prototype.ngOnDestroy = function () {
1475
+ var _a, _b;
1476
+ if (this.layer) {
1477
+ (_a = this._map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.layer);
1478
+ }
1479
+ // @ts-ignore
1480
+ (_b = this.layer) === null || _b === void 0 ? void 0 : _b.setMap(null);
1210
1481
  };
1211
- MapPlateComponent.prototype.setOsm = function () {
1212
- if (!this.map)
1482
+ OsmTileLayerComponent.prototype.initLayer = function () {
1483
+ if (!this._url || !this._map)
1213
1484
  return;
1214
- 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}";
1215
- this.detector.detectChanges();
1216
- this.map.updateSize();
1485
+ if (this.layer)
1486
+ this._map.removeLayer(this.layer);
1487
+ this.layer = new TileLayer__default["default"]({
1488
+ source: new OSM__default["default"]({
1489
+ url: this._url,
1490
+ }),
1491
+ });
1492
+ this.layer.set('name', 'osm-tile-layer');
1493
+ this._map.addLayer(this.layer);
1217
1494
  };
1218
- return MapPlateComponent;
1495
+ return OsmTileLayerComponent;
1219
1496
  }(DestructibleComponent));
1220
- MapPlateComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, deps: [{ token: i0__namespace.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
1221
- MapPlateComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService, MapFeatureService], usesInheritance: true, ngImport: i0__namespace, template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], directives: [{ type: i5__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1222
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, decorators: [{
1497
+ OsmTileLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: OsmTileLayerComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
1498
+ OsmTileLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: { url: "url", map: "map" }, usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1499
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: OsmTileLayerComponent, decorators: [{
1223
1500
  type: i0.Component,
1224
1501
  args: [{
1225
- selector: 'lib-map-plate',
1226
- templateUrl: './map-plate.component.html',
1227
- styleUrls: ['./map-plate.component.scss'],
1502
+ selector: 'lib-osm-tile-layer',
1503
+ template: '',
1504
+ styleUrls: [],
1228
1505
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1229
- providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService, MapFeatureService],
1230
1506
  }]
1231
- }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1507
+ }], ctorParameters: function () { return []; }, propDecorators: { url: [{
1508
+ type: i0.Input
1509
+ }], map: [{
1232
1510
  type: i0.Input
1233
1511
  }] } });
1234
1512
 
1235
- var TileLayerSettings = /** @class */ (function () {
1236
- function TileLayerSettings() {
1513
+ var FeatureLayerSettings = /** @class */ (function () {
1514
+ function FeatureLayerSettings() {
1515
+ this.name = IdGenerator.get();
1516
+ this.zIndex = 1;
1237
1517
  this.maxZoom = 19;
1238
1518
  this.minZoom = 0;
1239
- this.opacity = 0.6;
1240
- this.url = '';
1241
- this.projection = 'EPSG:3857';
1242
1519
  }
1243
- TileLayerSettings.copy = function (model) {
1244
- var result = new TileLayerSettings();
1520
+ FeatureLayerSettings.copy = function (model) {
1521
+ var result = new FeatureLayerSettings();
1522
+ result.name = model.name;
1245
1523
  result.maxZoom = model.maxZoom;
1246
1524
  result.minZoom = model.minZoom;
1247
- result.projection = model.projection;
1248
- result.opacity = model.opacity;
1249
- result.url = model.url;
1525
+ result.zIndex = model.zIndex;
1526
+ result.style = model.style;
1250
1527
  return result;
1251
1528
  };
1252
- TileLayerSettings.prototype.setUrl = function (url) {
1253
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url: url }));
1529
+ FeatureLayerSettings.prototype.setZIndex = function (zIndex) {
1530
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex: zIndex }));
1254
1531
  };
1255
- TileLayerSettings.prototype.setMaxZoom = function (maxZoom) {
1256
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom: maxZoom }));
1532
+ FeatureLayerSettings.prototype.setName = function (name) {
1533
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { name: name }));
1257
1534
  };
1258
- TileLayerSettings.prototype.setMinZoom = function (minZoom) {
1259
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom: minZoom }));
1535
+ FeatureLayerSettings.prototype.setMaxZoom = function (maxZoom) {
1536
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom: maxZoom }));
1260
1537
  };
1261
- TileLayerSettings.prototype.setOpacity = function (opacity) {
1262
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { opacity: opacity }));
1538
+ FeatureLayerSettings.prototype.setMinZoom = function (minZoom) {
1539
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom: minZoom }));
1263
1540
  };
1264
- TileLayerSettings.prototype.setProjection = function (projection) {
1265
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { projection: projection }));
1541
+ FeatureLayerSettings.prototype.setStyle = function (style) {
1542
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { style: style }));
1266
1543
  };
1267
- TileLayerSettings.prototype.isSame = function (model) {
1544
+ FeatureLayerSettings.prototype.isSame = function (model) {
1268
1545
  if (this.maxZoom !== model.maxZoom)
1269
1546
  return false;
1270
1547
  if (this.minZoom !== model.minZoom)
1271
1548
  return false;
1272
- if (this.url !== model.url)
1549
+ if (this.zIndex !== model.zIndex)
1273
1550
  return false;
1274
- if (this.projection !== model.projection)
1551
+ if (this.name !== model.name)
1275
1552
  return false;
1276
- if (this.opacity !== model.opacity)
1553
+ if (this.style !== model.style)
1277
1554
  return false;
1278
1555
  return true;
1279
1556
  };
1280
- return TileLayerSettings;
1557
+ return FeatureLayerSettings;
1281
1558
  }());
1282
1559
 
1283
- var TileLayerFactory = /** @class */ (function () {
1284
- function TileLayerFactory() {
1560
+ var FeatureLayerFactory = /** @class */ (function () {
1561
+ function FeatureLayerFactory() {
1285
1562
  }
1286
- TileLayerFactory.prototype.build = function (settings) {
1287
- var source$1 = new source.XYZ({
1288
- tileSize: 256,
1289
- maxZoom: settings.maxZoom || 14,
1290
- minZoom: settings.minZoom || 1,
1291
- projection: proj.get(settings.projection),
1292
- tileUrlFunction: this.getTileFunc(settings),
1293
- crossOrigin: 'Anonymous',
1563
+ FeatureLayerFactory.prototype.build = function (settings) {
1564
+ var source$1 = new source.Vector({});
1565
+ var layer$1 = new layer.Vector({
1566
+ source: source$1,
1567
+ maxZoom: settings.maxZoom,
1568
+ minZoom: settings.minZoom,
1569
+ zIndex: settings.zIndex,
1294
1570
  });
1295
- return new TileLayer__default["default"]({ source: source$1, opacity: settings.opacity });
1296
- };
1297
- TileLayerFactory.prototype.getTileFunc = function (settings) {
1298
- var _this = this;
1299
- return function (tileCoord) {
1300
- var zoom = tileCoord[0];
1301
- var x = tileCoord[1];
1302
- var y = tileCoord[2];
1303
- var normalizedCoord = _this.getNormalizedCoord({ x: x, y: y }, zoom);
1304
- var bound = 1 << zoom;
1305
- return settings.url
1306
- .replace('{x}', String((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.x) || x))
1307
- .replace('{z}', String(zoom))
1308
- .replace('{y}', String(bound - ((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.y) || y) - 1));
1309
- };
1310
- };
1311
- TileLayerFactory.prototype.getNormalizedCoord = function (coord, zoom) {
1312
- var y = coord.y;
1313
- var x = coord.x;
1314
- var tileRange = 1 << zoom;
1315
- if (y < 0 || y >= tileRange)
1316
- return null;
1317
- if (x < 0 || x >= tileRange)
1318
- x = ((x % tileRange) + tileRange) % tileRange;
1319
- return { x: x, y: y };
1571
+ if (settings.style)
1572
+ layer$1.setStyle(settings.style);
1573
+ layer$1.set('name', settings.name);
1574
+ return layer$1;
1320
1575
  };
1321
- return TileLayerFactory;
1576
+ return FeatureLayerFactory;
1322
1577
  }());
1323
- TileLayerFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1324
- TileLayerFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, providedIn: 'root' });
1325
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, decorators: [{
1578
+ FeatureLayerFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1579
+ FeatureLayerFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerFactory, providedIn: 'root' });
1580
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerFactory, decorators: [{
1326
1581
  type: i0.Injectable,
1327
1582
  args: [{
1328
1583
  providedIn: 'root',
1329
1584
  }]
1330
1585
  }] });
1331
1586
 
1332
- var TileLayerComponent = /** @class */ (function (_super) {
1333
- __extends(TileLayerComponent, _super);
1334
- function TileLayerComponent(postboy, factory) {
1587
+ var FeatureLayerComponent = /** @class */ (function (_super) {
1588
+ __extends(FeatureLayerComponent, _super);
1589
+ function FeatureLayerComponent(postboy, factory) {
1335
1590
  var _this = _super.call(this) || this;
1336
1591
  _this.postboy = postboy;
1337
1592
  _this.factory = factory;
1338
- _this._settings = new TileLayerSettings();
1593
+ _this.layer = null;
1594
+ _this._settings = new FeatureLayerSettings();
1339
1595
  _this.onDestroy = function () { return _this.removeLayer(); };
1340
1596
  return _this;
1341
1597
  }
1342
- TileLayerComponent.prototype.ngOnInit = function () {
1598
+ FeatureLayerComponent.prototype.ngOnInit = function () {
1343
1599
  var _this = this;
1344
1600
  this.postboy
1345
1601
  .subscribe(MapRenderedEvent.ID)
1346
1602
  .pipe(operators.filter(function (m) { return !!m; }), operators.first())
1347
1603
  .subscribe(function (m) { return _this.initLayer(); });
1348
1604
  };
1349
- Object.defineProperty(TileLayerComponent.prototype, "settings", {
1605
+ Object.defineProperty(FeatureLayerComponent.prototype, "settings", {
1350
1606
  set: function (value) {
1351
1607
  if (!value || this._settings.isSame(value))
1352
1608
  return;
@@ -1356,63 +1612,78 @@
1356
1612
  enumerable: false,
1357
1613
  configurable: true
1358
1614
  });
1359
- TileLayerComponent.prototype.initLayer = function () {
1615
+ FeatureLayerComponent.prototype.initLayer = function () {
1360
1616
  this.removeLayer();
1361
1617
  this.layer = this.factory.build(this._settings);
1362
- this.postboy.fire(new AddTileCommand(this.layer));
1618
+ this.postboy.fire(new AddLayerCommand(this.layer));
1363
1619
  };
1364
- TileLayerComponent.prototype.removeLayer = function () {
1620
+ FeatureLayerComponent.prototype.removeLayer = function () {
1365
1621
  if (this.layer)
1366
- this.postboy.fire(new RemoveTileCommand(this.layer));
1622
+ this.postboy.fire(new RemoveLayerCommand(this.layer));
1367
1623
  };
1368
- return TileLayerComponent;
1624
+ return FeatureLayerComponent;
1369
1625
  }(DestructibleComponent));
1370
- TileLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerComponent, deps: [{ token: MapPostboyService }, { token: TileLayerFactory }], target: i0__namespace.ɵɵFactoryTarget.Component });
1371
- TileLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TileLayerComponent, selector: "lib-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1372
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerComponent, decorators: [{
1626
+ FeatureLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerComponent, deps: [{ token: MapPostboyService }, { token: FeatureLayerFactory }], target: i0__namespace.ɵɵFactoryTarget.Component });
1627
+ FeatureLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1628
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerComponent, decorators: [{
1373
1629
  type: i0.Component,
1374
1630
  args: [{
1375
- selector: 'lib-tile-layer',
1631
+ selector: 'lib-feature-layer',
1376
1632
  template: '',
1377
1633
  styleUrls: [],
1378
1634
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1379
1635
  }]
1380
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: TileLayerFactory }]; }, propDecorators: { settings: [{
1636
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: FeatureLayerFactory }]; }, propDecorators: { settings: [{
1381
1637
  type: i0.Input
1382
1638
  }] } });
1383
1639
 
1384
- var FeatureLayerSettings = /** @class */ (function () {
1385
- function FeatureLayerSettings() {
1640
+ var ClusterLayerSettings = /** @class */ (function () {
1641
+ function ClusterLayerSettings() {
1386
1642
  this.name = IdGenerator.get();
1387
1643
  this.zIndex = 1;
1388
1644
  this.maxZoom = 19;
1389
1645
  this.minZoom = 0;
1646
+ this.distance = 20;
1647
+ this.bbox = false;
1648
+ this.clusterCancel = 14;
1390
1649
  }
1391
- FeatureLayerSettings.copy = function (model) {
1392
- var result = new FeatureLayerSettings();
1650
+ ClusterLayerSettings.copy = function (model) {
1651
+ var result = new ClusterLayerSettings();
1393
1652
  result.name = model.name;
1394
1653
  result.maxZoom = model.maxZoom;
1395
1654
  result.minZoom = model.minZoom;
1396
1655
  result.zIndex = model.zIndex;
1656
+ result.bbox = model.bbox;
1657
+ result.clusterCancel = model.clusterCancel;
1658
+ result.distance = model.distance;
1397
1659
  result.style = model.style;
1398
1660
  return result;
1399
1661
  };
1400
- FeatureLayerSettings.prototype.setZIndex = function (zIndex) {
1401
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex: zIndex }));
1662
+ ClusterLayerSettings.prototype.setZIndex = function (zIndex) {
1663
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex: zIndex }));
1402
1664
  };
1403
- FeatureLayerSettings.prototype.setName = function (name) {
1404
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { name: name }));
1665
+ ClusterLayerSettings.prototype.setDistance = function (distance) {
1666
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { distance: distance }));
1405
1667
  };
1406
- FeatureLayerSettings.prototype.setMaxZoom = function (maxZoom) {
1407
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom: maxZoom }));
1668
+ ClusterLayerSettings.prototype.setName = function (name) {
1669
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { name: name }));
1408
1670
  };
1409
- FeatureLayerSettings.prototype.setMinZoom = function (minZoom) {
1410
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom: minZoom }));
1671
+ ClusterLayerSettings.prototype.setMaxZoom = function (maxZoom) {
1672
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom: maxZoom }));
1411
1673
  };
1412
- FeatureLayerSettings.prototype.setStyle = function (style) {
1413
- return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { style: style }));
1674
+ ClusterLayerSettings.prototype.setMinZoom = function (minZoom) {
1675
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom: minZoom }));
1414
1676
  };
1415
- FeatureLayerSettings.prototype.isSame = function (model) {
1677
+ ClusterLayerSettings.prototype.setClusterCancel = function (clusterCancel) {
1678
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { clusterCancel: clusterCancel }));
1679
+ };
1680
+ ClusterLayerSettings.prototype.setBbox = function (bbox) {
1681
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { bbox: bbox }));
1682
+ };
1683
+ ClusterLayerSettings.prototype.setStyle = function (style) {
1684
+ return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { style: style }));
1685
+ };
1686
+ ClusterLayerSettings.prototype.isSame = function (model) {
1416
1687
  if (this.maxZoom !== model.maxZoom)
1417
1688
  return false;
1418
1689
  if (this.minZoom !== model.minZoom)
@@ -1421,90 +1692,266 @@
1421
1692
  return false;
1422
1693
  if (this.name !== model.name)
1423
1694
  return false;
1695
+ if (this.distance !== model.distance)
1696
+ return false;
1697
+ if (this.clusterCancel !== model.clusterCancel)
1698
+ return false;
1699
+ if (this.bbox !== model.bbox)
1700
+ return false;
1424
1701
  if (this.style !== model.style)
1425
1702
  return false;
1426
1703
  return true;
1427
1704
  };
1428
- return FeatureLayerSettings;
1705
+ return ClusterLayerSettings;
1429
1706
  }());
1430
1707
 
1431
- var FeatureLayerFactory = /** @class */ (function () {
1432
- function FeatureLayerFactory() {
1708
+ var ClusterLayerManager = /** @class */ (function () {
1709
+ function ClusterLayerManager(settings, layer, postboy) {
1710
+ this.settings = settings;
1711
+ this.layer = layer;
1712
+ this.postboy = postboy;
1713
+ this.observeClick();
1714
+ this.observeMapMovement();
1433
1715
  }
1434
- FeatureLayerFactory.prototype.build = function (settings) {
1435
- var source$1 = new source.Vector({});
1436
- var layer$1 = new layer.Vector({
1716
+ ClusterLayerManager.prototype.observeMapMovement = function () {
1717
+ var _this = this;
1718
+ rxjs.combineLatest([
1719
+ this.postboy.subscribe(MapMoveEndEvent.ID).pipe(operators.auditTime(250)),
1720
+ this.postboy.subscribe(MapRenderedEvent.ID),
1721
+ ]).subscribe(function (_d) {
1722
+ var _e = __read(_d, 2), movement = _e[0], renderEvent = _e[1];
1723
+ _this.checkClusterNecessity(renderEvent.map);
1724
+ });
1725
+ };
1726
+ ClusterLayerManager.prototype.observeClick = function () {
1727
+ var _this = this;
1728
+ this.postboy.subscribe(MapClickEvent.ID).subscribe(function (m) {
1729
+ var _a, _b;
1730
+ if (((_b = (_a = m.features[_this.settings.name]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 1) {
1731
+ _this.postboy.fire(new FitToFeaturesCommand(m.features[_this.settings.name], -1));
1732
+ }
1733
+ });
1734
+ };
1735
+ ClusterLayerManager.prototype.checkClusterNecessity = function (map) {
1736
+ var _a, _b, _c;
1737
+ var zoom = (_a = map.getView().getZoom()) !== null && _a !== void 0 ? _a : 0;
1738
+ var distance = zoom > this.settings.clusterCancel ? 0 : this.settings.distance;
1739
+ (_c = (_b = this.layer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.setDistance(distance);
1740
+ };
1741
+ return ClusterLayerManager;
1742
+ }());
1743
+
1744
+ var ClusterLayerFactory = /** @class */ (function () {
1745
+ function ClusterLayerFactory() {
1746
+ }
1747
+ ClusterLayerFactory.prototype.build = function (settings, postboy) {
1748
+ var source$1 = new source.Vector({
1749
+ strategy: settings.bbox ? loadingstrategy.bbox : undefined,
1750
+ });
1751
+ var cluster = new Cluster__default["default"]({
1752
+ distance: settings.distance,
1437
1753
  source: source$1,
1438
- maxZoom: settings.maxZoom,
1439
- minZoom: settings.minZoom,
1440
- zIndex: settings.zIndex,
1754
+ geometryFunction: function (feature) {
1755
+ var _a, _b;
1756
+ var geom = feature.getGeometry();
1757
+ if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Point') {
1758
+ return geom;
1759
+ }
1760
+ else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Polygon') {
1761
+ return (_a = geom) === null || _a === void 0 ? void 0 : _a.getInteriorPoint();
1762
+ }
1763
+ else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'MultiPolygon') {
1764
+ return (_b = Polygon.fromExtent(geom.getExtent())) === null || _b === void 0 ? void 0 : _b.getInteriorPoint();
1765
+ }
1766
+ return undefined;
1767
+ },
1441
1768
  });
1442
- if (settings.style)
1443
- layer$1.setStyle(settings.style);
1769
+ var layer$1 = new layer.Vector({
1770
+ source: cluster,
1771
+ maxZoom: settings.maxZoom || undefined,
1772
+ minZoom: settings.minZoom || undefined,
1773
+ zIndex: settings.zIndex || 0,
1774
+ });
1775
+ layer$1.setStyle(this.styleFunc(settings));
1444
1776
  layer$1.set('name', settings.name);
1445
- return layer$1;
1777
+ return new ClusterLayerManager(settings, layer$1, postboy);
1446
1778
  };
1447
- return FeatureLayerFactory;
1779
+ ClusterLayerFactory.prototype.styleFunc = function (settings) {
1780
+ return function (feature) {
1781
+ var features = feature.get('features');
1782
+ if (!settings.style)
1783
+ return undefined;
1784
+ return settings.style(features.map(function (f) { return (Object.assign({ id: f.getId() }, f.get(MapConstants.FeatureInfo))); }));
1785
+ };
1786
+ };
1787
+ return ClusterLayerFactory;
1448
1788
  }());
1449
- FeatureLayerFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1450
- FeatureLayerFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerFactory, providedIn: 'root' });
1451
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerFactory, decorators: [{
1789
+ ClusterLayerFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1790
+ ClusterLayerFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerFactory, providedIn: 'root' });
1791
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerFactory, decorators: [{
1452
1792
  type: i0.Injectable,
1453
1793
  args: [{
1454
1794
  providedIn: 'root',
1455
1795
  }]
1456
1796
  }] });
1457
1797
 
1458
- var FeatureLayerComponent = /** @class */ (function (_super) {
1459
- __extends(FeatureLayerComponent, _super);
1460
- function FeatureLayerComponent(postboy, factory) {
1798
+ var ClusterLayerComponent = /** @class */ (function (_super) {
1799
+ __extends(ClusterLayerComponent, _super);
1800
+ function ClusterLayerComponent(postboy, factory) {
1461
1801
  var _this = _super.call(this) || this;
1462
1802
  _this.postboy = postboy;
1463
1803
  _this.factory = factory;
1464
- _this.layer = null;
1465
- _this._settings = new FeatureLayerSettings();
1804
+ _this.manager = null;
1805
+ _this._settings = new ClusterLayerSettings();
1466
1806
  _this.onDestroy = function () { return _this.removeLayer(); };
1467
1807
  return _this;
1468
1808
  }
1469
- FeatureLayerComponent.prototype.ngOnInit = function () {
1470
- var _this = this;
1471
- this.postboy
1472
- .subscribe(MapRenderedEvent.ID)
1473
- .pipe(operators.filter(function (m) { return !!m; }), operators.first())
1474
- .subscribe(function (m) { return _this.initLayer(); });
1475
- };
1476
- Object.defineProperty(FeatureLayerComponent.prototype, "settings", {
1809
+ ClusterLayerComponent.prototype.ngOnInit = function () {
1810
+ var _this = this;
1811
+ this.postboy
1812
+ .subscribe(MapRenderedEvent.ID)
1813
+ .pipe(operators.filter(function (m) { return !!m; }), operators.first())
1814
+ .subscribe(function (m) { return _this.initLayer(); });
1815
+ };
1816
+ Object.defineProperty(ClusterLayerComponent.prototype, "settings", {
1817
+ set: function (value) {
1818
+ if (!value || this._settings.isSame(value))
1819
+ return;
1820
+ this._settings = value;
1821
+ this.initLayer();
1822
+ },
1823
+ enumerable: false,
1824
+ configurable: true
1825
+ });
1826
+ ClusterLayerComponent.prototype.initLayer = function () {
1827
+ this.removeLayer();
1828
+ this.manager = this.factory.build(this._settings, this.postboy);
1829
+ this.postboy.fire(new AddLayerCommand(this.manager.layer));
1830
+ };
1831
+ ClusterLayerComponent.prototype.removeLayer = function () {
1832
+ var _a;
1833
+ if ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.layer)
1834
+ this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
1835
+ };
1836
+ return ClusterLayerComponent;
1837
+ }(DestructibleComponent));
1838
+ ClusterLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerComponent, deps: [{ token: MapPostboyService }, { token: ClusterLayerFactory }], target: i0__namespace.ɵɵFactoryTarget.Component });
1839
+ ClusterLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ClusterLayerComponent, selector: "lib-cluster-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1840
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerComponent, decorators: [{
1841
+ type: i0.Component,
1842
+ args: [{
1843
+ selector: 'lib-cluster-layer',
1844
+ template: '',
1845
+ styleUrls: [],
1846
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
1847
+ }]
1848
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
1849
+ type: i0.Input
1850
+ }] } });
1851
+
1852
+ var MapPlateFactory = /** @class */ (function () {
1853
+ function MapPlateFactory() {
1854
+ }
1855
+ MapPlateFactory.prototype.build = function (settings) {
1856
+ return new Map__default["default"]({
1857
+ controls: [],
1858
+ view: new View__default["default"]({
1859
+ center: (settings === null || settings === void 0 ? void 0 : settings.center) || [0, 0],
1860
+ zoom: (settings === null || settings === void 0 ? void 0 : settings.zoom) || 4,
1861
+ minZoom: (settings === null || settings === void 0 ? void 0 : settings.minZoom) || 0,
1862
+ maxZoom: (settings === null || settings === void 0 ? void 0 : settings.maxZoom) || 19,
1863
+ }),
1864
+ layers: [],
1865
+ });
1866
+ };
1867
+ return MapPlateFactory;
1868
+ }());
1869
+ MapPlateFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1870
+ MapPlateFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateFactory, providedIn: 'root' });
1871
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateFactory, decorators: [{
1872
+ type: i0.Injectable,
1873
+ args: [{
1874
+ providedIn: 'root',
1875
+ }]
1876
+ }] });
1877
+
1878
+ var MapPlateComponent = /** @class */ (function (_super) {
1879
+ __extends(MapPlateComponent, _super);
1880
+ function MapPlateComponent(elementRef, postboy, mapFactory, registrator, detector) {
1881
+ var _this = _super.call(this) || this;
1882
+ _this.elementRef = elementRef;
1883
+ _this.postboy = postboy;
1884
+ _this.mapFactory = mapFactory;
1885
+ _this.registrator = registrator;
1886
+ _this.detector = detector;
1887
+ _this.osmUrl = '';
1888
+ _this._settings = new MapSettings();
1889
+ _this.drawingLayerSettings = new FeatureLayerSettings().setName(MapConstants.DrawingLayerId);
1890
+ _this.onDestroy = function () {
1891
+ _this.registrator.down();
1892
+ };
1893
+ registrator.up();
1894
+ return _this;
1895
+ }
1896
+ Object.defineProperty(MapPlateComponent.prototype, "settings", {
1477
1897
  set: function (value) {
1478
1898
  if (!value || this._settings.isSame(value))
1479
1899
  return;
1480
1900
  this._settings = value;
1481
- this.initLayer();
1901
+ this.setOsm();
1482
1902
  },
1483
1903
  enumerable: false,
1484
1904
  configurable: true
1485
1905
  });
1486
- FeatureLayerComponent.prototype.initLayer = function () {
1487
- this.removeLayer();
1488
- this.layer = this.factory.build(this._settings);
1489
- this.postboy.fire(new AddLayerCommand(this.layer));
1906
+ MapPlateComponent.prototype.ngOnInit = function () {
1907
+ var _this = this;
1908
+ proj.useGeographic();
1909
+ this.map = this.mapFactory.build(this._settings);
1910
+ this.map.setTarget(this.elementRef.nativeElement);
1911
+ this.detector.detectChanges();
1912
+ this.map.once('postrender', function () {
1913
+ _this.map.updateSize();
1914
+ _this.postboy.fire(new MapRenderedEvent(_this.map));
1915
+ });
1916
+ this.setOsm();
1490
1917
  };
1491
- FeatureLayerComponent.prototype.removeLayer = function () {
1492
- if (this.layer)
1493
- this.postboy.fire(new RemoveLayerCommand(this.layer));
1918
+ MapPlateComponent.prototype.setOsm = function () {
1919
+ if (!this.map)
1920
+ return;
1921
+ 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}";
1922
+ this.detector.detectChanges();
1923
+ this.map.updateSize();
1494
1924
  };
1495
- return FeatureLayerComponent;
1925
+ return MapPlateComponent;
1496
1926
  }(DestructibleComponent));
1497
- FeatureLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerComponent, deps: [{ token: MapPostboyService }, { token: FeatureLayerFactory }], target: i0__namespace.ɵɵFactoryTarget.Component });
1498
- FeatureLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1499
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FeatureLayerComponent, decorators: [{
1927
+ MapPlateComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, deps: [{ token: i0__namespace.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
1928
+ MapPlateComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [
1929
+ MessageRegistratorService,
1930
+ MapStateService,
1931
+ MapManagementService,
1932
+ MapClickService,
1933
+ MapFeatureService,
1934
+ DrawingService,
1935
+ DrawingGenerationService,
1936
+ ], usesInheritance: true, ngImport: i0__namespace, template: "<ng-content></ng-content>\r\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\r\n<lib-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></lib-feature-layer>\r\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }, { type: FeatureLayerComponent, selector: "lib-feature-layer", inputs: ["settings"] }], directives: [{ type: i6__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1937
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, decorators: [{
1500
1938
  type: i0.Component,
1501
1939
  args: [{
1502
- selector: 'lib-feature-layer',
1503
- template: '',
1504
- styleUrls: [],
1940
+ selector: 'lib-map-plate',
1941
+ templateUrl: './map-plate.component.html',
1942
+ styleUrls: ['./map-plate.component.scss'],
1505
1943
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1944
+ providers: [
1945
+ MessageRegistratorService,
1946
+ MapStateService,
1947
+ MapManagementService,
1948
+ MapClickService,
1949
+ MapFeatureService,
1950
+ DrawingService,
1951
+ DrawingGenerationService,
1952
+ ],
1506
1953
  }]
1507
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: FeatureLayerFactory }]; }, propDecorators: { settings: [{
1954
+ }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1508
1955
  type: i0.Input
1509
1956
  }] } });
1510
1957
 
@@ -1696,8 +2143,7 @@
1696
2143
  .subscribe(function () { return _this.putPolygons(); });
1697
2144
  };
1698
2145
  PolygonsComponent.prototype.putPolygons = function () {
1699
- var _a;
1700
- if (!((_a = this._polygons) === null || _a === void 0 ? void 0 : _a.length))
2146
+ if (!this._polygons)
1701
2147
  return;
1702
2148
  this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map(function (m) { return m.feature; })));
1703
2149
  };
@@ -1719,194 +2165,6 @@
1719
2165
  type: i0.Input
1720
2166
  }] } });
1721
2167
 
1722
- var ClusterLayerSettings = /** @class */ (function () {
1723
- function ClusterLayerSettings() {
1724
- this.name = IdGenerator.get();
1725
- this.zIndex = 1;
1726
- this.maxZoom = 19;
1727
- this.minZoom = 0;
1728
- this.distance = 20;
1729
- this.bbox = false;
1730
- }
1731
- ClusterLayerSettings.copy = function (model) {
1732
- var result = new ClusterLayerSettings();
1733
- result.name = model.name;
1734
- result.maxZoom = model.maxZoom;
1735
- result.minZoom = model.minZoom;
1736
- result.zIndex = model.zIndex;
1737
- result.bbox = model.bbox;
1738
- result.distance = model.distance;
1739
- result.style = model.style;
1740
- return result;
1741
- };
1742
- ClusterLayerSettings.prototype.setZIndex = function (zIndex) {
1743
- return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { zIndex: zIndex }));
1744
- };
1745
- ClusterLayerSettings.prototype.setDistance = function (distance) {
1746
- return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { distance: distance }));
1747
- };
1748
- ClusterLayerSettings.prototype.setName = function (name) {
1749
- return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { name: name }));
1750
- };
1751
- ClusterLayerSettings.prototype.setMaxZoom = function (maxZoom) {
1752
- return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom: maxZoom }));
1753
- };
1754
- ClusterLayerSettings.prototype.setMinZoom = function (minZoom) {
1755
- return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom: minZoom }));
1756
- };
1757
- ClusterLayerSettings.prototype.setBbox = function (bbox) {
1758
- return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { bbox: bbox }));
1759
- };
1760
- ClusterLayerSettings.prototype.setStyle = function (style) {
1761
- return ClusterLayerSettings.copy(Object.assign(Object.assign({}, this), { style: style }));
1762
- };
1763
- ClusterLayerSettings.prototype.isSame = function (model) {
1764
- if (this.maxZoom !== model.maxZoom)
1765
- return false;
1766
- if (this.minZoom !== model.minZoom)
1767
- return false;
1768
- if (this.zIndex !== model.zIndex)
1769
- return false;
1770
- if (this.name !== model.name)
1771
- return false;
1772
- if (this.distance !== model.distance)
1773
- return false;
1774
- if (this.bbox !== model.bbox)
1775
- return false;
1776
- if (this.style !== model.style)
1777
- return false;
1778
- return true;
1779
- };
1780
- return ClusterLayerSettings;
1781
- }());
1782
-
1783
- var ClusterLayerManager = /** @class */ (function () {
1784
- function ClusterLayerManager(settings, layer, postboy) {
1785
- this.settings = settings;
1786
- this.layer = layer;
1787
- this.postboy = postboy;
1788
- this.observeClick();
1789
- }
1790
- ClusterLayerManager.prototype.observeClick = function () {
1791
- var _this = this;
1792
- this.postboy.subscribe(MapClickEvent.ID).subscribe(function (m) {
1793
- var _a, _b;
1794
- if (((_b = (_a = m.features[_this.settings.name]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 1) {
1795
- _this.postboy.fire(new FitToFeaturesCommand(m.features[_this.settings.name], -1));
1796
- }
1797
- });
1798
- };
1799
- return ClusterLayerManager;
1800
- }());
1801
-
1802
- var ClusterLayerFactory = /** @class */ (function () {
1803
- function ClusterLayerFactory() {
1804
- }
1805
- ClusterLayerFactory.prototype.build = function (settings, postboy) {
1806
- var source$1 = new source.Vector({
1807
- strategy: settings.bbox ? loadingstrategy.bbox : undefined,
1808
- });
1809
- var cluster = new Cluster__default["default"]({
1810
- distance: settings.distance,
1811
- source: source$1,
1812
- geometryFunction: function (feature) {
1813
- var _a, _b;
1814
- var geom = feature.getGeometry();
1815
- if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Point') {
1816
- return geom;
1817
- }
1818
- else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'Polygon') {
1819
- return (_a = geom) === null || _a === void 0 ? void 0 : _a.getInteriorPoint();
1820
- }
1821
- else if ((geom === null || geom === void 0 ? void 0 : geom.getType()) == 'MultiPolygon') {
1822
- return (_b = Polygon.fromExtent(geom.getExtent())) === null || _b === void 0 ? void 0 : _b.getInteriorPoint();
1823
- }
1824
- return undefined;
1825
- },
1826
- });
1827
- var layer$1 = new layer.Vector({
1828
- source: cluster,
1829
- maxZoom: settings.maxZoom || undefined,
1830
- minZoom: settings.minZoom || undefined,
1831
- zIndex: settings.zIndex || 0,
1832
- });
1833
- layer$1.setStyle(this.styleFunc(settings));
1834
- layer$1.set('name', settings.name);
1835
- return new ClusterLayerManager(settings, layer$1, postboy);
1836
- };
1837
- ClusterLayerFactory.prototype.styleFunc = function (settings) {
1838
- return function (feature) {
1839
- var features = feature.get('features');
1840
- if (!settings.style)
1841
- return undefined;
1842
- return settings.style(features.map(function (f) { return (Object.assign({ id: f.getId() }, f.get(MapConstants.FeatureInfo))); }));
1843
- };
1844
- };
1845
- return ClusterLayerFactory;
1846
- }());
1847
- ClusterLayerFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1848
- ClusterLayerFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerFactory, providedIn: 'root' });
1849
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerFactory, decorators: [{
1850
- type: i0.Injectable,
1851
- args: [{
1852
- providedIn: 'root',
1853
- }]
1854
- }] });
1855
-
1856
- var ClusterLayerComponent = /** @class */ (function (_super) {
1857
- __extends(ClusterLayerComponent, _super);
1858
- function ClusterLayerComponent(postboy, factory) {
1859
- var _this = _super.call(this) || this;
1860
- _this.postboy = postboy;
1861
- _this.factory = factory;
1862
- _this.manager = null;
1863
- _this._settings = new ClusterLayerSettings();
1864
- _this.onDestroy = function () { return _this.removeLayer(); };
1865
- return _this;
1866
- }
1867
- ClusterLayerComponent.prototype.ngOnInit = function () {
1868
- var _this = this;
1869
- this.postboy
1870
- .subscribe(MapRenderedEvent.ID)
1871
- .pipe(operators.filter(function (m) { return !!m; }), operators.first())
1872
- .subscribe(function (m) { return _this.initLayer(); });
1873
- };
1874
- Object.defineProperty(ClusterLayerComponent.prototype, "settings", {
1875
- set: function (value) {
1876
- if (!value || this._settings.isSame(value))
1877
- return;
1878
- this._settings = value;
1879
- this.initLayer();
1880
- },
1881
- enumerable: false,
1882
- configurable: true
1883
- });
1884
- ClusterLayerComponent.prototype.initLayer = function () {
1885
- this.removeLayer();
1886
- this.manager = this.factory.build(this._settings, this.postboy);
1887
- this.postboy.fire(new AddLayerCommand(this.manager.layer));
1888
- };
1889
- ClusterLayerComponent.prototype.removeLayer = function () {
1890
- var _a;
1891
- if ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.layer)
1892
- this.postboy.fire(new RemoveLayerCommand(this.manager.layer));
1893
- };
1894
- return ClusterLayerComponent;
1895
- }(DestructibleComponent));
1896
- ClusterLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerComponent, deps: [{ token: MapPostboyService }, { token: ClusterLayerFactory }], target: i0__namespace.ɵɵFactoryTarget.Component });
1897
- ClusterLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ClusterLayerComponent, selector: "lib-cluster-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1898
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ClusterLayerComponent, decorators: [{
1899
- type: i0.Component,
1900
- args: [{
1901
- selector: 'lib-cluster-layer',
1902
- template: '',
1903
- styleUrls: [],
1904
- changeDetection: i0.ChangeDetectionStrategy.OnPush,
1905
- }]
1906
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ClusterLayerFactory }]; }, propDecorators: { settings: [{
1907
- type: i0.Input
1908
- }] } });
1909
-
1910
2168
  var MapModule = /** @class */ (function () {
1911
2169
  function MapModule() {
1912
2170
  }
@@ -1921,18 +2179,18 @@
1921
2179
  MarkersComponent,
1922
2180
  TooltipComponent,
1923
2181
  PolygonsComponent,
1924
- ClusterLayerComponent], imports: [i5.CommonModule], exports: [MapPlateComponent,
2182
+ ClusterLayerComponent], imports: [i6.CommonModule], exports: [MapPlateComponent,
1925
2183
  FeatureLayerComponent,
1926
2184
  MarkersComponent,
1927
2185
  TileLayerComponent,
1928
2186
  TooltipComponent,
1929
2187
  PolygonsComponent,
1930
2188
  ClusterLayerComponent] });
1931
- MapModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapModule, imports: [[i5.CommonModule]] });
2189
+ MapModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapModule, imports: [[i6.CommonModule]] });
1932
2190
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapModule, decorators: [{
1933
2191
  type: i0.NgModule,
1934
2192
  args: [{
1935
- imports: [i5.CommonModule],
2193
+ imports: [i6.CommonModule],
1936
2194
  declarations: [
1937
2195
  DestructibleComponent,
1938
2196
  MapPlateComponent,
@@ -2023,6 +2281,59 @@
2023
2281
  return TextStyleHelper;
2024
2282
  }());
2025
2283
 
2284
+ var StringifyFeatureHelper = /** @class */ (function () {
2285
+ function StringifyFeatureHelper() {
2286
+ }
2287
+ StringifyFeatureHelper.polygon = function (feature, format$1) {
2288
+ if (format$1 === void 0) { format$1 = exports.FeatureOutputFormat.GeoJson; }
2289
+ return format$1 === exports.FeatureOutputFormat.GeoJson
2290
+ ? new format.GeoJSON().writeFeature(feature)
2291
+ : new format.WKT().writeFeature(feature);
2292
+ };
2293
+ StringifyFeatureHelper.circle = function (feature, format) {
2294
+ if (format === void 0) { format = exports.FeatureOutputFormat.GeoJson; }
2295
+ // const clone = feature.clone();
2296
+ // clone.setGeometry(fromCircle(feature.getGeometry()! as Circle));
2297
+ var tetemp = feature.getGeometryName();
2298
+ var circle = feature.getGeometry();
2299
+ // const temp = StringifyFeatureHelper.drawCircle(circle.getCenter(), circle.getRadius());
2300
+ var ttt = feature.getGeometry().getExtent();
2301
+ var eastPoint = [ttt[2], (ttt[1] + ttt[3]) / 2];
2302
+ var aaa = __spreadArray(__spreadArray([], __read(proj.transform([ttt[0], ttt[1]], 'EPSG:4326', 'EPSG:3857'))), __read(proj.transform([ttt[2], ttt[3]], 'EPSG:4326', 'EPSG:3857')));
2303
+ var radius = (aaa[2] - aaa[0]) / 2;
2304
+ var radius2 = new geom.LineString([circle.getCenter(), eastPoint]).getLength();
2305
+ var polygonGeom = new Polygon__default["default"](StringifyFeatureHelper.drawCircle(circle.getCenter(), radius));
2306
+ // var edgeCoordinate = [circle.getCenter()[0] + radius, circle.getCenter()[1]];
2307
+ // var wgs84Sphere = new Sphere(6378137);
2308
+ return StringifyFeatureHelper.polygon(new ol.Feature(polygonGeom), format);
2309
+ // const rad = circle.getRadius();
2310
+ // const degrees = 180 / Math.PI; // radians to degrees
2311
+ // const radians = Math.PI / 180; // degrees to radians
2312
+ // const rlat = rad * degrees * 1000;
2313
+ // const rlng = rad * radians;
2314
+ // return StringifyFeatureHelper.polygon(new Feature<Geometry>(circular(circle.getCenter(),circle.getRadius() * METERS_PER_UNIT)), format);
2315
+ };
2316
+ StringifyFeatureHelper.drawCircle = function (point, radius) {
2317
+ var tetetemp = proj.transform(point, 'EPSG:4326', 'EPSG:3857');
2318
+ // const tetetemp = point;
2319
+ var radians = Math.PI / 180; // degrees to radians
2320
+ var degrees = 180 / Math.PI; // radians to degrees
2321
+ var earthsradius = 6378137.0;
2322
+ var rlat = (radius / earthsradius) * degrees;
2323
+ var rlng = rlat / Math.cos(tetetemp[1] * radians);
2324
+ var extp = [];
2325
+ for (var i = 0; i <= 32; i++) {
2326
+ var theta = Math.PI * (i / 16);
2327
+ extp.push([
2328
+ tetetemp[0] + rlng * Math.cos(theta) * epsg4326.METERS_PER_UNIT,
2329
+ tetetemp[1] + rlat * Math.sin(theta) * epsg4326.METERS_PER_UNIT,
2330
+ ]);
2331
+ }
2332
+ return [extp.map(function (e) { return proj.transform(e, 'EPSG:3857', 'EPSG:4326'); })];
2333
+ };
2334
+ return StringifyFeatureHelper;
2335
+ }());
2336
+
2026
2337
  /*
2027
2338
  * Public API Surface of maps
2028
2339
  */
@@ -2035,16 +2346,16 @@
2035
2346
  * Generated bundle index. Do not edit.
2036
2347
  */
2037
2348
 
2038
- exports.CallbackMessage = CallbackMessage;
2349
+ exports.CancelDrawingCommand = CancelDrawingCommand;
2039
2350
  exports.CloseTooltipCommand = CloseTooltipCommand;
2040
2351
  exports.ClusterLayerComponent = ClusterLayerComponent;
2041
2352
  exports.ClusterLayerSettings = ClusterLayerSettings;
2042
2353
  exports.FeatureLayerComponent = FeatureLayerComponent;
2043
2354
  exports.FeatureLayerSettings = FeatureLayerSettings;
2044
- exports.GenericMessage = GenericMessage;
2045
2355
  exports.MapClickEvent = MapClickEvent;
2046
2356
  exports.MapLyrsLabel = MapLyrsLabel;
2047
2357
  exports.MapModule = MapModule;
2358
+ exports.MapMoveEndEvent = MapMoveEndEvent;
2048
2359
  exports.MapPlateComponent = MapPlateComponent;
2049
2360
  exports.MapPostboyService = MapPostboyService;
2050
2361
  exports.MapRenderedEvent = MapRenderedEvent;
@@ -2057,6 +2368,8 @@
2057
2368
  exports.PolygonModel = PolygonModel;
2058
2369
  exports.PolygonStyleHelper = PolygonStyleHelper;
2059
2370
  exports.PolygonsComponent = PolygonsComponent;
2371
+ exports.StartDrawingCommand = StartDrawingCommand;
2372
+ exports.StringifyFeatureHelper = StringifyFeatureHelper;
2060
2373
  exports.TextStyleHelper = TextStyleHelper;
2061
2374
  exports.TileLayerComponent = TileLayerComponent;
2062
2375
  exports.TileLayerSettings = TileLayerSettings;