@artstesh/maps 6.1.1 → 6.1.2

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 (33) hide show
  1. package/dist/esm2022/map/map-plate/layers/feature-layer/feature-layer.settings.mjs +28 -1
  2. package/dist/esm2022/map/map-plate/map-plate.component.mjs +5 -1
  3. package/dist/esm2022/map/messages/events/map-feature-hovered.event.mjs +23 -0
  4. package/dist/esm2022/map/messages/events/map-pointer-move.event.mjs +21 -0
  5. package/dist/esm2022/map/messages/index.mjs +3 -1
  6. package/dist/esm2022/map/models/map.constants.mjs +2 -1
  7. package/dist/esm2022/map/services/map-feature.service.mjs +22 -2
  8. package/dist/esm2022/map/services/message-registrator.service.mjs +7 -2
  9. package/dist/esm2022/src/map/map-plate/layers/feature-layer/feature-layer.settings.mjs +28 -1
  10. package/dist/esm2022/src/map/map-plate/map-plate.component.mjs +5 -1
  11. package/dist/esm2022/src/map/messages/events/map-feature-hovered.event.mjs +23 -0
  12. package/dist/esm2022/src/map/messages/events/map-pointer-move.event.mjs +21 -0
  13. package/dist/esm2022/src/map/messages/index.mjs +3 -1
  14. package/dist/esm2022/src/map/models/map.constants.mjs +2 -1
  15. package/dist/esm2022/src/map/services/map-feature.service.mjs +22 -2
  16. package/dist/esm2022/src/map/services/message-registrator.service.mjs +7 -2
  17. package/dist/fesm2022/maps-components-src-map.mjs +95 -3
  18. package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
  19. package/dist/fesm2022/maps-components.mjs +95 -3
  20. package/dist/fesm2022/maps-components.mjs.map +1 -1
  21. package/dist/map/map-plate/layers/feature-layer/feature-layer.settings.d.ts +22 -0
  22. package/dist/map/messages/events/map-feature-hovered.event.d.ts +19 -0
  23. package/dist/map/messages/events/map-pointer-move.event.d.ts +17 -0
  24. package/dist/map/messages/index.d.ts +2 -0
  25. package/dist/map/models/map.constants.d.ts +1 -0
  26. package/dist/map/services/map-feature.service.d.ts +1 -0
  27. package/dist/src/map/map-plate/layers/feature-layer/feature-layer.settings.d.ts +22 -0
  28. package/dist/src/map/messages/events/map-feature-hovered.event.d.ts +19 -0
  29. package/dist/src/map/messages/events/map-pointer-move.event.d.ts +17 -0
  30. package/dist/src/map/messages/index.d.ts +2 -0
  31. package/dist/src/map/models/map.constants.d.ts +1 -0
  32. package/dist/src/map/services/map-feature.service.d.ts +1 -0
  33. 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';
@@ -191,6 +191,7 @@ class IdGenerator {
191
191
  class MapConstants {
192
192
  static FeatureInfo = 'f-info';
193
193
  static DrawingLayerId = '93a981756ec7';
194
+ static FeatureLayerName = 'L-253';
194
195
  }
195
196
 
196
197
  class MarkerModel {
@@ -547,6 +548,48 @@ class MapMoveEndEvent extends PostboyGenericMessage {
547
548
  }
548
549
  }
549
550
 
551
+ /**
552
+ * Represents an event that is triggered when the pointer moves on a map.
553
+ * This class extends PostboyGenericMessage.
554
+ *
555
+ * It contains information about the coordinates of the pointer when the event occurs.
556
+ */
557
+ class MapPointerMoveEvent extends PostboyGenericMessage {
558
+ point;
559
+ static ID = '193cb41d-2489-45cc-b349-59c3ec18ed72';
560
+ /**
561
+ * Constructor for initializing an instance with a given point.
562
+ *
563
+ * @param {Array<number>} point - An array representing the coordinates of the point.
564
+ */
565
+ constructor(point) {
566
+ super();
567
+ this.point = point;
568
+ }
569
+ }
570
+
571
+ /**
572
+ * Represents an event triggered when a map feature is hovered over.
573
+ * This event contains information about the hovered feature and its associated layer.
574
+ * Extends the PostboyGenericMessage class.
575
+ */
576
+ class MapFeatureHoveredEvent extends PostboyGenericMessage {
577
+ feature;
578
+ layer;
579
+ static ID = 'eb9b032a-1616-4823-a628-0fd8ffc3b57a';
580
+ /**
581
+ * Constructs an instance of the class.
582
+ *
583
+ * @param {Feature|null} feature - The feature associated with this instance. Can be null.
584
+ * @param {string|null} layer - The layer associated with this instance. Can be null.
585
+ */
586
+ constructor(feature, layer) {
587
+ super();
588
+ this.feature = feature;
589
+ this.layer = layer;
590
+ }
591
+ }
592
+
550
593
  /**
551
594
  * A class responsible for executing filtering of geographical features
552
595
  * based on a specific geographical point (latitude and longitude).
@@ -987,6 +1030,7 @@ class MapFeatureService {
987
1030
  this.observeMapRender();
988
1031
  this.observeFitToFeatures();
989
1032
  this.observeFitToPolygons();
1033
+ this.observePointerMove();
990
1034
  }
991
1035
  observeMapRender() {
992
1036
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -995,6 +1039,22 @@ class MapFeatureService {
995
1039
  this.postboy.fire(this.fitPolygonsWaiting);
996
1040
  });
997
1041
  }
1042
+ observePointerMove() {
1043
+ this.postboy.sub(MapPointerMoveEvent).subscribe((ev) => {
1044
+ if (!this.map)
1045
+ return;
1046
+ let featureFound = false;
1047
+ this.map.forEachFeatureAtPixel(ev.point, (f) => {
1048
+ if (f instanceof Feature) {
1049
+ this.postboy.fire(new MapFeatureHoveredEvent(f, f.get(MapConstants.FeatureLayerName)));
1050
+ featureFound = true;
1051
+ }
1052
+ return true;
1053
+ });
1054
+ if (!featureFound)
1055
+ this.postboy.fire(new MapFeatureHoveredEvent(null, null));
1056
+ });
1057
+ }
998
1058
  observeFitToFeatures() {
999
1059
  this.postboy.sub(FitToFeaturesCommand).subscribe((cmd) => {
1000
1060
  this.fitToGeometries(cmd.features.map((f) => f.getGeometry()), cmd.zoomAfter);
@@ -1303,6 +1363,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1303
1363
  this.recordSubject(CancelDrawingCommand);
1304
1364
  this.recordSubject(StartDrawingCommand);
1305
1365
  this.recordSubject(GetLayerQuery);
1366
+ this.recordSubject(MapFeatureHoveredEvent);
1367
+ this.recordWithPipe(MapPointerMoveEvent, new Subject(), (s) => s.pipe(debounceTime(150)));
1306
1368
  this.recordSubject(DrawingFinishedEvent);
1307
1369
  this.recordSubject(GetFeaturesInAreaQuery);
1308
1370
  this.recordSubject(DrawSelectionAreaCommand);
@@ -1651,6 +1713,21 @@ class FeatureLayerSettings {
1651
1713
  * The styling definition of layer's features. The easiest way is to use {@link PolygonStyleHelper},{@link MarkerStyleHelper}
1652
1714
  */
1653
1715
  style;
1716
+ /**
1717
+ * Defines the style applied to a feature when it is hovered over.
1718
+ *
1719
+ * This property can accept either a static style object or a dynamic style function.
1720
+ * When a `StyleFunction` is provided, it will determine the style dynamically
1721
+ * based on the feature being hovered.
1722
+ *
1723
+ * The style is applied temporarily, specifically for the hovered feature,
1724
+ * and overrides any default or predefined styles for that feature.
1725
+ *
1726
+ * Optional property.
1727
+ *
1728
+ * @type {(Style | StyleFunction)}
1729
+ */
1730
+ featureHoverStyle;
1654
1731
  /**
1655
1732
  * Copies the given FeatureLayerSettings object
1656
1733
  *
@@ -1664,6 +1741,7 @@ class FeatureLayerSettings {
1664
1741
  result.minZoom = model.minZoom;
1665
1742
  result.zIndex = model.zIndex;
1666
1743
  result.style = model.style;
1744
+ result.featureHoverStyle = model.featureHoverStyle;
1667
1745
  return result;
1668
1746
  }
1669
1747
  /**
@@ -1712,6 +1790,15 @@ class FeatureLayerSettings {
1712
1790
  setStyle(style) {
1713
1791
  return FeatureLayerSettings.copy({ ...this, style });
1714
1792
  }
1793
+ /**
1794
+ * Sets the style to apply to features when they are hovered over.
1795
+ *
1796
+ * @param {Style | StyleFunction} featureHoverStyle - The style or style function to use for hovered features.
1797
+ * @return {FeatureLayerSettings} A new instance of FeatureLayerSettings with the updated hover style.
1798
+ */
1799
+ setFeatureHoverStyle(featureHoverStyle) {
1800
+ return FeatureLayerSettings.copy({ ...this, featureHoverStyle });
1801
+ }
1715
1802
  /**
1716
1803
  * Checks if the given FeatureLayerSettings object is identical to the current object.
1717
1804
  *
@@ -1729,6 +1816,8 @@ class FeatureLayerSettings {
1729
1816
  return false;
1730
1817
  if (this.style !== model.style)
1731
1818
  return false;
1819
+ if (this.featureHoverStyle !== model.featureHoverStyle)
1820
+ return false;
1732
1821
  return true;
1733
1822
  }
1734
1823
  }
@@ -2134,6 +2223,9 @@ class MapPlateComponent extends DestructibleComponent {
2134
2223
  this.map.updateSize();
2135
2224
  this.postboy.fire(new MapRenderedEvent(this.map));
2136
2225
  });
2226
+ this.map.on('pointermove', (ev) => {
2227
+ this.postboy.fire(new MapPointerMoveEvent(ev.pixel));
2228
+ });
2137
2229
  this.setOsm();
2138
2230
  }
2139
2231
  onDestroy = () => {
@@ -2793,5 +2885,5 @@ class StringifyFeatureHelper {
2793
2885
  * Generated bundle index. Do not edit.
2794
2886
  */
2795
2887
 
2796
- 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 };
2888
+ 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 };
2797
2889
  //# sourceMappingURL=maps-components.mjs.map