@artstesh/maps 4.1.2 → 4.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/esm2020/map/map-plate/map-plate.component.mjs +4 -1
  2. package/dist/esm2020/map/messages/commands/add-control.command.mjs +12 -0
  3. package/dist/esm2020/map/messages/commands/remove-control.command.mjs +12 -0
  4. package/dist/esm2020/map/messages/commands/set-map-center.command.mjs +23 -0
  5. package/dist/esm2020/map/messages/index.mjs +4 -1
  6. package/dist/esm2020/map/models/index.mjs +2 -1
  7. package/dist/esm2020/map/models/map-control.mjs +15 -0
  8. package/dist/esm2020/map/services/controls/controls.service.mjs +37 -0
  9. package/dist/esm2020/map/services/map-state.service.mjs +19 -4
  10. package/dist/esm2020/map/services/message-registrator.service.mjs +12 -5
  11. package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +4 -1
  12. package/dist/esm2020/src/map/messages/commands/add-control.command.mjs +12 -0
  13. package/dist/esm2020/src/map/messages/commands/remove-control.command.mjs +12 -0
  14. package/dist/esm2020/src/map/messages/commands/set-map-center.command.mjs +23 -0
  15. package/dist/esm2020/src/map/messages/index.mjs +4 -1
  16. package/dist/esm2020/src/map/models/index.mjs +2 -1
  17. package/dist/esm2020/src/map/models/map-control.mjs +15 -0
  18. package/dist/esm2020/src/map/services/controls/controls.service.mjs +37 -0
  19. package/dist/esm2020/src/map/services/map-state.service.mjs +19 -4
  20. package/dist/esm2020/src/map/services/message-registrator.service.mjs +12 -5
  21. package/dist/fesm2015/maps-components-src-map.mjs +117 -7
  22. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  23. package/dist/fesm2015/maps-components.mjs +117 -7
  24. package/dist/fesm2015/maps-components.mjs.map +1 -1
  25. package/dist/fesm2020/maps-components-src-map.mjs +116 -7
  26. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  27. package/dist/fesm2020/maps-components.mjs +116 -7
  28. package/dist/fesm2020/maps-components.mjs.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
@@ -6,11 +6,11 @@ import { Feature, Collection } from 'ol';
6
6
  import { Point, LineString } from 'ol/geom';
7
7
  import { GeoJSON, WKT } from 'ol/format';
8
8
  import { getCenter, createEmpty, extend } from 'ol/extent';
9
+ import { Control, Zoom } from 'ol/control';
9
10
  import { get, useGeographic, transform } from 'ol/proj';
10
11
  import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
11
12
  import { Draw, Modify, Translate } from 'ol/interaction';
12
13
  import { createRegularPolygon, createBox } from 'ol/interaction/Draw';
13
- import { Zoom } from 'ol/control';
14
14
  import { first, filter, auditTime } from 'rxjs/operators';
15
15
  import { Vector, XYZ } from 'ol/source';
16
16
  import TileLayer from 'ol/layer/Tile';
@@ -247,6 +247,20 @@ class Dictionary {
247
247
  }
248
248
  }
249
249
 
250
+ /**
251
+ *
252
+ * 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.
253
+ * This is the base class for controls. You can use it for simple custom controls by creating the element with listeners, creating an instance:
254
+ * var myControl = new Control({element: myElement}); and then adding this to the map.
255
+ * 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.
256
+ * You can also extend this base for your own control class. See examples/custom-controls for an example of how to do this.
257
+ */
258
+ class MapControl extends Control {
259
+ constructor(options) {
260
+ super(options);
261
+ }
262
+ }
263
+
250
264
  class MapRenderedEvent extends PostboyGenericMessage {
251
265
  constructor(map) {
252
266
  super();
@@ -347,6 +361,50 @@ class CancelFeatureModificationCommand extends PostboyGenericMessage {
347
361
  }
348
362
  CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
349
363
 
364
+ class AddControlCommand extends PostboyGenericMessage {
365
+ constructor(item) {
366
+ super();
367
+ this.item = item;
368
+ }
369
+ get id() {
370
+ return AddControlCommand.ID;
371
+ }
372
+ }
373
+ AddControlCommand.ID = '8e1c06eb-b395-4fe1-929c-ebf0805eeb49';
374
+
375
+ class RemoveControlCommand extends PostboyGenericMessage {
376
+ constructor(item) {
377
+ super();
378
+ this.item = item;
379
+ }
380
+ get id() {
381
+ return RemoveControlCommand.ID;
382
+ }
383
+ }
384
+ RemoveControlCommand.ID = '361641e0-804a-4930-8c27-0cea6330dbfc';
385
+
386
+ /**
387
+ * Forces map to move to a specific point
388
+ */
389
+ class SetMapCenterCommand extends PostboyGenericMessage {
390
+ /**
391
+ *
392
+ * @param lat - the desired latitude
393
+ * @param lng - the desired longitude
394
+ * @param zoom - the desired zoom; doesn't change zoom if undefined
395
+ */
396
+ constructor(lat, lng, zoom) {
397
+ super();
398
+ this.lat = lat;
399
+ this.lng = lng;
400
+ this.zoom = zoom;
401
+ }
402
+ get id() {
403
+ return SetMapCenterCommand.ID;
404
+ }
405
+ }
406
+ SetMapCenterCommand.ID = 'd50e89c9-6707-4f8c-ab57-65fcef232182';
407
+
350
408
  class AddLayerCommand extends PostboyGenericMessage {
351
409
  constructor(layer) {
352
410
  super();
@@ -640,7 +698,14 @@ class MapStateService {
640
698
  this.postboy = postboy;
641
699
  }
642
700
  up() {
643
- this.postboy.subscribe(MapRenderedEvent.ID).subscribe((ev) => {
701
+ this.observeMapRendering();
702
+ this.observeCenter();
703
+ }
704
+ observeMapRendering() {
705
+ this.postboy
706
+ .subscribe(MapRenderedEvent.ID)
707
+ .pipe(first())
708
+ .subscribe((ev) => {
644
709
  var _a;
645
710
  this.map = ev.map;
646
711
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.on('moveend', () => {
@@ -651,6 +716,14 @@ class MapStateService {
651
716
  });
652
717
  });
653
718
  }
719
+ observeCenter() {
720
+ this.postboy.subscribe(SetMapCenterCommand.ID).subscribe((c) => {
721
+ var _a, _b;
722
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.getView().setCenter([c.lng, c.lat]);
723
+ if (c.zoom)
724
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.getView().setZoom(c.zoom);
725
+ });
726
+ }
654
727
  }
655
728
  MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
656
729
  MapStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService });
@@ -914,14 +987,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
914
987
  type: Injectable
915
988
  }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
916
989
 
990
+ class ControlsService {
991
+ constructor(postboy) {
992
+ this.postboy = postboy;
993
+ }
994
+ up() {
995
+ this.observeMapRender();
996
+ }
997
+ observeMapRender() {
998
+ this.postboy
999
+ .subscribe(MapRenderedEvent.ID)
1000
+ .pipe(first())
1001
+ .subscribe((m) => {
1002
+ this.map = m.map;
1003
+ this.observeAdding();
1004
+ this.observeRemoving();
1005
+ });
1006
+ }
1007
+ observeAdding() {
1008
+ this.postboy.subscribe(AddControlCommand.ID).subscribe((c) => { var _a; return (_a = this.map) === null || _a === void 0 ? void 0 : _a.addControl(c.item); });
1009
+ }
1010
+ observeRemoving() {
1011
+ this.postboy
1012
+ .subscribe(RemoveControlCommand.ID)
1013
+ .subscribe((c) => { var _a; return (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeControl(c.item); });
1014
+ }
1015
+ }
1016
+ ControlsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
1017
+ ControlsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService });
1018
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService, decorators: [{
1019
+ type: Injectable
1020
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
1021
+
917
1022
  class MessageRegistratorService extends PostboyAbstractRegistrator {
918
- constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
1023
+ constructor(service, management, state, mapFeature, interaction, drawing, featureModification, controls) {
919
1024
  super(service);
920
- this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
1025
+ this.registerServices([management, state, interaction, mapFeature, drawing, featureModification, controls]);
921
1026
  }
922
1027
  _up() {
923
1028
  this.registerReplay(MapRenderedEvent.ID);
924
1029
  this.registerReplay(PlaceLayerFeaturesCommand.ID);
1030
+ this.registerReplay(RemoveControlCommand.ID);
1031
+ this.registerReplay(AddControlCommand.ID);
1032
+ this.registerReplay(SetMapCenterCommand.ID);
925
1033
  this.registerSubject(AddLayerCommand.ID);
926
1034
  this.registerSubject(RemoveLayerCommand.ID);
927
1035
  this.registerSubject(AddTileCommand.ID);
@@ -946,11 +1054,11 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
946
1054
  this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
947
1055
  }
948
1056
  }
949
- MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: FeatureModificationService }], target: i0.ɵɵFactoryTarget.Injectable });
1057
+ MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: FeatureModificationService }, { token: ControlsService }], target: i0.ɵɵFactoryTarget.Injectable });
950
1058
  MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
951
1059
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
952
1060
  type: Injectable
953
- }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
1061
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }, { type: ControlsService }]; } });
954
1062
 
955
1063
  class TileLayerSettings {
956
1064
  constructor() {
@@ -1553,6 +1661,7 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
1553
1661
  DrawingGenerationService,
1554
1662
  FeatureService,
1555
1663
  FeatureModificationService,
1664
+ ControlsService,
1556
1665
  ], usesInheritance: true, ngImport: i0, 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"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "art-osm-tile-layer", inputs: ["url", "map"] }, { kind: "component", type: FeatureLayerComponent, selector: "art-feature-layer", inputs: ["settings"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1557
1666
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
1558
1667
  type: Component,
@@ -1566,6 +1675,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1566
1675
  DrawingGenerationService,
1567
1676
  FeatureService,
1568
1677
  FeatureModificationService,
1678
+ ControlsService,
1569
1679
  ], 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"] }]
1570
1680
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
1571
1681
  type: Input
@@ -2010,5 +2120,5 @@ class StringifyFeatureHelper {
2010
2120
  * Generated bundle index. Do not edit.
2011
2121
  */
2012
2122
 
2013
- export { CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2123
+ export { AddControlCommand, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapControl, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2014
2124
  //# sourceMappingURL=maps-components.mjs.map