@artstesh/maps 1.0.0 → 1.0.3

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 (78) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +307 -134
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +307 -134
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.component.js +40 -6
  6. package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.factory.js +50 -0
  7. package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.settings.js +14 -8
  8. package/dist/esm2015/map/map-plate/map-plate.component.js +8 -7
  9. package/dist/esm2015/map/map.module.js +3 -3
  10. package/dist/esm2015/map/messages/commands/add-tile.command.js +12 -0
  11. package/dist/esm2015/map/messages/commands/remove-tile.command.js +12 -0
  12. package/dist/esm2015/map/messages/events/map-click.event.js +13 -0
  13. package/dist/esm2015/map/messages/index.js +2 -1
  14. package/dist/esm2015/map/models/marker-model.js +4 -7
  15. package/dist/esm2015/map/services/map-click.service.js +51 -0
  16. package/dist/esm2015/map/services/map-management.service.js +21 -9
  17. package/dist/esm2015/map/services/map-postboy.service.js +6 -17
  18. package/dist/esm2015/map/services/map-state.service.js +4 -2
  19. package/dist/esm2015/map/services/message-registrator.service.js +23 -12
  20. package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.component.js +40 -6
  21. package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.factory.js +50 -0
  22. package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.settings.js +14 -8
  23. package/dist/esm2015/src/map/map-plate/map-plate.component.js +8 -7
  24. package/dist/esm2015/src/map/map.module.js +3 -3
  25. package/dist/esm2015/src/map/messages/commands/add-tile.command.js +12 -0
  26. package/dist/esm2015/src/map/messages/commands/remove-tile.command.js +12 -0
  27. package/dist/esm2015/src/map/messages/events/map-click.event.js +13 -0
  28. package/dist/esm2015/src/map/messages/index.js +2 -1
  29. package/dist/esm2015/src/map/models/marker-model.js +4 -7
  30. package/dist/esm2015/src/map/services/map-click.service.js +51 -0
  31. package/dist/esm2015/src/map/services/map-management.service.js +21 -9
  32. package/dist/esm2015/src/map/services/map-postboy.service.js +6 -17
  33. package/dist/esm2015/src/map/services/map-state.service.js +4 -2
  34. package/dist/esm2015/src/map/services/message-registrator.service.js +23 -12
  35. package/dist/fesm2015/maps-components-src-map.js +263 -119
  36. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  37. package/dist/fesm2015/maps-components.js +263 -119
  38. package/dist/fesm2015/maps-components.js.map +1 -1
  39. package/dist/map/map-plate/layers/tile-layer/tile-layer.component.d.ts +14 -5
  40. package/dist/map/map-plate/layers/tile-layer/tile-layer.factory.d.ts +11 -0
  41. package/dist/map/map-plate/layers/tile-layer/tile-layer.settings.d.ts +3 -2
  42. package/dist/map/map-plate/map-plate.component.d.ts +2 -2
  43. package/dist/map/map.module.d.ts +1 -1
  44. package/dist/map/messages/commands/add-tile.command.d.ts +9 -0
  45. package/dist/map/messages/commands/remove-tile.command.d.ts +9 -0
  46. package/dist/map/messages/events/map-click.event.d.ts +12 -0
  47. package/dist/map/messages/index.d.ts +1 -0
  48. package/dist/map/models/marker-model.d.ts +2 -2
  49. package/dist/map/services/map-click.service.d.ts +16 -0
  50. package/dist/map/services/map-management.service.d.ts +5 -2
  51. package/dist/map/services/map-postboy.service.d.ts +4 -7
  52. package/dist/map/services/map-state.service.d.ts +3 -1
  53. package/dist/map/services/message-registrator.service.d.ts +7 -2
  54. package/dist/package.json +2 -1
  55. package/dist/src/map/map-plate/layers/tile-layer/tile-layer.component.d.ts +14 -5
  56. package/dist/src/map/map-plate/layers/tile-layer/tile-layer.factory.d.ts +11 -0
  57. package/dist/src/map/map-plate/layers/tile-layer/tile-layer.settings.d.ts +3 -2
  58. package/dist/src/map/map-plate/map-plate.component.d.ts +2 -2
  59. package/dist/src/map/map.module.d.ts +1 -1
  60. package/dist/src/map/messages/commands/add-tile.command.d.ts +9 -0
  61. package/dist/src/map/messages/commands/remove-tile.command.d.ts +9 -0
  62. package/dist/src/map/messages/events/map-click.event.d.ts +12 -0
  63. package/dist/src/map/messages/index.d.ts +1 -0
  64. package/dist/src/map/models/marker-model.d.ts +2 -2
  65. package/dist/src/map/services/map-click.service.d.ts +16 -0
  66. package/dist/src/map/services/map-management.service.d.ts +5 -2
  67. package/dist/src/map/services/map-postboy.service.d.ts +4 -7
  68. package/dist/src/map/services/map-state.service.d.ts +3 -1
  69. package/dist/src/map/services/message-registrator.service.d.ts +7 -2
  70. package/package.json +4 -3
  71. package/dist/esm2015/map/messages/commands/clear-layer.command.js +0 -12
  72. package/dist/esm2015/map/services/service.collector.js +0 -14
  73. package/dist/esm2015/src/map/messages/commands/clear-layer.command.js +0 -12
  74. package/dist/esm2015/src/map/services/service.collector.js +0 -14
  75. package/dist/map/messages/commands/clear-layer.command.d.ts +0 -7
  76. package/dist/map/services/service.collector.d.ts +0 -9
  77. package/dist/src/map/messages/commands/clear-layer.command.d.ts +0 -7
  78. package/dist/src/map/services/service.collector.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/proj'), require('rxjs'), 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/style/Style'), require('ol/style')) :
3
- typeof define === 'function' && define.amd ? define('maps-components/src/map', ['exports', '@angular/core', '@angular/common', 'ol', 'ol/geom', 'ol/proj', 'rxjs', 'ol/Map', 'ol/View', 'ol/layer/Tile', 'ol/source/OSM', 'rxjs/operators', 'ol/source', 'ol/layer', 'ol/style/Style', 'ol/style'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["maps-components"] = global["maps-components"] || {}, global["maps-components"].src = global["maps-components"].src || {}, global["maps-components"].src.map = {}), global.ng.core, global.ng.common, global.ol, global.geom, global.proj, global.rxjs, global.Map, global.View, global.TileLayer, global.OSM, global.rxjs.operators, global.source, global.layer, global.Style, global.style));
5
- })(this, (function (exports, i0, i5, ol, geom, proj, rxjs, Map, View, TileLayer, OSM, operators, source, layer, 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/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/style/Style'), require('ol/style')) :
3
+ typeof define === 'function' && define.amd ? define('maps-components/src/map', ['exports', '@angular/core', '@angular/common', 'ol', 'ol/geom', 'ol/proj', 'rxjs', '@artstesh/postboy', 'ol/Map', 'ol/View', 'ol/layer/Tile', 'ol/source/OSM', 'rxjs/operators', 'ol/source', 'ol/layer', 'ol/style/Style', 'ol/style'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["maps-components"] = global["maps-components"] || {}, global["maps-components"].src = global["maps-components"].src || {}, global["maps-components"].src.map = {}), global.ng.core, global.ng.common, global.ol, global.geom, global.proj, global.rxjs, global.postboy, global.Map, global.View, global.TileLayer, global.OSM, global.rxjs.operators, global.source, global.layer, global.Style, global.style));
5
+ })(this, (function (exports, i0, i5, ol, geom, proj, rxjs, postboy, Map, View, TileLayer, OSM, operators, source, layer, Style, style) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -611,10 +611,8 @@
611
611
  function MarkerModel(lat, lng, id, info) {
612
612
  this.lat = lat;
613
613
  this.lng = lng;
614
- this.id = id;
615
614
  this.info = info;
616
- if (id == null)
617
- this.id = IdGenerator.get();
615
+ this.id = id == null ? IdGenerator.get() : id;
618
616
  this._feature = this.getFeature();
619
617
  }
620
618
  Object.defineProperty(MarkerModel.prototype, "feature", {
@@ -625,12 +623,10 @@
625
623
  configurable: true
626
624
  });
627
625
  MarkerModel.prototype.getFeature = function () {
628
- var _this = this;
629
626
  var feature = new ol.Feature(new geom.Point([this.lng, this.lat]));
630
627
  feature.setId(this.id);
631
- if (this.info) {
632
- Object.keys(this.info).forEach(function (k) { return feature.set(k, _this.info[k]); });
633
- }
628
+ if (this.info)
629
+ feature.set('info', this.info);
634
630
  return feature;
635
631
  };
636
632
  return MarkerModel;
@@ -674,6 +670,25 @@
674
670
  }(GenericMessage));
675
671
  MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
676
672
 
673
+ var MapClickEvent = /** @class */ (function (_super) {
674
+ __extends(MapClickEvent, _super);
675
+ function MapClickEvent(coordinates, entities) {
676
+ var _this = _super.call(this) || this;
677
+ _this.coordinates = coordinates;
678
+ _this.entities = entities;
679
+ return _this;
680
+ }
681
+ Object.defineProperty(MapClickEvent.prototype, "id", {
682
+ get: function () {
683
+ return MapClickEvent.ID;
684
+ },
685
+ enumerable: false,
686
+ configurable: true
687
+ });
688
+ return MapClickEvent;
689
+ }(GenericMessage));
690
+ MapClickEvent.ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
691
+
677
692
  var AddLayerCommand = /** @class */ (function (_super) {
678
693
  __extends(AddLayerCommand, _super);
679
694
  function AddLayerCommand(layer) {
@@ -729,100 +744,90 @@
729
744
  }(GenericMessage));
730
745
  RemoveLayerCommand.ID = 'ab484e0e-e185-45cd-8434-12101f3c7eb1';
731
746
 
732
- var ClearLayerCommand = /** @class */ (function (_super) {
733
- __extends(ClearLayerCommand, _super);
734
- function ClearLayerCommand(layer) {
747
+ var AddTileCommand = /** @class */ (function (_super) {
748
+ __extends(AddTileCommand, _super);
749
+ function AddTileCommand(layer) {
735
750
  var _this = _super.call(this) || this;
736
751
  _this.layer = layer;
737
752
  return _this;
738
753
  }
739
- Object.defineProperty(ClearLayerCommand.prototype, "id", {
754
+ Object.defineProperty(AddTileCommand.prototype, "id", {
740
755
  get: function () {
741
- return ClearLayerCommand.ID;
756
+ return AddTileCommand.ID;
742
757
  },
743
758
  enumerable: false,
744
759
  configurable: true
745
760
  });
746
- return ClearLayerCommand;
761
+ return AddTileCommand;
747
762
  }(GenericMessage));
748
- ClearLayerCommand.ID = 'd02842b7-fa62-458d-b1e4-12dd814610c5';
763
+ AddTileCommand.ID = '25b7df28-72ce-4453-9fe6-54285a2fdc57';
749
764
 
750
- var MapPostboyService = /** @class */ (function () {
765
+ var RemoveTileCommand = /** @class */ (function (_super) {
766
+ __extends(RemoveTileCommand, _super);
767
+ function RemoveTileCommand(layer) {
768
+ var _this = _super.call(this) || this;
769
+ _this.layer = layer;
770
+ return _this;
771
+ }
772
+ Object.defineProperty(RemoveTileCommand.prototype, "id", {
773
+ get: function () {
774
+ return RemoveTileCommand.ID;
775
+ },
776
+ enumerable: false,
777
+ configurable: true
778
+ });
779
+ return RemoveTileCommand;
780
+ }(GenericMessage));
781
+ RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
782
+
783
+ var MapPostboyService = /** @class */ (function (_super) {
784
+ __extends(MapPostboyService, _super);
751
785
  function MapPostboyService() {
752
- this.applications = {};
786
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
787
+ _this.observe = function (id) { return _this.subscribe(id); };
788
+ return _this;
753
789
  }
754
- MapPostboyService.prototype.register = function (id, sub) {
755
- this.applications[id] = sub;
756
- };
757
- MapPostboyService.prototype.subscribe = function (id) {
758
- if (!this.applications[id])
759
- throw new Error("There is no event with id " + id);
760
- return this.applications[id].asObservable();
761
- };
762
- MapPostboyService.prototype.fire = function (message) {
763
- if (!this.applications[message.id])
764
- throw new Error("There is no event with id " + message.id);
765
- this.applications[message.id].next(message);
766
- };
767
790
  return MapPostboyService;
768
- }());
769
- MapPostboyService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPostboyService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
791
+ }(postboy.PostboyService));
792
+ 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 });
770
793
  MapPostboyService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPostboyService });
771
794
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPostboyService, decorators: [{
772
795
  type: i0.Injectable
773
796
  }] });
774
797
 
775
- var MessageRegistratorService = /** @class */ (function () {
776
- function MessageRegistratorService(service) {
777
- service.register(MapRenderedEvent.ID, new rxjs.ReplaySubject(1));
778
- service.register(AddLayerCommand.ID, new rxjs.Subject());
779
- service.register(PlaceLayerFeaturesCommand.ID, new rxjs.ReplaySubject(1));
780
- service.register(RemoveLayerCommand.ID, new rxjs.Subject());
781
- service.register(ClearLayerCommand.ID, new rxjs.Subject());
782
- }
783
- return MessageRegistratorService;
784
- }());
785
- MessageRegistratorService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
786
- MessageRegistratorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService });
787
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, decorators: [{
788
- type: i0.Injectable
789
- }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
790
-
791
- var MapStateService = /** @class */ (function () {
792
- function MapStateService(postboy) {
793
- var _this = this;
794
- this.postboy = postboy;
795
- postboy.subscribe(MapRenderedEvent.ID).subscribe(function (m) { return (_this.map = m); });
796
- }
797
- return MapStateService;
798
- }());
799
- MapStateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
800
- MapStateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapStateService });
801
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapStateService, decorators: [{
802
- type: i0.Injectable
803
- }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
804
-
805
798
  var MapManagementService = /** @class */ (function () {
806
799
  function MapManagementService(postboy) {
807
800
  this.postboy = postboy;
808
801
  this.layers = {};
802
+ }
803
+ MapManagementService.prototype.up = function () {
809
804
  this.observeMapRender();
810
805
  this.observeAddLayer();
811
806
  this.observeRemoveLayer();
812
807
  this.observePlaceFeatures();
813
- this.observeClearLayer();
814
- }
815
- MapManagementService.prototype.observeMapRender = function () {
808
+ this.observeAddTile();
809
+ this.observeRemoveTile();
810
+ };
811
+ MapManagementService.prototype.observeRemoveTile = function () {
816
812
  var _this = this;
817
- this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (m) {
818
- _this.map = m.map;
813
+ this.postboy.subscribe(RemoveTileCommand.ID).subscribe(function (c) {
814
+ if (!_this.map)
815
+ return;
816
+ _this.map.removeLayer(c.layer);
819
817
  });
820
818
  };
821
- MapManagementService.prototype.observeClearLayer = function () {
819
+ MapManagementService.prototype.observeAddTile = function () {
822
820
  var _this = this;
823
- this.postboy.subscribe(ClearLayerCommand.ID).subscribe(function (c) {
824
- var _a, _b;
825
- (_b = (_a = _this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear();
821
+ this.postboy.subscribe(AddTileCommand.ID).subscribe(function (c) {
822
+ if (!_this.map)
823
+ return;
824
+ _this.map.addLayer(c.layer);
825
+ });
826
+ };
827
+ MapManagementService.prototype.observeMapRender = function () {
828
+ var _this = this;
829
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (m) {
830
+ _this.map = m.map;
826
831
  });
827
832
  };
828
833
  MapManagementService.prototype.observeAddLayer = function () {
@@ -861,16 +866,94 @@
861
866
  type: i0.Injectable
862
867
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
863
868
 
864
- var ServiceCollector = /** @class */ (function () {
865
- function ServiceCollector(registrator, management, state) {
869
+ var MapStateService = /** @class */ (function () {
870
+ function MapStateService(postboy) {
871
+ this.postboy = postboy;
872
+ }
873
+ MapStateService.prototype.up = function () {
874
+ var _this = this;
875
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (m) { return (_this.map = m); });
876
+ };
877
+ return MapStateService;
878
+ }());
879
+ MapStateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
880
+ MapStateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapStateService });
881
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapStateService, decorators: [{
882
+ type: i0.Injectable
883
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
884
+
885
+ var MapClickService = /** @class */ (function () {
886
+ function MapClickService(postboy) {
887
+ this.postboy = postboy;
866
888
  }
867
- return ServiceCollector;
889
+ MapClickService.prototype.up = function () {
890
+ this.observeMapRender();
891
+ };
892
+ MapClickService.prototype.observeMapRender = function () {
893
+ var _this = this;
894
+ this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (m) {
895
+ var _a;
896
+ _this.map = m.map;
897
+ (_a = _this.map) === null || _a === void 0 ? void 0 : _a.on('singleclick', function (e) {
898
+ _this.postboy.fire(_this.onClick(e));
899
+ });
900
+ });
901
+ };
902
+ MapClickService.prototype.onClick = function (ev) {
903
+ var _this = this;
904
+ var _a;
905
+ var model = new MapClickEvent(ev.coordinate, {});
906
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.forEachFeatureAtPixel(ev.pixel, function (f, l) {
907
+ _this.getFeatureCollectionWithInner([f])
908
+ .filter(function (f) { return !!f.getId(); })
909
+ .forEach(function (fs) {
910
+ var layerName = l.get('name');
911
+ if (!model.entities[layerName])
912
+ model.entities[layerName] = [];
913
+ model.entities[layerName].push(f.getId());
914
+ });
915
+ });
916
+ return model;
917
+ };
918
+ MapClickService.prototype.getFeatureCollectionWithInner = function (features) {
919
+ var result = [];
920
+ features === null || features === void 0 ? void 0 : features.forEach(function (f) {
921
+ var innerFeatures = f.get('features');
922
+ (innerFeatures === null || innerFeatures === void 0 ? void 0 : innerFeatures.length) ? result.push.apply(result, __spreadArray([], __read(innerFeatures))) : result.push(f);
923
+ });
924
+ return result;
925
+ };
926
+ return MapClickService;
868
927
  }());
869
- ServiceCollector.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ServiceCollector, deps: [{ token: MessageRegistratorService }, { token: MapManagementService }, { token: MapStateService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
870
- ServiceCollector.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ServiceCollector });
871
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ServiceCollector, decorators: [{
928
+ MapClickService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapClickService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
929
+ MapClickService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapClickService });
930
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapClickService, decorators: [{
872
931
  type: i0.Injectable
873
- }], ctorParameters: function () { return [{ type: MessageRegistratorService }, { type: MapManagementService }, { type: MapStateService }]; } });
932
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
933
+
934
+ var MessageRegistratorService = /** @class */ (function (_super) {
935
+ __extends(MessageRegistratorService, _super);
936
+ function MessageRegistratorService(service, management, state, interaction) {
937
+ var _this = _super.call(this, service) || this;
938
+ _this.registerServices([management, state, interaction]);
939
+ return _this;
940
+ }
941
+ MessageRegistratorService.prototype._up = function () {
942
+ this.registerReplay(MapRenderedEvent.ID);
943
+ this.registerReplay(PlaceLayerFeaturesCommand.ID);
944
+ this.registerSubject(AddLayerCommand.ID);
945
+ this.registerSubject(RemoveLayerCommand.ID);
946
+ this.registerSubject(AddTileCommand.ID);
947
+ this.registerSubject(RemoveTileCommand.ID);
948
+ this.registerSubject(MapClickEvent.ID);
949
+ };
950
+ return MessageRegistratorService;
951
+ }(postboy.PostboyAbstractRegistrator));
952
+ 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: MapClickService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
953
+ MessageRegistratorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService });
954
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, decorators: [{
955
+ type: i0.Injectable
956
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapClickService }]; } });
874
957
 
875
958
  var MapPlateFactory = /** @class */ (function () {
876
959
  function MapPlateFactory() {
@@ -975,6 +1058,7 @@
975
1058
  _this.detector = detector;
976
1059
  _this.osmUrl = '';
977
1060
  _this._settings = new MapSettings();
1061
+ registrator.up();
978
1062
  return _this;
979
1063
  }
980
1064
  Object.defineProperty(MapPlateComponent.prototype, "settings", {
@@ -1008,8 +1092,8 @@
1008
1092
  };
1009
1093
  return MapPlateComponent;
1010
1094
  }(DestructibleComponent));
1011
- 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: ServiceCollector }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
1012
- 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, ServiceCollector], 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 });
1095
+ 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 });
1096
+ 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], 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 });
1013
1097
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, decorators: [{
1014
1098
  type: i0.Component,
1015
1099
  args: [{
@@ -1017,21 +1101,149 @@
1017
1101
  templateUrl: './map-plate.component.html',
1018
1102
  styleUrls: ['./map-plate.component.scss'],
1019
1103
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1020
- providers: [MessageRegistratorService, MapStateService, MapManagementService, ServiceCollector],
1104
+ providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService],
1021
1105
  }]
1022
- }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: ServiceCollector }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1106
+ }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1023
1107
  type: i0.Input
1024
1108
  }] } });
1025
1109
 
1110
+ var TileLayerSettings = /** @class */ (function () {
1111
+ function TileLayerSettings() {
1112
+ this.maxZoom = 19;
1113
+ this.minZoom = 0;
1114
+ this.opacity = 0.6;
1115
+ this.url = '';
1116
+ this.projection = 'EPSG:3857';
1117
+ }
1118
+ TileLayerSettings.copy = function (model) {
1119
+ var result = new TileLayerSettings();
1120
+ result.maxZoom = model.maxZoom;
1121
+ result.minZoom = model.minZoom;
1122
+ result.projection = model.projection;
1123
+ result.opacity = model.opacity;
1124
+ result.url = model.url;
1125
+ return result;
1126
+ };
1127
+ TileLayerSettings.prototype.setUrl = function (url) {
1128
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url: url }));
1129
+ };
1130
+ TileLayerSettings.prototype.setMaxZoom = function (maxZoom) {
1131
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom: maxZoom }));
1132
+ };
1133
+ TileLayerSettings.prototype.setMinZoom = function (minZoom) {
1134
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom: minZoom }));
1135
+ };
1136
+ TileLayerSettings.prototype.setOpacity = function (opacity) {
1137
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { opacity: opacity }));
1138
+ };
1139
+ TileLayerSettings.prototype.setProjection = function (projection) {
1140
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { projection: projection }));
1141
+ };
1142
+ TileLayerSettings.prototype.isSame = function (model) {
1143
+ if (this.maxZoom !== model.maxZoom)
1144
+ return false;
1145
+ if (this.minZoom !== model.minZoom)
1146
+ return false;
1147
+ if (this.url !== model.url)
1148
+ return false;
1149
+ if (this.projection !== model.projection)
1150
+ return false;
1151
+ if (this.opacity !== model.opacity)
1152
+ return false;
1153
+ return true;
1154
+ };
1155
+ return TileLayerSettings;
1156
+ }());
1157
+
1158
+ var TileLayerFactory = /** @class */ (function () {
1159
+ function TileLayerFactory() {
1160
+ }
1161
+ TileLayerFactory.prototype.build = function (settings) {
1162
+ var source$1 = new source.XYZ({
1163
+ tileSize: 256,
1164
+ maxZoom: settings.maxZoom || 14,
1165
+ minZoom: settings.minZoom || 1,
1166
+ projection: proj.get(settings.projection),
1167
+ tileUrlFunction: this.getTileFunc(settings),
1168
+ crossOrigin: 'Anonymous',
1169
+ });
1170
+ return new TileLayer__default["default"]({ source: source$1, opacity: settings.opacity });
1171
+ };
1172
+ TileLayerFactory.prototype.getTileFunc = function (settings) {
1173
+ var _this = this;
1174
+ return function (tileCoord) {
1175
+ var zoom = tileCoord[0];
1176
+ var x = tileCoord[1];
1177
+ var y = tileCoord[2];
1178
+ var normalizedCoord = _this.getNormalizedCoord({ x: x, y: y }, zoom);
1179
+ var bound = 1 << zoom;
1180
+ return settings.url
1181
+ .replace('{x}', String((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.x) || x))
1182
+ .replace('{z}', String(zoom))
1183
+ .replace('{y}', String(bound - ((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.y) || y) - 1));
1184
+ };
1185
+ };
1186
+ TileLayerFactory.prototype.getNormalizedCoord = function (coord, zoom) {
1187
+ var y = coord.y;
1188
+ var x = coord.x;
1189
+ var tileRange = 1 << zoom;
1190
+ if (y < 0 || y >= tileRange)
1191
+ return null;
1192
+ if (x < 0 || x >= tileRange)
1193
+ x = ((x % tileRange) + tileRange) % tileRange;
1194
+ return { x: x, y: y };
1195
+ };
1196
+ return TileLayerFactory;
1197
+ }());
1198
+ TileLayerFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1199
+ TileLayerFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, providedIn: 'root' });
1200
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerFactory, decorators: [{
1201
+ type: i0.Injectable,
1202
+ args: [{
1203
+ providedIn: 'root',
1204
+ }]
1205
+ }] });
1206
+
1026
1207
  var TileLayerComponent = /** @class */ (function (_super) {
1027
1208
  __extends(TileLayerComponent, _super);
1028
- function TileLayerComponent() {
1029
- return _super.call(this) || this;
1209
+ function TileLayerComponent(postboy, factory) {
1210
+ var _this = _super.call(this) || this;
1211
+ _this.postboy = postboy;
1212
+ _this.factory = factory;
1213
+ _this._settings = new TileLayerSettings();
1214
+ _this.onDestroy = function () { return _this.removeLayer(); };
1215
+ return _this;
1030
1216
  }
1217
+ TileLayerComponent.prototype.ngOnInit = function () {
1218
+ var _this = this;
1219
+ this.postboy
1220
+ .subscribe(MapRenderedEvent.ID)
1221
+ .pipe(operators.filter(function (m) { return !!m; }), operators.first())
1222
+ .subscribe(function (m) { return _this.initLayer(); });
1223
+ };
1224
+ Object.defineProperty(TileLayerComponent.prototype, "settings", {
1225
+ set: function (value) {
1226
+ if (!value || this._settings.isSame(value))
1227
+ return;
1228
+ this._settings = value;
1229
+ this.initLayer();
1230
+ },
1231
+ enumerable: false,
1232
+ configurable: true
1233
+ });
1234
+ TileLayerComponent.prototype.initLayer = function () {
1235
+ this.removeLayer();
1236
+ this.layer = this.factory.build(this._settings);
1237
+ this.postboy.fire(new AddTileCommand(this.layer));
1238
+ };
1239
+ TileLayerComponent.prototype.removeLayer = function () {
1240
+ if (this.layer)
1241
+ this.postboy.fire(new RemoveTileCommand(this.layer));
1242
+ };
1031
1243
  return TileLayerComponent;
1032
1244
  }(DestructibleComponent));
1033
- TileLayerComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
1034
- TileLayerComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TileLayerComponent, selector: "lib-tile-layer", usesInheritance: true, ngImport: i0__namespace, template: '', isInline: true, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
1245
+ 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 });
1246
+ 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 });
1035
1247
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TileLayerComponent, decorators: [{
1036
1248
  type: i0.Component,
1037
1249
  args: [{
@@ -1040,7 +1252,9 @@
1040
1252
  styleUrls: [],
1041
1253
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1042
1254
  }]
1043
- }], ctorParameters: function () { return []; } });
1255
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: TileLayerFactory }]; }, propDecorators: { settings: [{
1256
+ type: i0.Input
1257
+ }] } });
1044
1258
 
1045
1259
  var FeatureLayerSettings = /** @class */ (function () {
1046
1260
  function FeatureLayerSettings() {
@@ -1228,7 +1442,7 @@
1228
1442
  TileLayerComponent,
1229
1443
  OsmTileLayerComponent,
1230
1444
  FeatureLayerComponent,
1231
- MarkersComponent], imports: [i5.CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent] });
1445
+ MarkersComponent], imports: [i5.CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent] });
1232
1446
  MapModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapModule, imports: [[i5.CommonModule]] });
1233
1447
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapModule, decorators: [{
1234
1448
  type: i0.NgModule,
@@ -1242,52 +1456,10 @@
1242
1456
  FeatureLayerComponent,
1243
1457
  MarkersComponent,
1244
1458
  ],
1245
- exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent],
1459
+ exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent],
1246
1460
  }]
1247
1461
  }] });
1248
1462
 
1249
- var TileLayerSettings = /** @class */ (function () {
1250
- function TileLayerSettings() {
1251
- this.name = 'tiles';
1252
- this.maxZoom = 19;
1253
- this.minZoom = 0;
1254
- this.opacity = 1;
1255
- this.url = '';
1256
- }
1257
- TileLayerSettings.copy = function (model) {
1258
- var result = new TileLayerSettings();
1259
- result.name = model.name;
1260
- result.maxZoom = model.maxZoom;
1261
- result.minZoom = model.minZoom;
1262
- result.url = model.url;
1263
- return result;
1264
- };
1265
- TileLayerSettings.prototype.setUrl = function (url) {
1266
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url: url }));
1267
- };
1268
- TileLayerSettings.prototype.setName = function (name) {
1269
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { name: name }));
1270
- };
1271
- TileLayerSettings.prototype.setMaxZoom = function (maxZoom) {
1272
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom: maxZoom }));
1273
- };
1274
- TileLayerSettings.prototype.setMinZoom = function (minZoom) {
1275
- return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom: minZoom }));
1276
- };
1277
- TileLayerSettings.prototype.isSame = function (model) {
1278
- if (this.maxZoom !== model.maxZoom)
1279
- return false;
1280
- if (this.minZoom !== model.minZoom)
1281
- return false;
1282
- if (this.url !== model.url)
1283
- return false;
1284
- if (this.name !== model.name)
1285
- return false;
1286
- return true;
1287
- };
1288
- return TileLayerSettings;
1289
- }());
1290
-
1291
1463
  var MarkerStyleHelper = /** @class */ (function () {
1292
1464
  function MarkerStyleHelper() {
1293
1465
  }
@@ -1329,6 +1501,7 @@
1329
1501
  exports.FeatureLayerComponent = FeatureLayerComponent;
1330
1502
  exports.FeatureLayerSettings = FeatureLayerSettings;
1331
1503
  exports.GenericMessage = GenericMessage;
1504
+ exports.MapClickEvent = MapClickEvent;
1332
1505
  exports.MapLyrsLabel = MapLyrsLabel;
1333
1506
  exports.MapModule = MapModule;
1334
1507
  exports.MapPlateComponent = MapPlateComponent;