@artstesh/maps 1.1.21 → 1.1.23

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/bundles/maps-components-src-map.umd.js +100 -8
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +100 -8
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/map-plate/features/polygons/polygons.component.js +6 -2
  6. package/dist/esm2015/map/map-plate/layers/feature-layer/feature-layer.settings.js +13 -1
  7. package/dist/esm2015/map/map-plate/map-plate.component.js +5 -1
  8. package/dist/esm2015/map/messages/events/map-feature-hovered.event.js +21 -0
  9. package/dist/esm2015/map/messages/events/map-pointer-move.event.js +20 -0
  10. package/dist/esm2015/map/messages/index.js +3 -1
  11. package/dist/esm2015/map/models/feature-format.enum.js +2 -1
  12. package/dist/esm2015/map/models/map.constants.js +2 -1
  13. package/dist/esm2015/map/services/drawing/drawing.service.js +4 -2
  14. package/dist/esm2015/map/services/drawing/feature-modification.service.js +4 -2
  15. package/dist/esm2015/map/services/map-feature.service.js +22 -2
  16. package/dist/esm2015/map/services/message-registrator.service.js +7 -2
  17. package/dist/esm2015/src/map/map-plate/features/polygons/polygons.component.js +6 -2
  18. package/dist/esm2015/src/map/map-plate/layers/feature-layer/feature-layer.settings.js +13 -1
  19. package/dist/esm2015/src/map/map-plate/map-plate.component.js +5 -1
  20. package/dist/esm2015/src/map/messages/events/map-feature-hovered.event.js +21 -0
  21. package/dist/esm2015/src/map/messages/events/map-pointer-move.event.js +20 -0
  22. package/dist/esm2015/src/map/messages/index.js +3 -1
  23. package/dist/esm2015/src/map/models/feature-format.enum.js +2 -1
  24. package/dist/esm2015/src/map/models/map.constants.js +2 -1
  25. package/dist/esm2015/src/map/services/drawing/drawing.service.js +4 -2
  26. package/dist/esm2015/src/map/services/drawing/feature-modification.service.js +4 -2
  27. package/dist/esm2015/src/map/services/map-feature.service.js +22 -2
  28. package/dist/esm2015/src/map/services/message-registrator.service.js +7 -2
  29. package/dist/fesm2015/maps-components-src-map.js +89 -7
  30. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  31. package/dist/fesm2015/maps-components.js +89 -7
  32. package/dist/fesm2015/maps-components.js.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).
@@ -938,6 +979,7 @@ class MapFeatureService {
938
979
  this.observeMapRender();
939
980
  this.observeFitToFeatures();
940
981
  this.observeFitToPolygons();
982
+ this.observePointerMove();
941
983
  }
942
984
  observeMapRender() {
943
985
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -946,6 +988,22 @@ class MapFeatureService {
946
988
  this.postboy.fire(this.fitPolygonsWaiting);
947
989
  });
948
990
  }
991
+ observePointerMove() {
992
+ this.postboy.sub(MapPointerMoveEvent).subscribe((ev) => {
993
+ if (!this.map)
994
+ return;
995
+ let featureFound = false;
996
+ this.map.forEachFeatureAtPixel(ev.point, (f) => {
997
+ if (f instanceof Feature) {
998
+ this.postboy.fire(new MapFeatureHoveredEvent(f, f.get(MapConstants.FeatureLayerName)));
999
+ featureFound = true;
1000
+ }
1001
+ return true;
1002
+ });
1003
+ if (!featureFound)
1004
+ this.postboy.fire(new MapFeatureHoveredEvent(null, null));
1005
+ });
1006
+ }
949
1007
  observeFitToFeatures() {
950
1008
  this.postboy.sub(FitToFeaturesCommand).subscribe((cmd) => {
951
1009
  this.fitToGeometries(cmd.features.map((f) => f.getGeometry()), cmd.zoomAfter);
@@ -1067,7 +1125,9 @@ class DrawingService {
1067
1125
  onEnd(evt, command, layer) {
1068
1126
  command.finish(command.format === FeatureOutputFormat.GeoJson
1069
1127
  ? new GeoJSON().writeFeature(evt.feature)
1070
- : new WKT().writeFeature(evt.feature));
1128
+ : command.format === FeatureOutputFormat.WKT
1129
+ ? new WKT().writeFeature(evt.feature)
1130
+ : new GeoJSON().writeGeometry(evt.feature.getGeometry()));
1071
1131
  this.clearInteraction(layer);
1072
1132
  }
1073
1133
  observeMapRender() {
@@ -1158,7 +1218,9 @@ class FeatureModificationService {
1158
1218
  onModified(command) {
1159
1219
  command.next(command.format === FeatureOutputFormat.GeoJson
1160
1220
  ? new GeoJSON().writeFeature(command.model.feature)
1161
- : new WKT().writeFeature(command.model.feature));
1221
+ : command.format === FeatureOutputFormat.WKT
1222
+ ? new WKT().writeFeature(command.model.feature)
1223
+ : new GeoJSON().writeGeometry(command.model.feature.getGeometry()));
1162
1224
  }
1163
1225
  observeMapRender() {
1164
1226
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -1245,6 +1307,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1245
1307
  this.recordSubject(CancelDrawingCommand);
1246
1308
  this.recordSubject(StartDrawingCommand);
1247
1309
  this.recordSubject(GetLayerQuery);
1310
+ this.recordSubject(MapFeatureHoveredEvent);
1311
+ this.recordWithPipe(MapPointerMoveEvent, new Subject(), (s) => s.pipe(debounceTime(150)));
1248
1312
  this.recordSubject(DrawingFinishedEvent);
1249
1313
  this.recordSubject(GetFeaturesInAreaQuery);
1250
1314
  this.recordSubject(DrawSelectionAreaCommand);
@@ -1612,6 +1676,7 @@ class FeatureLayerSettings {
1612
1676
  result.minZoom = model.minZoom;
1613
1677
  result.zIndex = model.zIndex;
1614
1678
  result.style = model.style;
1679
+ result.featureHoverStyle = model.featureHoverStyle;
1615
1680
  return result;
1616
1681
  }
1617
1682
  /**
@@ -1660,6 +1725,15 @@ class FeatureLayerSettings {
1660
1725
  setStyle(style) {
1661
1726
  return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { style }));
1662
1727
  }
1728
+ /**
1729
+ * Sets the style to apply to features when they are hovered over.
1730
+ *
1731
+ * @param {Style | StyleFunction} featureHoverStyle - The style or style function to use for hovered features.
1732
+ * @return {FeatureLayerSettings} A new instance of FeatureLayerSettings with the updated hover style.
1733
+ */
1734
+ setFeatureHoverStyle(featureHoverStyle) {
1735
+ return FeatureLayerSettings.copy(Object.assign(Object.assign({}, this), { featureHoverStyle }));
1736
+ }
1663
1737
  /**
1664
1738
  * Checks if the given FeatureLayerSettings object is identical to the current object.
1665
1739
  *
@@ -1677,6 +1751,8 @@ class FeatureLayerSettings {
1677
1751
  return false;
1678
1752
  if (this.style !== model.style)
1679
1753
  return false;
1754
+ if (this.featureHoverStyle !== model.featureHoverStyle)
1755
+ return false;
1680
1756
  return true;
1681
1757
  }
1682
1758
  }
@@ -2087,6 +2163,9 @@ class MapPlateComponent extends DestructibleComponent {
2087
2163
  this.map.updateSize();
2088
2164
  this.postboy.fire(new MapRenderedEvent(this.map));
2089
2165
  });
2166
+ this.map.on('pointermove', (ev) => {
2167
+ this.postboy.fire(new MapPointerMoveEvent(ev.pixel));
2168
+ });
2090
2169
  this.setOsm();
2091
2170
  }
2092
2171
  setOsm() {
@@ -2317,7 +2396,10 @@ class PolygonsComponent extends DestructibleComponent {
2317
2396
  putPolygons() {
2318
2397
  if (!this._polygons)
2319
2398
  return;
2320
- this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
2399
+ this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => {
2400
+ m.feature.set(MapConstants.FeatureLayerName, this.layerName);
2401
+ return m.feature;
2402
+ })));
2321
2403
  }
2322
2404
  }
2323
2405
  PolygonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: PolygonsComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
@@ -2763,5 +2845,5 @@ class StringifyFeatureHelper {
2763
2845
  * Generated bundle index. Do not edit.
2764
2846
  */
2765
2847
 
2766
- 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 };
2848
+ 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 };
2767
2849
  //# sourceMappingURL=maps-components.js.map