@artstesh/maps 1.1.24 → 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 (53) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +278 -11
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +278 -11
  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/modify-feature.command.js +7 -5
  12. package/dist/esm2015/map/messages/commands/remove-image-layer.command.js +9 -0
  13. package/dist/esm2015/map/public-api.js +2 -1
  14. package/dist/esm2015/map/services/drawing/feature-modification.service.js +3 -2
  15. package/dist/esm2015/map/services/map-management.service.js +16 -1
  16. package/dist/esm2015/map/services/message-registrator.service.js +5 -1
  17. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer-factory.js +26 -0
  18. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer.component.js +54 -0
  19. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer.settings.js +136 -0
  20. package/dist/esm2015/src/map/map-plate/layers/index.js +3 -1
  21. package/dist/esm2015/src/map/map.module.js +8 -3
  22. package/dist/esm2015/src/map/messages/commands/add-image-layer.command.js +9 -0
  23. package/dist/esm2015/src/map/messages/commands/modify-feature.command.js +7 -5
  24. package/dist/esm2015/src/map/messages/commands/remove-image-layer.command.js +9 -0
  25. package/dist/esm2015/src/map/public-api.js +2 -1
  26. package/dist/esm2015/src/map/services/drawing/feature-modification.service.js +3 -2
  27. package/dist/esm2015/src/map/services/map-management.service.js +16 -1
  28. package/dist/esm2015/src/map/services/message-registrator.service.js +5 -1
  29. package/dist/fesm2015/maps-components-src-map.js +250 -8
  30. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  31. package/dist/fesm2015/maps-components.js +250 -8
  32. package/dist/fesm2015/maps-components.js.map +1 -1
  33. package/dist/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  34. package/dist/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  35. package/dist/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  36. package/dist/map/map-plate/layers/index.d.ts +2 -0
  37. package/dist/map/map.module.d.ts +3 -2
  38. package/dist/map/messages/commands/add-image-layer.command.d.ts +8 -0
  39. package/dist/map/messages/commands/modify-feature.command.d.ts +6 -4
  40. package/dist/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  41. package/dist/map/public-api.d.ts +1 -0
  42. package/dist/map/services/map-management.service.d.ts +1 -0
  43. package/dist/src/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  44. package/dist/src/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  45. package/dist/src/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  46. package/dist/src/map/map-plate/layers/index.d.ts +2 -0
  47. package/dist/src/map/map.module.d.ts +3 -2
  48. package/dist/src/map/messages/commands/add-image-layer.command.d.ts +8 -0
  49. package/dist/src/map/messages/commands/modify-feature.command.d.ts +6 -4
  50. package/dist/src/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  51. package/dist/src/map/public-api.d.ts +1 -0
  52. package/dist/src/map/services/map-management.service.d.ts +1 -0
  53. 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 {
@@ -388,15 +391,17 @@ class ModifyFeatureCommand extends PostboyCallbackMessage {
388
391
  /**
389
392
  * Constructs an instance of the class.
390
393
  *
391
- * @param {PolygonModel} model - The polygon model to be used.
392
- * @param {Style} style - The style configuration for the polygon.
393
- * @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the features. Default is GeoJson.
394
+ * @param {PolygonModel} model - The model representing the polygon data.
395
+ * @param {Style} style - The style to be applied to the polygon.
396
+ * @param {FeatureOutputFormat} [format=FeatureOutputFormat.GeoJson] - The output format of the feature, defaults to GeoJson.
397
+ * @param {boolean} [draggable=true] - Determines whether the polygon is draggable, defaults to true.
394
398
  */
395
- constructor(model, style, format = FeatureOutputFormat.GeoJson) {
399
+ constructor(model, style, format = FeatureOutputFormat.GeoJson, draggable = true) {
396
400
  super();
397
401
  this.model = model;
398
402
  this.style = style;
399
403
  this.format = format;
404
+ this.draggable = draggable;
400
405
  }
401
406
  }
402
407
  ModifyFeatureCommand.ID = '8f76507e-f18d-4232-bab7-f3d4e3d707bb';
@@ -864,6 +869,22 @@ class ZoomControlFactory {
864
869
  }
865
870
  }
866
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
+
867
888
  class MapPostboyService extends PostboyService {
868
889
  constructor() {
869
890
  super();
@@ -895,6 +916,7 @@ class MapManagementService {
895
916
  this.observeLayerQuery();
896
917
  this.observeFeaturesInArea();
897
918
  this.observeFeaturesInPoint();
919
+ this.observeImageLayer();
898
920
  }
899
921
  observeRemoveTile() {
900
922
  this.postboy.sub(RemoveTileCommand).subscribe((c) => {
@@ -913,6 +935,18 @@ class MapManagementService {
913
935
  this.map.addLayer(c.layer);
914
936
  });
915
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
+ }
916
950
  observeMapRender() {
917
951
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
918
952
  this.map = m.map;
@@ -1239,7 +1273,8 @@ class FeatureModificationService {
1239
1273
  this.observeCancelation(ev, l);
1240
1274
  this.initFeature(l, ev.model.feature);
1241
1275
  this.addModify(ev);
1242
- this.addDragging(ev);
1276
+ if (ev.draggable)
1277
+ this.addDragging(ev);
1243
1278
  });
1244
1279
  });
1245
1280
  }
@@ -1357,6 +1392,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1357
1392
  this.recordSubject(AddLayerCommand);
1358
1393
  this.recordSubject(RemoveLayerCommand);
1359
1394
  this.recordSubject(AddTileCommand);
1395
+ this.recordSubject(RemoveImageLayerCommand);
1396
+ this.recordSubject(AddImageLayerCommand);
1360
1397
  this.recordSubject(RemoveTileCommand);
1361
1398
  this.recordSubject(MapClickEvent);
1362
1399
  this.recordSubject(CloseTooltipCommand);
@@ -2168,6 +2205,207 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2168
2205
  type: Input
2169
2206
  }] } });
2170
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
+
2171
2409
  class MapPlateFactory {
2172
2410
  build(settings) {
2173
2411
  return new Map({
@@ -2671,14 +2909,16 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.
2671
2909
  TooltipComponent,
2672
2910
  PolygonsComponent,
2673
2911
  ClusterLayerComponent,
2674
- MapControlZoomComponent], imports: [CommonModule], exports: [MapPlateComponent,
2912
+ MapControlZoomComponent,
2913
+ ImageLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
2675
2914
  FeatureLayerComponent,
2676
2915
  MarkersComponent,
2677
2916
  TileLayerComponent,
2678
2917
  TooltipComponent,
2679
2918
  PolygonsComponent,
2680
2919
  ClusterLayerComponent,
2681
- MapControlZoomComponent] });
2920
+ MapControlZoomComponent,
2921
+ ImageLayerComponent] });
2682
2922
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, imports: [[CommonModule]] });
2683
2923
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, decorators: [{
2684
2924
  type: NgModule,
@@ -2695,6 +2935,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2695
2935
  PolygonsComponent,
2696
2936
  ClusterLayerComponent,
2697
2937
  MapControlZoomComponent,
2938
+ ImageLayerComponent,
2698
2939
  ],
2699
2940
  exports: [
2700
2941
  MapPlateComponent,
@@ -2705,6 +2946,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2705
2946
  PolygonsComponent,
2706
2947
  ClusterLayerComponent,
2707
2948
  MapControlZoomComponent,
2949
+ ImageLayerComponent,
2708
2950
  ],
2709
2951
  }]
2710
2952
  }] });
@@ -2905,5 +3147,5 @@ class StringifyFeatureHelper {
2905
3147
  * Generated bundle index. Do not edit.
2906
3148
  */
2907
3149
 
2908
- 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 };
2909
3151
  //# sourceMappingURL=maps-components.js.map