@artstesh/maps 1.1.25 → 1.1.26

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 (43) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +265 -6
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +265 -6
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/map-plate/layers/image-layer/image-layer-factory.js +26 -0
  6. package/dist/esm2015/map/map-plate/layers/image-layer/image-layer.component.js +54 -0
  7. package/dist/esm2015/map/map-plate/layers/image-layer/image-layer.settings.js +136 -0
  8. package/dist/esm2015/map/map-plate/layers/index.js +3 -1
  9. package/dist/esm2015/map/map.module.js +8 -3
  10. package/dist/esm2015/map/messages/commands/add-image-layer.command.js +9 -0
  11. package/dist/esm2015/map/messages/commands/remove-image-layer.command.js +9 -0
  12. package/dist/esm2015/map/services/map-management.service.js +16 -1
  13. package/dist/esm2015/map/services/message-registrator.service.js +5 -1
  14. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer-factory.js +26 -0
  15. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer.component.js +54 -0
  16. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer.settings.js +136 -0
  17. package/dist/esm2015/src/map/map-plate/layers/index.js +3 -1
  18. package/dist/esm2015/src/map/map.module.js +8 -3
  19. package/dist/esm2015/src/map/messages/commands/add-image-layer.command.js +9 -0
  20. package/dist/esm2015/src/map/messages/commands/remove-image-layer.command.js +9 -0
  21. package/dist/esm2015/src/map/services/map-management.service.js +16 -1
  22. package/dist/esm2015/src/map/services/message-registrator.service.js +5 -1
  23. package/dist/fesm2015/maps-components-src-map.js +241 -3
  24. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  25. package/dist/fesm2015/maps-components.js +241 -3
  26. package/dist/fesm2015/maps-components.js.map +1 -1
  27. package/dist/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  28. package/dist/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  29. package/dist/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  30. package/dist/map/map-plate/layers/index.d.ts +2 -0
  31. package/dist/map/map.module.d.ts +3 -2
  32. package/dist/map/messages/commands/add-image-layer.command.d.ts +8 -0
  33. package/dist/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  34. package/dist/map/services/map-management.service.d.ts +1 -0
  35. package/dist/src/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  36. package/dist/src/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  37. package/dist/src/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  38. package/dist/src/map/map-plate/layers/index.d.ts +2 -0
  39. package/dist/src/map/map.module.d.ts +3 -2
  40. package/dist/src/map/messages/commands/add-image-layer.command.d.ts +8 -0
  41. package/dist/src/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  42. package/dist/src/map/services/map-management.service.d.ts +1 -0
  43. package/package.json +1 -1
@@ -22,6 +22,8 @@ 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';
@@ -867,6 +869,22 @@ class ZoomControlFactory {
867
869
  }
868
870
  }
869
871
 
872
+ class AddImageLayerCommand extends PostboyGenericMessage {
873
+ constructor(layer) {
874
+ super();
875
+ this.layer = layer;
876
+ }
877
+ }
878
+ AddImageLayerCommand.ID = '70f9b86f-8bc2-4f28-ae79-a13fc0b1ee5d';
879
+
880
+ class RemoveImageLayerCommand extends PostboyGenericMessage {
881
+ constructor(layer) {
882
+ super();
883
+ this.layer = layer;
884
+ }
885
+ }
886
+ RemoveImageLayerCommand.ID = 'c8e7efdb-17ff-4cf9-89be-e688b8de3b95';
887
+
870
888
  class MapPostboyService extends PostboyService {
871
889
  constructor() {
872
890
  super();
@@ -898,6 +916,7 @@ class MapManagementService {
898
916
  this.observeLayerQuery();
899
917
  this.observeFeaturesInArea();
900
918
  this.observeFeaturesInPoint();
919
+ this.observeImageLayer();
901
920
  }
902
921
  observeRemoveTile() {
903
922
  this.postboy.sub(RemoveTileCommand).subscribe((c) => {
@@ -916,6 +935,18 @@ class MapManagementService {
916
935
  this.map.addLayer(c.layer);
917
936
  });
918
937
  }
938
+ observeImageLayer() {
939
+ this.postboy.sub(AddImageLayerCommand).subscribe((c) => {
940
+ if (!this.map)
941
+ return;
942
+ this.map.addLayer(c.layer);
943
+ });
944
+ this.postboy.sub(RemoveImageLayerCommand).subscribe((c) => {
945
+ if (!this.map)
946
+ return;
947
+ this.map.removeLayer(c.layer);
948
+ });
949
+ }
919
950
  observeMapRender() {
920
951
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
921
952
  this.map = m.map;
@@ -1361,6 +1392,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1361
1392
  this.recordSubject(AddLayerCommand);
1362
1393
  this.recordSubject(RemoveLayerCommand);
1363
1394
  this.recordSubject(AddTileCommand);
1395
+ this.recordSubject(RemoveImageLayerCommand);
1396
+ this.recordSubject(AddImageLayerCommand);
1364
1397
  this.recordSubject(RemoveTileCommand);
1365
1398
  this.recordSubject(MapClickEvent);
1366
1399
  this.recordSubject(CloseTooltipCommand);
@@ -2172,6 +2205,207 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2172
2205
  type: Input
2173
2206
  }] } });
2174
2207
 
2208
+ class ImageLayerSettings {
2209
+ constructor() {
2210
+ /**
2211
+ * Represents the tiles URL.
2212
+ * @typedef {string} url
2213
+ *
2214
+ * @example
2215
+ * 'https://example.ex/{z}/{x}/{y}.png'
2216
+ */
2217
+ this.url = '';
2218
+ /**
2219
+ * Use interpolated values when resampling.
2220
+ * By default, linear interpolation is used when resampling.
2221
+ * Set to false to use the nearest neighbor instead.
2222
+ */
2223
+ this.interpolate = undefined;
2224
+ /**
2225
+ * The projection of the coordinate system.
2226
+ *
2227
+ * @type {string}
2228
+ * @default 'EPSG:3857'
2229
+ */
2230
+ this.projection = 'EPSG:3857';
2231
+ this.extent = [0, 0, 0, 0];
2232
+ /**
2233
+ * Additional headers that should be added to each tile request
2234
+ *
2235
+ * @type {Record<string, string>}
2236
+ * @default An empty array
2237
+ */
2238
+ this.requestHeaders = null;
2239
+ }
2240
+ /**
2241
+ * Creates a copy of the given tile layer settings.
2242
+ *
2243
+ * @param {ImageLayerSettings} model - The tile layer settings to be copied.
2244
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the same properties as the model.
2245
+ */
2246
+ static copy(model) {
2247
+ const result = new ImageLayerSettings();
2248
+ result.interpolate = model.interpolate;
2249
+ result.projection = model.projection;
2250
+ result.extent = model.extent;
2251
+ result.url = model.url;
2252
+ result.requestHeaders = model.requestHeaders;
2253
+ return result;
2254
+ }
2255
+ /**
2256
+ * Sets the URL of the ImageLayerSettings object.
2257
+ *
2258
+ * @param {string} url - The URL to be set.
2259
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2260
+ */
2261
+ setUrl(url) {
2262
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { url }));
2263
+ }
2264
+ /**
2265
+ * Sets the interpolation state for the image layer settings.
2266
+ *
2267
+ * @param {boolean} [interpolate] - Use interpolated values when resampling.
2268
+ * By default, linear interpolation is used when resampling.
2269
+ * Set to false to use the nearest neighbor instead.
2270
+ * @return {ImageLayerSettings} A new instance of ImageLayerSettings with the updated interpolation setting.
2271
+ */
2272
+ setInterpolate(interpolate) {
2273
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { interpolate }));
2274
+ }
2275
+ setExtent(extent) {
2276
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { extent }));
2277
+ }
2278
+ /**
2279
+ * Sets the requestHeaders of the ImageLayerSettings object.
2280
+ *
2281
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
2282
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2283
+ */
2284
+ setRequestHeaders(requestHeaders) {
2285
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { requestHeaders }));
2286
+ }
2287
+ /**
2288
+ * Sets the maximum zoom level for the tile layer.
2289
+ *
2290
+ * @param {number} maxZoom - The maximum zoom level.
2291
+ * @returns {ImageLayerSettings} - The updated tile layer settings object.
2292
+ */
2293
+ setMaxZoom(maxZoom) {
2294
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
2295
+ }
2296
+ /**
2297
+ * Sets the minimum zoom level for the Tile Layer.
2298
+ *
2299
+ * @param {number} minZoom - The minimum zoom level to be set.
2300
+ * @return {ImageLayerSettings} The modified ImageLayerSettings object with the updated minimum zoom level.
2301
+ */
2302
+ setMinZoom(minZoom) {
2303
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
2304
+ }
2305
+ /**
2306
+ * Sets the opacity of the ImageLayerSettings.
2307
+ *
2308
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2309
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the opacity set.
2310
+ */
2311
+ setOpacity(opacity) {
2312
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { opacity }));
2313
+ }
2314
+ /**
2315
+ * Sets the projection for the tile layer settings.
2316
+ *
2317
+ * @param {string} projection - The desired projection for the tile layer settings.
2318
+ * @return {ImageLayerSettings} - The updated tile layer settings with the new projection.
2319
+ */
2320
+ setProjection(projection) {
2321
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { projection }));
2322
+ }
2323
+ /**
2324
+ * Checks if the current instance of ImageLayerSettings is equal to the given model.
2325
+ * @param {ImageLayerSettings} model - The model to compare against.
2326
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2327
+ * otherwise, false.
2328
+ */
2329
+ isSame(model) {
2330
+ if (this.url !== model.url)
2331
+ return false;
2332
+ if (this.projection !== model.projection)
2333
+ return false;
2334
+ if (this.extent !== model.extent)
2335
+ return false;
2336
+ if (this.interpolate !== model.interpolate)
2337
+ return false;
2338
+ if (this.requestHeaders !== model.requestHeaders)
2339
+ return false;
2340
+ return true;
2341
+ }
2342
+ }
2343
+
2344
+ class ImageLayerFactory {
2345
+ build(settings) {
2346
+ const source = new Static({
2347
+ url: settings.url,
2348
+ interpolate: settings.interpolate,
2349
+ crossOrigin: 'Anonymous',
2350
+ projection: get(settings.projection),
2351
+ imageExtent: settings.extent,
2352
+ });
2353
+ return new ImageLayer({ source });
2354
+ }
2355
+ }
2356
+ ImageLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2357
+ ImageLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerFactory, providedIn: 'root' });
2358
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerFactory, decorators: [{
2359
+ type: Injectable,
2360
+ args: [{
2361
+ providedIn: 'root',
2362
+ }]
2363
+ }] });
2364
+
2365
+ class ImageLayerComponent extends DestructibleComponent {
2366
+ constructor(postboy, factory) {
2367
+ super();
2368
+ this.postboy = postboy;
2369
+ this.factory = factory;
2370
+ this._settings = new ImageLayerSettings();
2371
+ this.onDestroy = () => this.removeLayer();
2372
+ }
2373
+ set settings(value) {
2374
+ if (!value || this._settings.isSame(value))
2375
+ return;
2376
+ this._settings = value;
2377
+ this.initLayer();
2378
+ }
2379
+ ngOnInit() {
2380
+ this.postboy
2381
+ .sub(MapRenderedEvent)
2382
+ .pipe(filter((m) => !!m), first())
2383
+ .subscribe((m) => this.initLayer());
2384
+ }
2385
+ initLayer() {
2386
+ this.removeLayer();
2387
+ this.layer = this.factory.build(this._settings);
2388
+ this.postboy.fire(new AddImageLayerCommand(this.layer));
2389
+ }
2390
+ removeLayer() {
2391
+ if (this.layer)
2392
+ this.postboy.fire(new RemoveImageLayerCommand(this.layer));
2393
+ }
2394
+ }
2395
+ ImageLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerComponent, deps: [{ token: MapPostboyService }, { token: ImageLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
2396
+ ImageLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ImageLayerComponent, selector: "art-image-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerComponent, decorators: [{
2398
+ type: Component,
2399
+ args: [{
2400
+ selector: 'art-image-layer',
2401
+ template: '',
2402
+ styleUrls: [],
2403
+ changeDetection: ChangeDetectionStrategy.OnPush,
2404
+ }]
2405
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ImageLayerFactory }]; }, propDecorators: { settings: [{
2406
+ type: Input
2407
+ }] } });
2408
+
2175
2409
  class MapPlateFactory {
2176
2410
  build(settings) {
2177
2411
  return new Map({
@@ -2675,14 +2909,16 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.
2675
2909
  TooltipComponent,
2676
2910
  PolygonsComponent,
2677
2911
  ClusterLayerComponent,
2678
- MapControlZoomComponent], imports: [CommonModule], exports: [MapPlateComponent,
2912
+ MapControlZoomComponent,
2913
+ ImageLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
2679
2914
  FeatureLayerComponent,
2680
2915
  MarkersComponent,
2681
2916
  TileLayerComponent,
2682
2917
  TooltipComponent,
2683
2918
  PolygonsComponent,
2684
2919
  ClusterLayerComponent,
2685
- MapControlZoomComponent] });
2920
+ MapControlZoomComponent,
2921
+ ImageLayerComponent] });
2686
2922
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, imports: [[CommonModule]] });
2687
2923
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, decorators: [{
2688
2924
  type: NgModule,
@@ -2699,6 +2935,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2699
2935
  PolygonsComponent,
2700
2936
  ClusterLayerComponent,
2701
2937
  MapControlZoomComponent,
2938
+ ImageLayerComponent,
2702
2939
  ],
2703
2940
  exports: [
2704
2941
  MapPlateComponent,
@@ -2709,6 +2946,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2709
2946
  PolygonsComponent,
2710
2947
  ClusterLayerComponent,
2711
2948
  MapControlZoomComponent,
2949
+ ImageLayerComponent,
2712
2950
  ],
2713
2951
  }]
2714
2952
  }] });
@@ -2909,5 +3147,5 @@ class StringifyFeatureHelper {
2909
3147
  * Generated bundle index. Do not edit.
2910
3148
  */
2911
3149
 
2912
- 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 };
3150
+ 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 };
2913
3151
  //# sourceMappingURL=maps-components.js.map