@artstesh/maps 1.1.2 → 1.1.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 (47) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +151 -9
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +151 -9
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/map-plate/map-plate.component.js +4 -1
  6. package/dist/esm2015/map/messages/commands/add-control.command.js +12 -0
  7. package/dist/esm2015/map/messages/commands/remove-control.command.js +12 -0
  8. package/dist/esm2015/map/messages/commands/set-map-center.command.js +23 -0
  9. package/dist/esm2015/map/messages/index.js +4 -1
  10. package/dist/esm2015/map/models/index.js +2 -1
  11. package/dist/esm2015/map/models/map-control.js +15 -0
  12. package/dist/esm2015/map/services/controls/controls.service.js +37 -0
  13. package/dist/esm2015/map/services/map-state.service.js +20 -4
  14. package/dist/esm2015/map/services/message-registrator.service.js +12 -5
  15. package/dist/esm2015/src/map/map-plate/map-plate.component.js +4 -1
  16. package/dist/esm2015/src/map/messages/commands/add-control.command.js +12 -0
  17. package/dist/esm2015/src/map/messages/commands/remove-control.command.js +12 -0
  18. package/dist/esm2015/src/map/messages/commands/set-map-center.command.js +23 -0
  19. package/dist/esm2015/src/map/messages/index.js +4 -1
  20. package/dist/esm2015/src/map/models/index.js +2 -1
  21. package/dist/esm2015/src/map/models/map-control.js +15 -0
  22. package/dist/esm2015/src/map/services/controls/controls.service.js +37 -0
  23. package/dist/esm2015/src/map/services/map-state.service.js +20 -4
  24. package/dist/esm2015/src/map/services/message-registrator.service.js +12 -5
  25. package/dist/fesm2015/maps-components-src-map.js +117 -7
  26. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  27. package/dist/fesm2015/maps-components.js +117 -7
  28. package/dist/fesm2015/maps-components.js.map +1 -1
  29. package/dist/map/messages/commands/add-control.command.d.ts +8 -0
  30. package/dist/map/messages/commands/remove-control.command.d.ts +8 -0
  31. package/dist/map/messages/commands/set-map-center.command.d.ts +18 -0
  32. package/dist/map/messages/index.d.ts +3 -0
  33. package/dist/map/models/index.d.ts +1 -0
  34. package/dist/map/models/map-control.d.ts +13 -0
  35. package/dist/map/services/controls/controls.service.d.ts +14 -0
  36. package/dist/map/services/map-state.service.d.ts +2 -0
  37. package/dist/map/services/message-registrator.service.d.ts +2 -1
  38. package/dist/src/map/messages/commands/add-control.command.d.ts +8 -0
  39. package/dist/src/map/messages/commands/remove-control.command.d.ts +8 -0
  40. package/dist/src/map/messages/commands/set-map-center.command.d.ts +18 -0
  41. package/dist/src/map/messages/index.d.ts +3 -0
  42. package/dist/src/map/models/index.d.ts +1 -0
  43. package/dist/src/map/models/map-control.d.ts +13 -0
  44. package/dist/src/map/services/controls/controls.service.d.ts +14 -0
  45. package/dist/src/map/services/map-state.service.d.ts +2 -0
  46. package/dist/src/map/services/message-registrator.service.d.ts +2 -1
  47. package/package.json +1 -1
@@ -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('@artstesh/postboy'), require('ol/interaction'), require('ol/interaction/Draw'), require('ol/control'), require('rxjs/operators'), require('ol/source'), 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', 'ol/interaction', 'ol/interaction/Draw', 'ol/control', 'rxjs/operators', 'ol/source', '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.interaction, global.Draw, global.control, global.rxjs.operators, global.source, 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, interaction, Draw, control, operators, source, TileLayer, OSM, layer, loadingstrategy, Polygon, Cluster, rxjs, Map, View, Overlay, Style, style, epsg4326) { '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/control'), require('ol/proj'), require('@artstesh/postboy'), require('ol/interaction'), require('ol/interaction/Draw'), require('rxjs/operators'), require('ol/source'), 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/control', 'ol/proj', '@artstesh/postboy', 'ol/interaction', 'ol/interaction/Draw', 'rxjs/operators', 'ol/source', '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.control, global.proj, global.postboy, global.interaction, global.Draw, global.rxjs.operators, global.source, 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, control, proj, postboy, interaction, Draw, operators, source, 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
 
@@ -752,6 +752,22 @@
752
752
  return Dictionary;
753
753
  }());
754
754
 
755
+ /**
756
+ *
757
+ * A control is a visible widget with a DOM element in a fixed position on the screen. They can involve user input (buttons), or be informational only; the position is determined using CSS. By default these are placed in the container with CSS class name ol-overlaycontainer-stopevent, but can use any outside DOM element.
758
+ * This is the base class for controls. You can use it for simple custom controls by creating the element with listeners, creating an instance:
759
+ * var myControl = new Control({element: myElement}); and then adding this to the map.
760
+ * The main advantage of having this as a control rather than a simple separate DOM element is that preventing propagation is handled for you. Controls will also be objects in a module:ol/Collection~Collection, so you can use their methods.
761
+ * You can also extend this base for your own control class. See examples/custom-controls for an example of how to do this.
762
+ */
763
+ var MapControl = /** @class */ (function (_super) {
764
+ __extends(MapControl, _super);
765
+ function MapControl(options) {
766
+ return _super.call(this, options) || this;
767
+ }
768
+ return MapControl;
769
+ }(control.Control));
770
+
755
771
  var MapRenderedEvent = /** @class */ (function (_super) {
756
772
  __extends(MapRenderedEvent, _super);
757
773
  function MapRenderedEvent(map) {
@@ -922,6 +938,71 @@
922
938
  }(postboy.PostboyGenericMessage));
923
939
  CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
924
940
 
941
+ var AddControlCommand = /** @class */ (function (_super) {
942
+ __extends(AddControlCommand, _super);
943
+ function AddControlCommand(item) {
944
+ var _this = _super.call(this) || this;
945
+ _this.item = item;
946
+ return _this;
947
+ }
948
+ Object.defineProperty(AddControlCommand.prototype, "id", {
949
+ get: function () {
950
+ return AddControlCommand.ID;
951
+ },
952
+ enumerable: false,
953
+ configurable: true
954
+ });
955
+ return AddControlCommand;
956
+ }(postboy.PostboyGenericMessage));
957
+ AddControlCommand.ID = '8e1c06eb-b395-4fe1-929c-ebf0805eeb49';
958
+
959
+ var RemoveControlCommand = /** @class */ (function (_super) {
960
+ __extends(RemoveControlCommand, _super);
961
+ function RemoveControlCommand(item) {
962
+ var _this = _super.call(this) || this;
963
+ _this.item = item;
964
+ return _this;
965
+ }
966
+ Object.defineProperty(RemoveControlCommand.prototype, "id", {
967
+ get: function () {
968
+ return RemoveControlCommand.ID;
969
+ },
970
+ enumerable: false,
971
+ configurable: true
972
+ });
973
+ return RemoveControlCommand;
974
+ }(postboy.PostboyGenericMessage));
975
+ RemoveControlCommand.ID = '361641e0-804a-4930-8c27-0cea6330dbfc';
976
+
977
+ /**
978
+ * Forces map to move to a specific point
979
+ */
980
+ var SetMapCenterCommand = /** @class */ (function (_super) {
981
+ __extends(SetMapCenterCommand, _super);
982
+ /**
983
+ *
984
+ * @param lat - the desired latitude
985
+ * @param lng - the desired longitude
986
+ * @param zoom - the desired zoom; doesn't change zoom if undefined
987
+ */
988
+ function SetMapCenterCommand(lat, lng, zoom) {
989
+ var _this = _super.call(this) || this;
990
+ _this.lat = lat;
991
+ _this.lng = lng;
992
+ _this.zoom = zoom;
993
+ return _this;
994
+ }
995
+ Object.defineProperty(SetMapCenterCommand.prototype, "id", {
996
+ get: function () {
997
+ return SetMapCenterCommand.ID;
998
+ },
999
+ enumerable: false,
1000
+ configurable: true
1001
+ });
1002
+ return SetMapCenterCommand;
1003
+ }(postboy.PostboyGenericMessage));
1004
+ SetMapCenterCommand.ID = 'd50e89c9-6707-4f8c-ab57-65fcef232182';
1005
+
925
1006
  var AddLayerCommand = /** @class */ (function (_super) {
926
1007
  __extends(AddLayerCommand, _super);
927
1008
  function AddLayerCommand(layer) {
@@ -1320,8 +1401,15 @@
1320
1401
  this.postboy = postboy;
1321
1402
  }
1322
1403
  MapStateService.prototype.up = function () {
1404
+ this.observeMapRendering();
1405
+ this.observeCenter();
1406
+ };
1407
+ MapStateService.prototype.observeMapRendering = function () {
1323
1408
  var _this = this;
1324
- this.postboy.subscribe(MapRenderedEvent.ID).subscribe(function (ev) {
1409
+ this.postboy
1410
+ .subscribe(MapRenderedEvent.ID)
1411
+ .pipe(operators.first())
1412
+ .subscribe(function (ev) {
1325
1413
  var _a;
1326
1414
  _this.map = ev.map;
1327
1415
  (_a = _this.map) === null || _a === void 0 ? void 0 : _a.on('moveend', function () {
@@ -1332,6 +1420,15 @@
1332
1420
  });
1333
1421
  });
1334
1422
  };
1423
+ MapStateService.prototype.observeCenter = function () {
1424
+ var _this = this;
1425
+ this.postboy.subscribe(SetMapCenterCommand.ID).subscribe(function (c) {
1426
+ var _a, _b;
1427
+ (_a = _this.map) === null || _a === void 0 ? void 0 : _a.getView().setCenter([c.lng, c.lat]);
1428
+ if (c.zoom)
1429
+ (_b = _this.map) === null || _b === void 0 ? void 0 : _b.getView().setZoom(c.zoom);
1430
+ });
1431
+ };
1335
1432
  return MapStateService;
1336
1433
  }());
1337
1434
  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 });
@@ -1614,16 +1711,55 @@
1614
1711
  type: i0.Injectable
1615
1712
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1616
1713
 
1714
+ var ControlsService = /** @class */ (function () {
1715
+ function ControlsService(postboy) {
1716
+ this.postboy = postboy;
1717
+ }
1718
+ ControlsService.prototype.up = function () {
1719
+ this.observeMapRender();
1720
+ };
1721
+ ControlsService.prototype.observeMapRender = function () {
1722
+ var _this = this;
1723
+ this.postboy
1724
+ .subscribe(MapRenderedEvent.ID)
1725
+ .pipe(operators.first())
1726
+ .subscribe(function (m) {
1727
+ _this.map = m.map;
1728
+ _this.observeAdding();
1729
+ _this.observeRemoving();
1730
+ });
1731
+ };
1732
+ ControlsService.prototype.observeAdding = function () {
1733
+ var _this = this;
1734
+ this.postboy.subscribe(AddControlCommand.ID).subscribe(function (c) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.addControl(c.item); });
1735
+ };
1736
+ ControlsService.prototype.observeRemoving = function () {
1737
+ var _this = this;
1738
+ this.postboy
1739
+ .subscribe(RemoveControlCommand.ID)
1740
+ .subscribe(function (c) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.removeControl(c.item); });
1741
+ };
1742
+ return ControlsService;
1743
+ }());
1744
+ ControlsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ControlsService, deps: [{ token: MapPostboyService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1745
+ ControlsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ControlsService });
1746
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ControlsService, decorators: [{
1747
+ type: i0.Injectable
1748
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1749
+
1617
1750
  var MessageRegistratorService = /** @class */ (function (_super) {
1618
1751
  __extends(MessageRegistratorService, _super);
1619
- function MessageRegistratorService(service, management, state, mapFeature, interaction, drawing, featureModification) {
1752
+ function MessageRegistratorService(service, management, state, mapFeature, interaction, drawing, featureModification, controls) {
1620
1753
  var _this = _super.call(this, service) || this;
1621
- _this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
1754
+ _this.registerServices([management, state, interaction, mapFeature, drawing, featureModification, controls]);
1622
1755
  return _this;
1623
1756
  }
1624
1757
  MessageRegistratorService.prototype._up = function () {
1625
1758
  this.registerReplay(MapRenderedEvent.ID);
1626
1759
  this.registerReplay(PlaceLayerFeaturesCommand.ID);
1760
+ this.registerReplay(RemoveControlCommand.ID);
1761
+ this.registerReplay(AddControlCommand.ID);
1762
+ this.registerReplay(SetMapCenterCommand.ID);
1627
1763
  this.registerSubject(AddLayerCommand.ID);
1628
1764
  this.registerSubject(RemoveLayerCommand.ID);
1629
1765
  this.registerSubject(AddTileCommand.ID);
@@ -1649,11 +1785,11 @@
1649
1785
  };
1650
1786
  return MessageRegistratorService;
1651
1787
  }(postboy.PostboyAbstractRegistrator));
1652
- 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: FeatureModificationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1788
+ 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: FeatureModificationService }, { token: ControlsService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1653
1789
  MessageRegistratorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService });
1654
1790
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MessageRegistratorService, decorators: [{
1655
1791
  type: i0.Injectable
1656
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
1792
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }, { type: ControlsService }]; } });
1657
1793
 
1658
1794
  var TileLayerSettings = /** @class */ (function () {
1659
1795
  function TileLayerSettings() {
@@ -2339,6 +2475,7 @@
2339
2475
  DrawingGenerationService,
2340
2476
  FeatureService,
2341
2477
  FeatureModificationService,
2478
+ ControlsService,
2342
2479
  ], usesInheritance: true, ngImport: i0__namespace, template: "<ng-content></ng-content>\r\n<art-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></art-osm-tile-layer>\r\n<art-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></art-feature-layer>\r\n", styles: ["art-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: OsmTileLayerComponent, selector: "art-osm-tile-layer", inputs: ["url", "map"] }, { type: FeatureLayerComponent, selector: "art-feature-layer", inputs: ["settings"] }], directives: [{ type: i6__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
2343
2480
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MapPlateComponent, decorators: [{
2344
2481
  type: i0.Component,
@@ -2357,6 +2494,7 @@
2357
2494
  DrawingGenerationService,
2358
2495
  FeatureService,
2359
2496
  FeatureModificationService,
2497
+ ControlsService,
2360
2498
  ],
2361
2499
  }]
2362
2500
  }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { settings: [{
@@ -2878,6 +3016,7 @@
2878
3016
  * Generated bundle index. Do not edit.
2879
3017
  */
2880
3018
 
3019
+ exports.AddControlCommand = AddControlCommand;
2881
3020
  exports.CancelDrawingCommand = CancelDrawingCommand;
2882
3021
  exports.CancelFeatureModificationCommand = CancelFeatureModificationCommand;
2883
3022
  exports.CloseTooltipCommand = CloseTooltipCommand;
@@ -2888,6 +3027,7 @@
2888
3027
  exports.FeatureLayerComponent = FeatureLayerComponent;
2889
3028
  exports.FeatureLayerSettings = FeatureLayerSettings;
2890
3029
  exports.MapClickEvent = MapClickEvent;
3030
+ exports.MapControl = MapControl;
2891
3031
  exports.MapControlZoomComponent = MapControlZoomComponent;
2892
3032
  exports.MapLyrsLabel = MapLyrsLabel;
2893
3033
  exports.MapModule = MapModule;
@@ -2905,6 +3045,8 @@
2905
3045
  exports.PolygonModel = PolygonModel;
2906
3046
  exports.PolygonStyleHelper = PolygonStyleHelper;
2907
3047
  exports.PolygonsComponent = PolygonsComponent;
3048
+ exports.RemoveControlCommand = RemoveControlCommand;
3049
+ exports.SetMapCenterCommand = SetMapCenterCommand;
2908
3050
  exports.StartDrawingCommand = StartDrawingCommand;
2909
3051
  exports.StringifyFeatureHelper = StringifyFeatureHelper;
2910
3052
  exports.TextStyleHelper = TextStyleHelper;