@artstesh/maps 4.1.23 → 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 (39) 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/map.constants.mjs +2 -1
  8. package/dist/esm2020/map/services/map-feature.service.mjs +22 -2
  9. package/dist/esm2020/map/services/message-registrator.service.mjs +7 -2
  10. package/dist/esm2020/src/map/map-plate/features/polygons/polygons.component.mjs +6 -2
  11. package/dist/esm2020/src/map/map-plate/layers/feature-layer/feature-layer.settings.mjs +13 -1
  12. package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +5 -1
  13. package/dist/esm2020/src/map/messages/events/map-feature-hovered.event.mjs +21 -0
  14. package/dist/esm2020/src/map/messages/events/map-pointer-move.event.mjs +20 -0
  15. package/dist/esm2020/src/map/messages/index.mjs +3 -1
  16. package/dist/esm2020/src/map/models/map.constants.mjs +2 -1
  17. package/dist/esm2020/src/map/services/map-feature.service.mjs +22 -2
  18. package/dist/esm2020/src/map/services/message-registrator.service.mjs +7 -2
  19. package/dist/fesm2015/maps-components-src-map.mjs +82 -5
  20. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  21. package/dist/fesm2015/maps-components.mjs +82 -5
  22. package/dist/fesm2015/maps-components.mjs.map +1 -1
  23. package/dist/fesm2020/maps-components-src-map.mjs +82 -5
  24. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  25. package/dist/fesm2020/maps-components.mjs +82 -5
  26. package/dist/fesm2020/maps-components.mjs.map +1 -1
  27. package/dist/map/map-plate/layers/feature-layer/feature-layer.settings.d.ts +22 -0
  28. package/dist/map/messages/events/map-feature-hovered.event.d.ts +19 -0
  29. package/dist/map/messages/events/map-pointer-move.event.d.ts +17 -0
  30. package/dist/map/messages/index.d.ts +2 -0
  31. package/dist/map/models/map.constants.d.ts +1 -0
  32. package/dist/map/services/map-feature.service.d.ts +1 -0
  33. package/dist/src/map/map-plate/layers/feature-layer/feature-layer.settings.d.ts +22 -0
  34. package/dist/src/map/messages/events/map-feature-hovered.event.d.ts +19 -0
  35. package/dist/src/map/messages/events/map-pointer-move.event.d.ts +17 -0
  36. package/dist/src/map/messages/index.d.ts +2 -0
  37. package/dist/src/map/models/map.constants.d.ts +1 -0
  38. package/dist/src/map/services/map-feature.service.d.ts +1 -0
  39. 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) {
@@ -519,6 +520,45 @@ class MapMoveEndEvent extends PostboyGenericMessage {
519
520
  }
520
521
  MapMoveEndEvent.ID = 'd210ec7e-032f-4ce8-8a39-7b816519eaae';
521
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
+
522
562
  /**
523
563
  * A class responsible for executing filtering of geographical features
524
564
  * based on a specific geographical point (latitude and longitude).
@@ -938,6 +978,7 @@ class MapFeatureService {
938
978
  this.observeMapRender();
939
979
  this.observeFitToFeatures();
940
980
  this.observeFitToPolygons();
981
+ this.observePointerMove();
941
982
  }
942
983
  observeMapRender() {
943
984
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -946,6 +987,22 @@ class MapFeatureService {
946
987
  this.postboy.fire(this.fitPolygonsWaiting);
947
988
  });
948
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
+ }
949
1006
  observeFitToFeatures() {
950
1007
  this.postboy.sub(FitToFeaturesCommand).subscribe((cmd) => {
951
1008
  this.fitToGeometries(cmd.features.map((f) => f.getGeometry()), cmd.zoomAfter);
@@ -1249,6 +1306,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1249
1306
  this.recordSubject(CancelDrawingCommand);
1250
1307
  this.recordSubject(StartDrawingCommand);
1251
1308
  this.recordSubject(GetLayerQuery);
1309
+ this.recordSubject(MapFeatureHoveredEvent);
1310
+ this.recordWithPipe(MapPointerMoveEvent, new Subject(), (s) => s.pipe(debounceTime(150)));
1252
1311
  this.recordSubject(DrawingFinishedEvent);
1253
1312
  this.recordSubject(GetFeaturesInAreaQuery);
1254
1313
  this.recordSubject(DrawSelectionAreaCommand);
@@ -1606,6 +1665,7 @@ class FeatureLayerSettings {
1606
1665
  result.minZoom = model.minZoom;
1607
1666
  result.zIndex = model.zIndex;
1608
1667
  result.style = model.style;
1668
+ result.featureHoverStyle = model.featureHoverStyle;
1609
1669
  return result;
1610
1670
  }
1611
1671
  /**
@@ -1654,6 +1714,15 @@ class FeatureLayerSettings {
1654
1714
  setStyle(style) {
1655
1715
  return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
1656
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
+ }
1657
1726
  /**
1658
1727
  * Checks if the given FeatureLayerSettings object is identical to the current object.
1659
1728
  *
@@ -1671,6 +1740,8 @@ class FeatureLayerSettings {
1671
1740
  return false;
1672
1741
  if (this.style !== model.style)
1673
1742
  return false;
1743
+ if (this.featureHoverStyle !== model.featureHoverStyle)
1744
+ return false;
1674
1745
  return true;
1675
1746
  }
1676
1747
  }
@@ -2071,6 +2142,9 @@ class MapPlateComponent extends DestructibleComponent {
2071
2142
  this.map.updateSize();
2072
2143
  this.postboy.fire(new MapRenderedEvent(this.map));
2073
2144
  });
2145
+ this.map.on('pointermove', (ev) => {
2146
+ this.postboy.fire(new MapPointerMoveEvent(ev.pixel));
2147
+ });
2074
2148
  this.setOsm();
2075
2149
  }
2076
2150
  setOsm() {
@@ -2285,7 +2359,10 @@ class PolygonsComponent extends DestructibleComponent {
2285
2359
  putPolygons() {
2286
2360
  if (!this._polygons)
2287
2361
  return;
2288
- 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
+ })));
2289
2366
  }
2290
2367
  }
2291
2368
  PolygonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PolygonsComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
@@ -2721,5 +2798,5 @@ class StringifyFeatureHelper {
2721
2798
  * Generated bundle index. Do not edit.
2722
2799
  */
2723
2800
 
2724
- 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 };
2801
+ 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 };
2725
2802
  //# sourceMappingURL=maps-components.mjs.map