@artstesh/maps 4.0.4 → 4.0.6

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 (69) hide show
  1. package/dist/esm2020/map/helpers/index.mjs +2 -1
  2. package/dist/esm2020/map/helpers/polygon-style.helper.mjs +16 -0
  3. package/dist/esm2020/map/map-plate/features/index.mjs +2 -1
  4. package/dist/esm2020/map/map-plate/features/polygons/polygons.component.mjs +41 -0
  5. package/dist/esm2020/map/map-plate/layers/feature-layer/feature-layer.component.mjs +1 -1
  6. package/dist/esm2020/map/map-plate/tooltips/index.mjs +3 -0
  7. package/dist/esm2020/map/map-plate/tooltips/tooltip/tooltip.component.mjs +76 -0
  8. package/dist/esm2020/map/map-plate/tooltips/tooltip/tooltip.settings.mjs +30 -0
  9. package/dist/esm2020/map/map.module.mjs +21 -3
  10. package/dist/esm2020/map/messages/commands/close-tooltip.command.mjs +12 -0
  11. package/dist/esm2020/map/messages/index.mjs +2 -1
  12. package/dist/esm2020/map/models/index.mjs +2 -1
  13. package/dist/esm2020/map/models/polygon.model.mjs +25 -0
  14. package/dist/esm2020/map/public-api.mjs +2 -1
  15. package/dist/esm2020/map/services/map-click.service.mjs +2 -2
  16. package/dist/esm2020/map/services/message-registrator.service.mjs +3 -1
  17. package/dist/esm2020/src/map/helpers/index.mjs +2 -1
  18. package/dist/esm2020/src/map/helpers/polygon-style.helper.mjs +16 -0
  19. package/dist/esm2020/src/map/map-plate/features/index.mjs +2 -1
  20. package/dist/esm2020/src/map/map-plate/features/polygons/polygons.component.mjs +41 -0
  21. package/dist/esm2020/src/map/map-plate/layers/feature-layer/feature-layer.component.mjs +1 -1
  22. package/dist/esm2020/src/map/map-plate/tooltips/index.mjs +3 -0
  23. package/dist/esm2020/src/map/map-plate/tooltips/tooltip/tooltip.component.mjs +76 -0
  24. package/dist/esm2020/src/map/map-plate/tooltips/tooltip/tooltip.settings.mjs +30 -0
  25. package/dist/esm2020/src/map/map.module.mjs +21 -3
  26. package/dist/esm2020/src/map/messages/commands/close-tooltip.command.mjs +12 -0
  27. package/dist/esm2020/src/map/messages/index.mjs +2 -1
  28. package/dist/esm2020/src/map/models/index.mjs +2 -1
  29. package/dist/esm2020/src/map/models/polygon.model.mjs +25 -0
  30. package/dist/esm2020/src/map/public-api.mjs +2 -1
  31. package/dist/esm2020/src/map/services/map-click.service.mjs +2 -2
  32. package/dist/esm2020/src/map/services/message-registrator.service.mjs +3 -1
  33. package/dist/fesm2015/maps-components-src-map.mjs +207 -5
  34. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  35. package/dist/fesm2015/maps-components.mjs +207 -5
  36. package/dist/fesm2015/maps-components.mjs.map +1 -1
  37. package/dist/fesm2020/maps-components-src-map.mjs +202 -5
  38. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  39. package/dist/fesm2020/maps-components.mjs +202 -5
  40. package/dist/fesm2020/maps-components.mjs.map +1 -1
  41. package/dist/map/helpers/index.d.ts +1 -0
  42. package/dist/map/helpers/polygon-style.helper.d.ts +4 -0
  43. package/dist/map/map-plate/features/index.d.ts +1 -0
  44. package/dist/map/map-plate/features/polygons/polygons.component.d.ts +16 -0
  45. package/dist/map/map-plate/layers/feature-layer/feature-layer.component.d.ts +1 -1
  46. package/dist/map/map-plate/tooltips/index.d.ts +2 -0
  47. package/dist/map/map-plate/tooltips/tooltip/tooltip.component.d.ts +26 -0
  48. package/dist/map/map-plate/tooltips/tooltip/tooltip.settings.d.ts +11 -0
  49. package/dist/map/map.module.d.ts +4 -2
  50. package/dist/map/messages/commands/close-tooltip.command.d.ts +7 -0
  51. package/dist/map/messages/index.d.ts +1 -0
  52. package/dist/map/models/index.d.ts +1 -0
  53. package/dist/map/models/polygon.model.d.ts +19 -0
  54. package/dist/map/public-api.d.ts +1 -0
  55. package/dist/src/map/helpers/index.d.ts +1 -0
  56. package/dist/src/map/helpers/polygon-style.helper.d.ts +4 -0
  57. package/dist/src/map/map-plate/features/index.d.ts +1 -0
  58. package/dist/src/map/map-plate/features/polygons/polygons.component.d.ts +16 -0
  59. package/dist/src/map/map-plate/layers/feature-layer/feature-layer.component.d.ts +1 -1
  60. package/dist/src/map/map-plate/tooltips/index.d.ts +2 -0
  61. package/dist/src/map/map-plate/tooltips/tooltip/tooltip.component.d.ts +26 -0
  62. package/dist/src/map/map-plate/tooltips/tooltip/tooltip.settings.d.ts +11 -0
  63. package/dist/src/map/map.module.d.ts +4 -2
  64. package/dist/src/map/messages/commands/close-tooltip.command.d.ts +7 -0
  65. package/dist/src/map/messages/index.d.ts +1 -0
  66. package/dist/src/map/models/index.d.ts +1 -0
  67. package/dist/src/map/models/polygon.model.d.ts +19 -0
  68. package/dist/src/map/public-api.d.ts +1 -0
  69. package/package.json +1 -1
@@ -1,9 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, Injectable, ChangeDetectionStrategy, Input, NgModule } from '@angular/core';
2
+ import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgModule } from '@angular/core';
3
3
  import * as i4 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import { Feature } from 'ol';
6
6
  import { Point } from 'ol/geom';
7
+ import { GeoJSON, WKT } from 'ol/format';
8
+ import { getCenter } from 'ol/extent';
7
9
  import { useGeographic, get } from 'ol/proj';
8
10
  import { Subject } from 'rxjs';
9
11
  import { PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
@@ -14,6 +16,7 @@ import OSM from 'ol/source/OSM';
14
16
  import { filter, first } from 'rxjs/operators';
15
17
  import { XYZ, Vector } from 'ol/source';
16
18
  import { Vector as Vector$1 } from 'ol/layer';
19
+ import Overlay from 'ol/Overlay';
17
20
  import Style from 'ol/style/Style';
18
21
  import { Icon, Circle, Fill, Stroke } from 'ol/style';
19
22
 
@@ -139,6 +142,29 @@ class MarkerModel {
139
142
  }
140
143
  }
141
144
 
145
+ class PolygonModel {
146
+ static fromGeoJson(id, json, info) {
147
+ let feature = new GeoJSON().readFeature(json);
148
+ feature.setId(id);
149
+ return new PolygonModel(feature, id, info);
150
+ }
151
+ static fromWKT(id, wkt, info) {
152
+ let feature = new WKT().readFeature(wkt);
153
+ feature.setId(id);
154
+ return new PolygonModel(feature, id, info);
155
+ }
156
+ constructor(feature, id, info) {
157
+ var _a;
158
+ this.info = info;
159
+ this.id = id == null ? IdGenerator.get() : id;
160
+ this._feature = feature;
161
+ [this.lng, this.lat] = getCenter((_a = this._feature.getGeometry()) === null || _a === void 0 ? void 0 : _a.getExtent());
162
+ }
163
+ get feature() {
164
+ return this._feature;
165
+ }
166
+ }
167
+
142
168
  class GenericMessage {
143
169
  }
144
170
  class CallbackMessage extends GenericMessage {
@@ -176,6 +202,17 @@ class MapClickEvent extends GenericMessage {
176
202
  }
177
203
  MapClickEvent.ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
178
204
 
205
+ class CloseTooltipCommand extends GenericMessage {
206
+ constructor(tooltipId) {
207
+ super();
208
+ this.tooltipId = tooltipId;
209
+ }
210
+ get id() {
211
+ return CloseTooltipCommand.ID;
212
+ }
213
+ }
214
+ CloseTooltipCommand.ID = '4896d52c-e34f-4994-bcfd-32832d12dbe4';
215
+
179
216
  class AddLayerCommand extends GenericMessage {
180
217
  constructor(layer) {
181
218
  super();
@@ -343,7 +380,7 @@ class MapClickService {
343
380
  const model = new MapClickEvent(ev.coordinate, {});
344
381
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.forEachFeatureAtPixel(ev.pixel, (f, l) => {
345
382
  this.getFeatureCollectionWithInner([f])
346
- .filter((f) => !!f.getId())
383
+ .filter((f) => f.getId() != null)
347
384
  .forEach((fs) => {
348
385
  let layerName = l.get('name');
349
386
  if (!model.entities[layerName])
@@ -381,6 +418,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
381
418
  this.registerSubject(AddTileCommand.ID);
382
419
  this.registerSubject(RemoveTileCommand.ID);
383
420
  this.registerSubject(MapClickEvent.ID);
421
+ this.registerSubject(CloseTooltipCommand.ID);
384
422
  }
385
423
  }
386
424
  MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -788,6 +826,140 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
788
826
  type: Input
789
827
  }] } });
790
828
 
829
+ class TooltipSettings {
830
+ constructor(id) {
831
+ this.containerClass = 'custom-tooltip-class';
832
+ this.show = (e) => true;
833
+ this.id = id !== null && id !== void 0 ? id : IdGenerator.get();
834
+ }
835
+ static copy(model) {
836
+ const result = new TooltipSettings(model.id);
837
+ result.show = model.show;
838
+ result.containerClass = model.containerClass;
839
+ return result;
840
+ }
841
+ setShow(show) {
842
+ return TooltipSettings.copy(Object.assign(Object.assign({}, this), { show }));
843
+ }
844
+ setClass(containerClass) {
845
+ return TooltipSettings.copy(Object.assign(Object.assign({}, this), { containerClass }));
846
+ }
847
+ isSame(model) {
848
+ if (this.show !== model.show)
849
+ return false;
850
+ if (this.containerClass !== model.containerClass)
851
+ return false;
852
+ if (this.id !== model.id)
853
+ return false;
854
+ return true;
855
+ }
856
+ }
857
+
858
+ class TooltipComponent extends DestructibleComponent {
859
+ set settings(value) {
860
+ if (!value || this._settings.isSame(value))
861
+ return;
862
+ this._settings = value;
863
+ this.detector.detectChanges();
864
+ }
865
+ constructor(postboy, detector) {
866
+ super();
867
+ this.postboy = postboy;
868
+ this.detector = detector;
869
+ this._settings = new TooltipSettings();
870
+ this.show = false;
871
+ this.removeOverlay = () => {
872
+ var _a;
873
+ !!this.overlay && ((_a = this.map) === null || _a === void 0 ? void 0 : _a.removeOverlay(this.overlay));
874
+ this.show = false;
875
+ };
876
+ this.options = (coordinates) => {
877
+ var _a;
878
+ return {
879
+ element: (_a = this.container) === null || _a === void 0 ? void 0 : _a.nativeElement,
880
+ autoPan: false,
881
+ autoPanAnimation: { duration: 0 },
882
+ position: coordinates,
883
+ };
884
+ };
885
+ }
886
+ ngOnInit() {
887
+ this.subs.push(this.observeMapRender());
888
+ this.subs.push(this.observeMapClick());
889
+ this.subs.push(this.observeClose());
890
+ }
891
+ observeMapClick() {
892
+ return this.postboy.subscribe(MapClickEvent.ID).subscribe((ev) => {
893
+ this._settings.show(ev) ? this.addOverlay(ev.coordinates) : this.removeOverlay();
894
+ });
895
+ }
896
+ observeClose() {
897
+ return this.postboy
898
+ .subscribe(CloseTooltipCommand.ID)
899
+ .pipe(filter((ev) => ev.tooltipId === this._settings.id))
900
+ .subscribe(() => this.removeOverlay());
901
+ }
902
+ observeMapRender() {
903
+ return this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
904
+ this.map = m.map;
905
+ });
906
+ }
907
+ addOverlay(coordinates) {
908
+ var _a;
909
+ this.removeOverlay();
910
+ this.overlay = new Overlay(this.options(coordinates));
911
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addOverlay(this.overlay);
912
+ this.show = true;
913
+ this.detector.detectChanges();
914
+ }
915
+ }
916
+ TooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TooltipComponent, deps: [{ token: MapPostboyService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
917
+ TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TooltipComponent, selector: "lib-tooltip", inputs: { settings: "settings" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["tip"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div #tip [class]=\"['tooltip-wrapper', _settings.containerClass]\" [hidden]=\"!show\">\r\n <ng-content></ng-content>\r\n</div>\r\n", styles: [".tooltip-wrapper{position:absolute}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
918
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TooltipComponent, decorators: [{
919
+ type: Component,
920
+ args: [{ selector: 'lib-tooltip', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div #tip [class]=\"['tooltip-wrapper', _settings.containerClass]\" [hidden]=\"!show\">\r\n <ng-content></ng-content>\r\n</div>\r\n", styles: [".tooltip-wrapper{position:absolute}\n"] }]
921
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { container: [{
922
+ type: ViewChild,
923
+ args: ['tip']
924
+ }], settings: [{
925
+ type: Input
926
+ }] } });
927
+
928
+ class PolygonsComponent extends DestructibleComponent {
929
+ constructor(postboy) {
930
+ super();
931
+ this.postboy = postboy;
932
+ this.layerName = '';
933
+ this._polygons = [];
934
+ }
935
+ set polygons(value) {
936
+ this._polygons = value;
937
+ this.putPolygons();
938
+ }
939
+ ngOnInit() {
940
+ this.postboy
941
+ .subscribe(MapRenderedEvent.ID)
942
+ .pipe(filter((m) => !!m), first())
943
+ .subscribe(() => this.putPolygons());
944
+ }
945
+ putPolygons() {
946
+ var _a;
947
+ if (!((_a = this._polygons) === null || _a === void 0 ? void 0 : _a.length))
948
+ return;
949
+ this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
950
+ }
951
+ }
952
+ PolygonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PolygonsComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
953
+ PolygonsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: PolygonsComponent, selector: "lib-polygons", inputs: { layerName: "layerName", polygons: "polygons" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
954
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PolygonsComponent, decorators: [{
955
+ type: Component,
956
+ args: [{ selector: 'lib-polygons', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
957
+ }], ctorParameters: function () { return [{ type: MapPostboyService }]; }, propDecorators: { layerName: [{
958
+ type: Input
959
+ }], polygons: [{
960
+ type: Input
961
+ }] } });
962
+
791
963
  class MapModule {
792
964
  }
793
965
  MapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -796,7 +968,14 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
796
968
  TileLayerComponent,
797
969
  OsmTileLayerComponent,
798
970
  FeatureLayerComponent,
799
- MarkersComponent], imports: [CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent] });
971
+ MarkersComponent,
972
+ TooltipComponent,
973
+ PolygonsComponent], imports: [CommonModule], exports: [MapPlateComponent,
974
+ FeatureLayerComponent,
975
+ MarkersComponent,
976
+ TileLayerComponent,
977
+ TooltipComponent,
978
+ PolygonsComponent] });
800
979
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
801
980
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
802
981
  type: NgModule,
@@ -809,8 +988,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
809
988
  OsmTileLayerComponent,
810
989
  FeatureLayerComponent,
811
990
  MarkersComponent,
991
+ TooltipComponent,
992
+ PolygonsComponent,
993
+ ],
994
+ exports: [
995
+ MapPlateComponent,
996
+ FeatureLayerComponent,
997
+ MarkersComponent,
998
+ TileLayerComponent,
999
+ TooltipComponent,
1000
+ PolygonsComponent,
812
1001
  ],
813
- exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent],
814
1002
  }]
815
1003
  }] });
816
1004
 
@@ -837,6 +1025,20 @@ class MarkerStyleHelper {
837
1025
  }
838
1026
  }
839
1027
 
1028
+ class PolygonStyleHelper {
1029
+ static simple(fill, stroke, strokeWidth = 1) {
1030
+ return new Style({
1031
+ fill: new Fill({
1032
+ color: fill,
1033
+ }),
1034
+ stroke: new Stroke({
1035
+ color: stroke,
1036
+ width: strokeWidth,
1037
+ }),
1038
+ });
1039
+ }
1040
+ }
1041
+
840
1042
  /*
841
1043
  * Public API Surface of maps
842
1044
  */
@@ -849,5 +1051,5 @@ class MarkerStyleHelper {
849
1051
  * Generated bundle index. Do not edit.
850
1052
  */
851
1053
 
852
- export { CallbackMessage, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings };
1054
+ export { CallbackMessage, CloseTooltipCommand, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
853
1055
  //# sourceMappingURL=maps-components.mjs.map