@artstesh/maps 4.1.22 → 4.1.24

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/features/polygons/polygons.component.mjs +6 -2
  2. package/dist/esm2020/map/map-plate/layers/feature-layer/feature-layer.settings.mjs +13 -1
  3. package/dist/esm2020/map/map-plate/map-plate.component.mjs +5 -1
  4. package/dist/esm2020/map/messages/events/map-feature-hovered.event.mjs +21 -0
  5. package/dist/esm2020/map/messages/events/map-pointer-move.event.mjs +20 -0
  6. package/dist/esm2020/map/messages/index.mjs +3 -1
  7. package/dist/esm2020/map/models/feature-format.enum.mjs +2 -1
  8. package/dist/esm2020/map/models/map.constants.mjs +2 -1
  9. package/dist/esm2020/map/services/drawing/drawing.service.mjs +4 -2
  10. package/dist/esm2020/map/services/drawing/feature-modification.service.mjs +4 -2
  11. package/dist/esm2020/map/services/map-feature.service.mjs +22 -2
  12. package/dist/esm2020/map/services/message-registrator.service.mjs +7 -2
  13. package/dist/esm2020/src/map/map-plate/features/polygons/polygons.component.mjs +6 -2
  14. package/dist/esm2020/src/map/map-plate/layers/feature-layer/feature-layer.settings.mjs +13 -1
  15. package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +5 -1
  16. package/dist/esm2020/src/map/messages/events/map-feature-hovered.event.mjs +21 -0
  17. package/dist/esm2020/src/map/messages/events/map-pointer-move.event.mjs +20 -0
  18. package/dist/esm2020/src/map/messages/index.mjs +3 -1
  19. package/dist/esm2020/src/map/models/feature-format.enum.mjs +2 -1
  20. package/dist/esm2020/src/map/models/map.constants.mjs +2 -1
  21. package/dist/esm2020/src/map/services/drawing/drawing.service.mjs +4 -2
  22. package/dist/esm2020/src/map/services/drawing/feature-modification.service.mjs +4 -2
  23. package/dist/esm2020/src/map/services/map-feature.service.mjs +22 -2
  24. package/dist/esm2020/src/map/services/message-registrator.service.mjs +7 -2
  25. package/dist/fesm2015/maps-components-src-map.mjs +89 -7
  26. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  27. package/dist/fesm2015/maps-components.mjs +89 -7
  28. package/dist/fesm2015/maps-components.mjs.map +1 -1
  29. package/dist/fesm2020/maps-components-src-map.mjs +89 -7
  30. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  31. package/dist/fesm2020/maps-components.mjs +89 -7
  32. package/dist/fesm2020/maps-components.mjs.map +1 -1
  33. package/dist/map/map-plate/layers/feature-layer/feature-layer.settings.d.ts +22 -0
  34. package/dist/map/messages/events/map-feature-hovered.event.d.ts +19 -0
  35. package/dist/map/messages/events/map-pointer-move.event.d.ts +17 -0
  36. package/dist/map/messages/index.d.ts +2 -0
  37. package/dist/map/models/feature-format.enum.d.ts +2 -1
  38. package/dist/map/models/map.constants.d.ts +1 -0
  39. package/dist/map/services/map-feature.service.d.ts +1 -0
  40. package/dist/src/map/map-plate/layers/feature-layer/feature-layer.settings.d.ts +22 -0
  41. package/dist/src/map/messages/events/map-feature-hovered.event.d.ts +19 -0
  42. package/dist/src/map/messages/events/map-pointer-move.event.d.ts +17 -0
  43. package/dist/src/map/messages/index.d.ts +2 -0
  44. package/dist/src/map/models/feature-format.enum.d.ts +2 -1
  45. package/dist/src/map/models/map.constants.d.ts +1 -0
  46. package/dist/src/map/services/map-feature.service.d.ts +1 -0
  47. package/package.json +1 -1
@@ -13,15 +13,15 @@ import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, Postboy
13
13
  import { Draw, Modify, Translate, defaults } from 'ol/interaction';
14
14
  import { createRegularPolygon, createBox } from 'ol/interaction/Draw';
15
15
  import * as Sphere from 'ol/sphere';
16
+ import { Subject, combineLatest } from 'rxjs';
17
+ import { first, debounceTime, filter, auditTime } from 'rxjs/operators';
16
18
  import { Dictionary } from '@artstesh/collections';
17
- import { first, filter, auditTime } from 'rxjs/operators';
18
19
  import { Vector, XYZ } from 'ol/source';
19
20
  import TileLayer from 'ol/layer/Tile';
20
21
  import OSM from 'ol/source/OSM';
21
22
  import { Vector as Vector$1 } from 'ol/layer';
22
23
  import { bbox } from 'ol/loadingstrategy';
23
24
  import Cluster from 'ol/source/Cluster';
24
- import { combineLatest } from 'rxjs';
25
25
  import Map from 'ol/Map';
26
26
  import View from 'ol/View';
27
27
  import Overlay from 'ol/Overlay';
@@ -194,7 +194,8 @@ IdGenerator.collection = 'ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789'.split('');
194
194
  class MapConstants {
195
195
  }
196
196
  MapConstants.FeatureInfo = 'f-info';
197
- MapConstants.DrawingLayerId = '93a981756ec7';
197
+ MapConstants.DrawingLayerId = '93a981756ec7';
198
+ MapConstants.FeatureLayerName = 'L-253';
198
199
 
199
200
  class MarkerModel {
200
201
  constructor(lat, lng, id, info) {
@@ -279,6 +280,7 @@ var FeatureOutputFormat;
279
280
  (function (FeatureOutputFormat) {
280
281
  FeatureOutputFormat[FeatureOutputFormat["GeoJson"] = 1] = "GeoJson";
281
282
  FeatureOutputFormat[FeatureOutputFormat["WKT"] = 2] = "WKT";
283
+ FeatureOutputFormat[FeatureOutputFormat["Geometry"] = 3] = "Geometry";
282
284
  })(FeatureOutputFormat || (FeatureOutputFormat = {}));
283
285
 
284
286
  /**
@@ -518,6 +520,45 @@ class MapMoveEndEvent extends PostboyGenericMessage {
518
520
  }
519
521
  MapMoveEndEvent.ID = 'd210ec7e-032f-4ce8-8a39-7b816519eaae';
520
522
 
523
+ /**
524
+ * Represents an event that is triggered when the pointer moves on a map.
525
+ * This class extends PostboyGenericMessage.
526
+ *
527
+ * It contains information about the coordinates of the pointer when the event occurs.
528
+ */
529
+ class MapPointerMoveEvent extends PostboyGenericMessage {
530
+ /**
531
+ * Constructor for initializing an instance with a given point.
532
+ *
533
+ * @param {Array<number>} point - An array representing the coordinates of the point.
534
+ */
535
+ constructor(point) {
536
+ super();
537
+ this.point = point;
538
+ }
539
+ }
540
+ MapPointerMoveEvent.ID = '193cb41d-2489-45cc-b349-59c3ec18ed72';
541
+
542
+ /**
543
+ * Represents an event triggered when a map feature is hovered over.
544
+ * This event contains information about the hovered feature and its associated layer.
545
+ * Extends the PostboyGenericMessage class.
546
+ */
547
+ class MapFeatureHoveredEvent extends PostboyGenericMessage {
548
+ /**
549
+ * Constructs an instance of the class.
550
+ *
551
+ * @param {Feature|null} feature - The feature associated with this instance. Can be null.
552
+ * @param {string|null} layer - The layer associated with this instance. Can be null.
553
+ */
554
+ constructor(feature, layer) {
555
+ super();
556
+ this.feature = feature;
557
+ this.layer = layer;
558
+ }
559
+ }
560
+ MapFeatureHoveredEvent.ID = 'eb9b032a-1616-4823-a628-0fd8ffc3b57a';
561
+
521
562
  /**
522
563
  * A class responsible for executing filtering of geographical features
523
564
  * based on a specific geographical point (latitude and longitude).
@@ -937,6 +978,7 @@ class MapFeatureService {
937
978
  this.observeMapRender();
938
979
  this.observeFitToFeatures();
939
980
  this.observeFitToPolygons();
981
+ this.observePointerMove();
940
982
  }
941
983
  observeMapRender() {
942
984
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -945,6 +987,22 @@ class MapFeatureService {
945
987
  this.postboy.fire(this.fitPolygonsWaiting);
946
988
  });
947
989
  }
990
+ observePointerMove() {
991
+ this.postboy.sub(MapPointerMoveEvent).subscribe((ev) => {
992
+ if (!this.map)
993
+ return;
994
+ let featureFound = false;
995
+ this.map.forEachFeatureAtPixel(ev.point, (f) => {
996
+ if (f instanceof Feature) {
997
+ this.postboy.fire(new MapFeatureHoveredEvent(f, f.get(MapConstants.FeatureLayerName)));
998
+ featureFound = true;
999
+ }
1000
+ return true;
1001
+ });
1002
+ if (!featureFound)
1003
+ this.postboy.fire(new MapFeatureHoveredEvent(null, null));
1004
+ });
1005
+ }
948
1006
  observeFitToFeatures() {
949
1007
  this.postboy.sub(FitToFeaturesCommand).subscribe((cmd) => {
950
1008
  this.fitToGeometries(cmd.features.map((f) => f.getGeometry()), cmd.zoomAfter);
@@ -1066,7 +1124,9 @@ class DrawingService {
1066
1124
  onEnd(evt, command, layer) {
1067
1125
  command.finish(command.format === FeatureOutputFormat.GeoJson
1068
1126
  ? new GeoJSON().writeFeature(evt.feature)
1069
- : new WKT().writeFeature(evt.feature));
1127
+ : command.format === FeatureOutputFormat.WKT
1128
+ ? new WKT().writeFeature(evt.feature)
1129
+ : new GeoJSON().writeGeometry(evt.feature.getGeometry()));
1070
1130
  this.clearInteraction(layer);
1071
1131
  }
1072
1132
  observeMapRender() {
@@ -1157,7 +1217,9 @@ class FeatureModificationService {
1157
1217
  onModified(command) {
1158
1218
  command.next(command.format === FeatureOutputFormat.GeoJson
1159
1219
  ? new GeoJSON().writeFeature(command.model.feature)
1160
- : new WKT().writeFeature(command.model.feature));
1220
+ : command.format === FeatureOutputFormat.WKT
1221
+ ? new WKT().writeFeature(command.model.feature)
1222
+ : new GeoJSON().writeGeometry(command.model.feature.getGeometry()));
1161
1223
  }
1162
1224
  observeMapRender() {
1163
1225
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -1244,6 +1306,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1244
1306
  this.recordSubject(CancelDrawingCommand);
1245
1307
  this.recordSubject(StartDrawingCommand);
1246
1308
  this.recordSubject(GetLayerQuery);
1309
+ this.recordSubject(MapFeatureHoveredEvent);
1310
+ this.recordWithPipe(MapPointerMoveEvent, new Subject(), (s) => s.pipe(debounceTime(150)));
1247
1311
  this.recordSubject(DrawingFinishedEvent);
1248
1312
  this.recordSubject(GetFeaturesInAreaQuery);
1249
1313
  this.recordSubject(DrawSelectionAreaCommand);
@@ -1601,6 +1665,7 @@ class FeatureLayerSettings {
1601
1665
  result.minZoom = model.minZoom;
1602
1666
  result.zIndex = model.zIndex;
1603
1667
  result.style = model.style;
1668
+ result.featureHoverStyle = model.featureHoverStyle;
1604
1669
  return result;
1605
1670
  }
1606
1671
  /**
@@ -1649,6 +1714,15 @@ class FeatureLayerSettings {
1649
1714
  setStyle(style) {
1650
1715
  return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
1651
1716
  }
1717
+ /**
1718
+ * Sets the style to apply to features when they are hovered over.
1719
+ *
1720
+ * @param {Style | StyleFunction} featureHoverStyle - The style or style function to use for hovered features.
1721
+ * @return {FeatureLayerSettings} A new instance of FeatureLayerSettings with the updated hover style.
1722
+ */
1723
+ setFeatureHoverStyle(featureHoverStyle) {
1724
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { featureHoverStyle }));
1725
+ }
1652
1726
  /**
1653
1727
  * Checks if the given FeatureLayerSettings object is identical to the current object.
1654
1728
  *
@@ -1666,6 +1740,8 @@ class FeatureLayerSettings {
1666
1740
  return false;
1667
1741
  if (this.style !== model.style)
1668
1742
  return false;
1743
+ if (this.featureHoverStyle !== model.featureHoverStyle)
1744
+ return false;
1669
1745
  return true;
1670
1746
  }
1671
1747
  }
@@ -2066,6 +2142,9 @@ class MapPlateComponent extends DestructibleComponent {
2066
2142
  this.map.updateSize();
2067
2143
  this.postboy.fire(new MapRenderedEvent(this.map));
2068
2144
  });
2145
+ this.map.on('pointermove', (ev) => {
2146
+ this.postboy.fire(new MapPointerMoveEvent(ev.pixel));
2147
+ });
2069
2148
  this.setOsm();
2070
2149
  }
2071
2150
  setOsm() {
@@ -2280,7 +2359,10 @@ class PolygonsComponent extends DestructibleComponent {
2280
2359
  putPolygons() {
2281
2360
  if (!this._polygons)
2282
2361
  return;
2283
- this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
2362
+ this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => {
2363
+ m.feature.set(MapConstants.FeatureLayerName, this.layerName);
2364
+ return m.feature;
2365
+ })));
2284
2366
  }
2285
2367
  }
2286
2368
  PolygonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PolygonsComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
@@ -2712,5 +2794,5 @@ class StringifyFeatureHelper {
2712
2794
  * Generated bundle index. Do not edit.
2713
2795
  */
2714
2796
 
2715
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetMapPositionExecutor, MapClickEvent, MapConstants, 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 };
2797
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetMapPositionExecutor, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2716
2798
  //# sourceMappingURL=maps-components-src-map.mjs.map