@artstesh/maps 6.1.4 → 6.1.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 (49) hide show
  1. package/dist/esm2022/map/map-plate/layers/image-layer/image-layer-factory.mjs +26 -0
  2. package/dist/esm2022/map/map-plate/layers/image-layer/image-layer.component.mjs +52 -0
  3. package/dist/esm2022/map/map-plate/layers/image-layer/image-layer.settings.mjs +134 -0
  4. package/dist/esm2022/map/map-plate/layers/index.mjs +3 -1
  5. package/dist/esm2022/map/map.module.mjs +8 -3
  6. package/dist/esm2022/map/messages/commands/add-image-layer.command.mjs +10 -0
  7. package/dist/esm2022/map/messages/commands/modify-feature.command.mjs +8 -5
  8. package/dist/esm2022/map/messages/commands/remove-image-layer.command.mjs +10 -0
  9. package/dist/esm2022/map/public-api.mjs +2 -1
  10. package/dist/esm2022/map/services/drawing/feature-modification.service.mjs +3 -2
  11. package/dist/esm2022/map/services/map-management.service.mjs +16 -1
  12. package/dist/esm2022/map/services/message-registrator.service.mjs +5 -1
  13. package/dist/esm2022/src/map/map-plate/layers/image-layer/image-layer-factory.mjs +26 -0
  14. package/dist/esm2022/src/map/map-plate/layers/image-layer/image-layer.component.mjs +52 -0
  15. package/dist/esm2022/src/map/map-plate/layers/image-layer/image-layer.settings.mjs +134 -0
  16. package/dist/esm2022/src/map/map-plate/layers/index.mjs +3 -1
  17. package/dist/esm2022/src/map/map.module.mjs +8 -3
  18. package/dist/esm2022/src/map/messages/commands/add-image-layer.command.mjs +10 -0
  19. package/dist/esm2022/src/map/messages/commands/modify-feature.command.mjs +8 -5
  20. package/dist/esm2022/src/map/messages/commands/remove-image-layer.command.mjs +10 -0
  21. package/dist/esm2022/src/map/public-api.mjs +2 -1
  22. package/dist/esm2022/src/map/services/drawing/feature-modification.service.mjs +3 -2
  23. package/dist/esm2022/src/map/services/map-management.service.mjs +16 -1
  24. package/dist/esm2022/src/map/services/message-registrator.service.mjs +5 -1
  25. package/dist/fesm2022/maps-components-src-map.mjs +249 -8
  26. package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
  27. package/dist/fesm2022/maps-components.mjs +249 -8
  28. package/dist/fesm2022/maps-components.mjs.map +1 -1
  29. package/dist/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  30. package/dist/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  31. package/dist/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  32. package/dist/map/map-plate/layers/index.d.ts +2 -0
  33. package/dist/map/map.module.d.ts +3 -2
  34. package/dist/map/messages/commands/add-image-layer.command.d.ts +8 -0
  35. package/dist/map/messages/commands/modify-feature.command.d.ts +6 -4
  36. package/dist/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  37. package/dist/map/public-api.d.ts +1 -0
  38. package/dist/map/services/map-management.service.d.ts +1 -0
  39. package/dist/src/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  40. package/dist/src/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  41. package/dist/src/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  42. package/dist/src/map/map-plate/layers/index.d.ts +2 -0
  43. package/dist/src/map/map.module.d.ts +3 -2
  44. package/dist/src/map/messages/commands/add-image-layer.command.d.ts +8 -0
  45. package/dist/src/map/messages/commands/modify-feature.command.d.ts +6 -4
  46. package/dist/src/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  47. package/dist/src/map/public-api.d.ts +1 -0
  48. package/dist/src/map/services/map-management.service.d.ts +1 -0
  49. package/package.json +1 -1
@@ -22,11 +22,14 @@ import OSM from 'ol/source/OSM';
22
22
  import { Vector as Vector$1 } from 'ol/layer';
23
23
  import { bbox } from 'ol/loadingstrategy';
24
24
  import Cluster from 'ol/source/Cluster';
25
+ import Static from 'ol/source/ImageStatic';
26
+ import ImageLayer from 'ol/layer/Image';
25
27
  import Map from 'ol/Map';
26
28
  import View from 'ol/View';
27
29
  import Overlay from 'ol/Overlay';
28
30
  import Style from 'ol/style/Style';
29
31
  import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
32
+ export { Style } from 'ol/style';
30
33
  import { METERS_PER_UNIT } from 'ol/proj/epsg4326';
31
34
 
32
35
  class DestructibleComponent {
@@ -402,19 +405,22 @@ class ModifyFeatureCommand extends PostboyCallbackMessage {
402
405
  model;
403
406
  style;
404
407
  format;
408
+ draggable;
405
409
  static ID = '8f76507e-f18d-4232-bab7-f3d4e3d707bb';
406
410
  /**
407
411
  * Constructs an instance of the class.
408
412
  *
409
- * @param {PolygonModel} model - The polygon model to be used.
410
- * @param {Style} style - The style configuration for the polygon.
411
- * @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the features. Default is GeoJson.
413
+ * @param {PolygonModel} model - The model representing the polygon data.
414
+ * @param {Style} style - The style to be applied to the polygon.
415
+ * @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the feature, defaults to GeoJson.
416
+ * @param {boolean} [draggable=true] - Determines whether the polygon is draggable, defaults to true.
412
417
  */
413
- constructor(model, style, format = FeatureOutputFormat.GeoJson) {
418
+ constructor(model, style, format = FeatureOutputFormat.GeoJson, draggable = true) {
414
419
  super();
415
420
  this.model = model;
416
421
  this.style = style;
417
422
  this.format = format;
423
+ this.draggable = draggable;
418
424
  }
419
425
  }
420
426
 
@@ -920,6 +926,24 @@ class ZoomControlFactory {
920
926
  }
921
927
  }
922
928
 
929
+ class AddImageLayerCommand extends PostboyGenericMessage {
930
+ layer;
931
+ static ID = '70f9b86f-8bc2-4f28-ae79-a13fc0b1ee5d';
932
+ constructor(layer) {
933
+ super();
934
+ this.layer = layer;
935
+ }
936
+ }
937
+
938
+ class RemoveImageLayerCommand extends PostboyGenericMessage {
939
+ layer;
940
+ static ID = 'c8e7efdb-17ff-4cf9-89be-e688b8de3b95';
941
+ constructor(layer) {
942
+ super();
943
+ this.layer = layer;
944
+ }
945
+ }
946
+
923
947
  class MapPostboyService extends PostboyService {
924
948
  constructor() {
925
949
  super();
@@ -948,6 +972,7 @@ class MapManagementService {
948
972
  this.observeLayerQuery();
949
973
  this.observeFeaturesInArea();
950
974
  this.observeFeaturesInPoint();
975
+ this.observeImageLayer();
951
976
  }
952
977
  observeRemoveTile() {
953
978
  this.postboy.sub(RemoveTileCommand).subscribe((c) => {
@@ -966,6 +991,18 @@ class MapManagementService {
966
991
  this.map.addLayer(c.layer);
967
992
  });
968
993
  }
994
+ observeImageLayer() {
995
+ this.postboy.sub(AddImageLayerCommand).subscribe((c) => {
996
+ if (!this.map)
997
+ return;
998
+ this.map.addLayer(c.layer);
999
+ });
1000
+ this.postboy.sub(RemoveImageLayerCommand).subscribe((c) => {
1001
+ if (!this.map)
1002
+ return;
1003
+ this.map.removeLayer(c.layer);
1004
+ });
1005
+ }
969
1006
  observeMapRender() {
970
1007
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
971
1008
  this.map = m.map;
@@ -1298,7 +1335,8 @@ class FeatureModificationService {
1298
1335
  this.observeCancelation(ev, l);
1299
1336
  this.initFeature(l, ev.model.feature);
1300
1337
  this.addModify(ev);
1301
- this.addDragging(ev);
1338
+ if (ev.draggable)
1339
+ this.addDragging(ev);
1302
1340
  });
1303
1341
  });
1304
1342
  }
@@ -1414,6 +1452,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1414
1452
  this.recordSubject(AddLayerCommand);
1415
1453
  this.recordSubject(RemoveLayerCommand);
1416
1454
  this.recordSubject(AddTileCommand);
1455
+ this.recordSubject(RemoveImageLayerCommand);
1456
+ this.recordSubject(AddImageLayerCommand);
1417
1457
  this.recordSubject(RemoveTileCommand);
1418
1458
  this.recordSubject(MapClickEvent);
1419
1459
  this.recordSubject(CloseTooltipCommand);
@@ -2226,6 +2266,203 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
2226
2266
  type: Input
2227
2267
  }] } });
2228
2268
 
2269
+ class ImageLayerSettings {
2270
+ /**
2271
+ * Represents the tiles URL.
2272
+ * @typedef {string} url
2273
+ *
2274
+ * @example
2275
+ * 'https://example.ex/{z}/{x}/{y}.png'
2276
+ */
2277
+ url = '';
2278
+ /**
2279
+ * Use interpolated values when resampling.
2280
+ * By default, linear interpolation is used when resampling.
2281
+ * Set to false to use the nearest neighbor instead.
2282
+ */
2283
+ interpolate = undefined;
2284
+ /**
2285
+ * The projection of the coordinate system.
2286
+ *
2287
+ * @type {string}
2288
+ * @default 'EPSG:3857'
2289
+ */
2290
+ projection = 'EPSG:3857';
2291
+ extent = [0, 0, 0, 0];
2292
+ /**
2293
+ * Additional headers that should be added to each tile request
2294
+ *
2295
+ * @type {Record<string, string>}
2296
+ * @default An empty array
2297
+ */
2298
+ requestHeaders = null;
2299
+ /**
2300
+ * Creates a copy of the given tile layer settings.
2301
+ *
2302
+ * @param {ImageLayerSettings} model - The tile layer settings to be copied.
2303
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the same properties as the model.
2304
+ */
2305
+ static copy(model) {
2306
+ const result = new ImageLayerSettings();
2307
+ result.interpolate = model.interpolate;
2308
+ result.projection = model.projection;
2309
+ result.extent = model.extent;
2310
+ result.url = model.url;
2311
+ result.requestHeaders = model.requestHeaders;
2312
+ return result;
2313
+ }
2314
+ /**
2315
+ * Sets the URL of the ImageLayerSettings object.
2316
+ *
2317
+ * @param {string} url - The URL to be set.
2318
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2319
+ */
2320
+ setUrl(url) {
2321
+ return ImageLayerSettings.copy({ ...this, url });
2322
+ }
2323
+ /**
2324
+ * Sets the interpolation state for the image layer settings.
2325
+ *
2326
+ * @param {boolean} [interpolate] - Use interpolated values when resampling.
2327
+ * By default, linear interpolation is used when resampling.
2328
+ * Set to false to use the nearest neighbor instead.
2329
+ * @return {ImageLayerSettings} A new instance of ImageLayerSettings with the updated interpolation setting.
2330
+ */
2331
+ setInterpolate(interpolate) {
2332
+ return ImageLayerSettings.copy({ ...this, interpolate });
2333
+ }
2334
+ setExtent(extent) {
2335
+ return ImageLayerSettings.copy({ ...this, extent });
2336
+ }
2337
+ /**
2338
+ * Sets the requestHeaders of the ImageLayerSettings object.
2339
+ *
2340
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
2341
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2342
+ */
2343
+ setRequestHeaders(requestHeaders) {
2344
+ return ImageLayerSettings.copy({ ...this, requestHeaders });
2345
+ }
2346
+ /**
2347
+ * Sets the maximum zoom level for the tile layer.
2348
+ *
2349
+ * @param {number} maxZoom - The maximum zoom level.
2350
+ * @returns {ImageLayerSettings} - The updated tile layer settings object.
2351
+ */
2352
+ setMaxZoom(maxZoom) {
2353
+ return ImageLayerSettings.copy({ ...this, maxZoom });
2354
+ }
2355
+ /**
2356
+ * Sets the minimum zoom level for the Tile Layer.
2357
+ *
2358
+ * @param {number} minZoom - The minimum zoom level to be set.
2359
+ * @return {ImageLayerSettings} The modified ImageLayerSettings object with the updated minimum zoom level.
2360
+ */
2361
+ setMinZoom(minZoom) {
2362
+ return ImageLayerSettings.copy({ ...this, minZoom });
2363
+ }
2364
+ /**
2365
+ * Sets the opacity of the ImageLayerSettings.
2366
+ *
2367
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2368
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the opacity set.
2369
+ */
2370
+ setOpacity(opacity) {
2371
+ return ImageLayerSettings.copy({ ...this, opacity });
2372
+ }
2373
+ /**
2374
+ * Sets the projection for the tile layer settings.
2375
+ *
2376
+ * @param {string} projection - The desired projection for the tile layer settings.
2377
+ * @return {ImageLayerSettings} - The updated tile layer settings with the new projection.
2378
+ */
2379
+ setProjection(projection) {
2380
+ return ImageLayerSettings.copy({ ...this, projection });
2381
+ }
2382
+ /**
2383
+ * Checks if the current instance of ImageLayerSettings is equal to the given model.
2384
+ * @param {ImageLayerSettings} model - The model to compare against.
2385
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2386
+ * otherwise, false.
2387
+ */
2388
+ isSame(model) {
2389
+ if (this.url !== model.url)
2390
+ return false;
2391
+ if (this.projection !== model.projection)
2392
+ return false;
2393
+ if (this.extent !== model.extent)
2394
+ return false;
2395
+ if (this.interpolate !== model.interpolate)
2396
+ return false;
2397
+ if (this.requestHeaders !== model.requestHeaders)
2398
+ return false;
2399
+ return true;
2400
+ }
2401
+ }
2402
+
2403
+ class ImageLayerFactory {
2404
+ build(settings) {
2405
+ const source = new Static({
2406
+ url: settings.url,
2407
+ interpolate: settings.interpolate,
2408
+ crossOrigin: 'Anonymous',
2409
+ projection: get(settings.projection),
2410
+ imageExtent: settings.extent,
2411
+ });
2412
+ return new ImageLayer({ source });
2413
+ }
2414
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2415
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerFactory, providedIn: 'root' });
2416
+ }
2417
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerFactory, decorators: [{
2418
+ type: Injectable,
2419
+ args: [{
2420
+ providedIn: 'root',
2421
+ }]
2422
+ }] });
2423
+
2424
+ class ImageLayerComponent extends DestructibleComponent {
2425
+ postboy;
2426
+ factory;
2427
+ layer;
2428
+ constructor(postboy, factory) {
2429
+ super();
2430
+ this.postboy = postboy;
2431
+ this.factory = factory;
2432
+ }
2433
+ _settings = new ImageLayerSettings();
2434
+ set settings(value) {
2435
+ if (!value || this._settings.isSame(value))
2436
+ return;
2437
+ this._settings = value;
2438
+ this.initLayer();
2439
+ }
2440
+ ngOnInit() {
2441
+ this.postboy
2442
+ .sub(MapRenderedEvent)
2443
+ .pipe(filter((m) => !!m), first())
2444
+ .subscribe((m) => this.initLayer());
2445
+ }
2446
+ onDestroy = () => this.removeLayer();
2447
+ initLayer() {
2448
+ this.removeLayer();
2449
+ this.layer = this.factory.build(this._settings);
2450
+ this.postboy.fire(new AddImageLayerCommand(this.layer));
2451
+ }
2452
+ removeLayer() {
2453
+ if (this.layer)
2454
+ this.postboy.fire(new RemoveImageLayerCommand(this.layer));
2455
+ }
2456
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerComponent, deps: [{ token: MapPostboyService }, { token: ImageLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
2457
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.7", type: ImageLayerComponent, selector: "art-image-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2458
+ }
2459
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerComponent, decorators: [{
2460
+ type: Component,
2461
+ args: [{ selector: 'art-image-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
2462
+ }], ctorParameters: () => [{ type: MapPostboyService }, { type: ImageLayerFactory }], propDecorators: { settings: [{
2463
+ type: Input
2464
+ }] } });
2465
+
2229
2466
  class MapPlateFactory {
2230
2467
  build(settings) {
2231
2468
  return new Map({
@@ -2714,14 +2951,16 @@ class MapModule {
2714
2951
  TooltipComponent,
2715
2952
  PolygonsComponent,
2716
2953
  ClusterLayerComponent,
2717
- MapControlZoomComponent], imports: [CommonModule], exports: [MapPlateComponent,
2954
+ MapControlZoomComponent,
2955
+ ImageLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
2718
2956
  FeatureLayerComponent,
2719
2957
  MarkersComponent,
2720
2958
  TileLayerComponent,
2721
2959
  TooltipComponent,
2722
2960
  PolygonsComponent,
2723
2961
  ClusterLayerComponent,
2724
- MapControlZoomComponent] });
2962
+ MapControlZoomComponent,
2963
+ ImageLayerComponent] });
2725
2964
  static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MapModule, imports: [CommonModule] });
2726
2965
  }
2727
2966
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MapModule, decorators: [{
@@ -2739,6 +2978,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
2739
2978
  PolygonsComponent,
2740
2979
  ClusterLayerComponent,
2741
2980
  MapControlZoomComponent,
2981
+ ImageLayerComponent,
2742
2982
  ],
2743
2983
  exports: [
2744
2984
  MapPlateComponent,
@@ -2749,6 +2989,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
2749
2989
  PolygonsComponent,
2750
2990
  ClusterLayerComponent,
2751
2991
  MapControlZoomComponent,
2992
+ ImageLayerComponent,
2752
2993
  ],
2753
2994
  }]
2754
2995
  }] });
@@ -2949,5 +3190,5 @@ class StringifyFeatureHelper {
2949
3190
  * Generated bundle index. Do not edit.
2950
3191
  */
2951
3192
 
2952
- 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, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
3193
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2953
3194
  //# sourceMappingURL=maps-components.mjs.map