@artstesh/maps 6.1.6 → 6.1.8
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.
- package/dist/esm2022/map/helpers/text-style.helper.mjs +15 -7
- package/dist/esm2022/map/map-plate/layers/index.mjs +3 -1
- package/dist/esm2022/map/map-plate/layers/raster-tile/raster-tile-layer.component.mjs +52 -0
- package/dist/esm2022/map/map-plate/layers/raster-tile/raster-tile-layer.factory.mjs +74 -0
- package/dist/esm2022/map/map-plate/layers/raster-tile/raster-tile-layer.settings.mjs +149 -0
- package/dist/esm2022/map/map.module.mjs +8 -3
- package/dist/esm2022/map/messages/commands/add-raster-tile-command.mjs +10 -0
- package/dist/esm2022/map/messages/commands/remove-raster-tile.command.mjs +10 -0
- package/dist/esm2022/map/messages/commands/start-drawing.command.mjs +1 -1
- package/dist/esm2022/map/messages/executors/generate-draw.executor.mjs +1 -1
- package/dist/esm2022/map/messages/executors/get-geometry-length.executor.mjs +18 -0
- package/dist/esm2022/map/messages/index.mjs +2 -1
- package/dist/esm2022/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2022/map/ol-proxy.mjs +6 -0
- package/dist/esm2022/map/public-api.mjs +2 -2
- package/dist/esm2022/map/services/drawing/drawing-generation.service.mjs +2 -2
- package/dist/esm2022/map/services/map-management.service.mjs +18 -9
- package/dist/esm2022/map/services/message-registrator.service.mjs +7 -1
- package/dist/esm2022/src/map/helpers/text-style.helper.mjs +15 -7
- package/dist/esm2022/src/map/map-plate/layers/index.mjs +3 -1
- package/dist/esm2022/src/map/map-plate/layers/raster-tile/raster-tile-layer.component.mjs +52 -0
- package/dist/esm2022/src/map/map-plate/layers/raster-tile/raster-tile-layer.factory.mjs +74 -0
- package/dist/esm2022/src/map/map-plate/layers/raster-tile/raster-tile-layer.settings.mjs +149 -0
- package/dist/esm2022/src/map/map.module.mjs +8 -3
- package/dist/esm2022/src/map/messages/commands/add-raster-tile-command.mjs +10 -0
- package/dist/esm2022/src/map/messages/commands/remove-raster-tile.command.mjs +10 -0
- package/dist/esm2022/src/map/messages/commands/start-drawing.command.mjs +1 -1
- package/dist/esm2022/src/map/messages/executors/generate-draw.executor.mjs +1 -1
- package/dist/esm2022/src/map/messages/executors/get-geometry-length.executor.mjs +18 -0
- package/dist/esm2022/src/map/messages/index.mjs +2 -1
- package/dist/esm2022/src/map/models/drawing-type.enum.mjs +2 -1
- package/dist/esm2022/src/map/ol-proxy.mjs +6 -0
- package/dist/esm2022/src/map/public-api.mjs +2 -2
- package/dist/esm2022/src/map/services/drawing/drawing-generation.service.mjs +2 -2
- package/dist/esm2022/src/map/services/map-management.service.mjs +18 -9
- package/dist/esm2022/src/map/services/message-registrator.service.mjs +7 -1
- package/dist/fesm2022/maps-components-src-map.mjs +345 -23
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +345 -23
- package/dist/fesm2022/maps-components.mjs.map +1 -1
- package/dist/map/helpers/text-style.helper.d.ts +10 -6
- package/dist/map/map-plate/layers/index.d.ts +2 -0
- package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.component.d.ts +21 -0
- package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.factory.d.ts +12 -0
- package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.settings.d.ts +108 -0
- package/dist/map/map.module.d.ts +3 -2
- package/dist/map/messages/commands/add-raster-tile-command.d.ts +8 -0
- package/dist/map/messages/commands/remove-raster-tile.command.d.ts +8 -0
- package/dist/map/messages/commands/start-drawing.command.d.ts +3 -3
- package/dist/map/messages/executors/generate-draw.executor.d.ts +3 -3
- package/dist/map/messages/executors/get-geometry-length.executor.d.ts +11 -0
- package/dist/map/messages/index.d.ts +1 -0
- package/dist/map/models/drawing-type.enum.d.ts +2 -1
- package/dist/map/ol-proxy.d.ts +7 -0
- package/dist/map/public-api.d.ts +1 -1
- package/dist/map/services/map-management.service.d.ts +0 -1
- package/dist/src/map/helpers/text-style.helper.d.ts +10 -6
- package/dist/src/map/map-plate/layers/index.d.ts +2 -0
- package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.component.d.ts +21 -0
- package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.factory.d.ts +12 -0
- package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.settings.d.ts +108 -0
- package/dist/src/map/map.module.d.ts +3 -2
- package/dist/src/map/messages/commands/add-raster-tile-command.d.ts +8 -0
- package/dist/src/map/messages/commands/remove-raster-tile.command.d.ts +8 -0
- package/dist/src/map/messages/commands/start-drawing.command.d.ts +3 -3
- package/dist/src/map/messages/executors/generate-draw.executor.d.ts +3 -3
- package/dist/src/map/messages/executors/get-geometry-length.executor.d.ts +11 -0
- package/dist/src/map/messages/index.d.ts +1 -0
- package/dist/src/map/models/drawing-type.enum.d.ts +2 -1
- package/dist/src/map/ol-proxy.d.ts +7 -0
- package/dist/src/map/public-api.d.ts +1 -1
- package/dist/src/map/services/map-management.service.d.ts +0 -1
- package/package.json +1 -1
|
@@ -3,16 +3,19 @@ import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgMod
|
|
|
3
3
|
import * as i4 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { Feature, Collection } from 'ol';
|
|
6
|
+
export { Feature } from 'ol';
|
|
6
7
|
import { Point, LineString } from 'ol/geom';
|
|
8
|
+
export { Geometry, LineString, Point } from 'ol/geom';
|
|
7
9
|
import { GeoJSON, WKT } from 'ol/format';
|
|
8
10
|
import { getCenter, createEmpty, extend } from 'ol/extent';
|
|
9
11
|
import Polygon, { circular, fromExtent } from 'ol/geom/Polygon';
|
|
10
12
|
import { Control, Zoom } from 'ol/control';
|
|
11
13
|
import { get, useGeographic, transform } from 'ol/proj';
|
|
12
14
|
import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
15
|
+
import * as Sphere from 'ol/sphere';
|
|
16
|
+
import { getLength } from 'ol/sphere';
|
|
13
17
|
import { Draw, Modify, Translate, defaults } from 'ol/interaction';
|
|
14
18
|
import { createRegularPolygon, createBox } from 'ol/interaction/Draw';
|
|
15
|
-
import * as Sphere from 'ol/sphere';
|
|
16
19
|
import { Subject, combineLatest } from 'rxjs';
|
|
17
20
|
import { first, debounceTime, filter, auditTime } from 'rxjs/operators';
|
|
18
21
|
import { Dictionary } from '@artstesh/collections';
|
|
@@ -24,13 +27,16 @@ import { bbox } from 'ol/loadingstrategy';
|
|
|
24
27
|
import Cluster from 'ol/source/Cluster';
|
|
25
28
|
import Static from 'ol/source/ImageStatic';
|
|
26
29
|
import ImageLayer from 'ol/layer/Image';
|
|
30
|
+
import RasterSource from 'ol/source/Raster';
|
|
27
31
|
import Map from 'ol/Map';
|
|
28
32
|
import View from 'ol/View';
|
|
29
33
|
import Overlay from 'ol/Overlay';
|
|
30
34
|
import Style from 'ol/style/Style';
|
|
31
|
-
import { Icon, Circle, Fill, Stroke, Text } from 'ol/style';
|
|
32
|
-
export { Style } from 'ol/style';
|
|
35
|
+
import { Icon, Circle as Circle$1, Fill, Stroke, Text } from 'ol/style';
|
|
36
|
+
export { Fill, RegularShape, Stroke, Style, Text } from 'ol/style';
|
|
33
37
|
import { METERS_PER_UNIT } from 'ol/proj/epsg4326';
|
|
38
|
+
import * as Circle from 'ol/style/Circle';
|
|
39
|
+
export { Circle as CircleStyle };
|
|
34
40
|
|
|
35
41
|
class DestructibleComponent {
|
|
36
42
|
subs = [];
|
|
@@ -275,6 +281,7 @@ var DrawingType;
|
|
|
275
281
|
DrawingType[DrawingType["Circle"] = 2] = "Circle";
|
|
276
282
|
DrawingType[DrawingType["Square"] = 3] = "Square";
|
|
277
283
|
DrawingType[DrawingType["Box"] = 4] = "Box";
|
|
284
|
+
DrawingType[DrawingType["LineString"] = 5] = "LineString";
|
|
278
285
|
})(DrawingType || (DrawingType = {}));
|
|
279
286
|
|
|
280
287
|
/**
|
|
@@ -735,6 +742,22 @@ class FitToFeaturesCommand extends PostboyGenericMessage {
|
|
|
735
742
|
}
|
|
736
743
|
}
|
|
737
744
|
|
|
745
|
+
class GetGeometryLengthExecutor extends PostboyExecutor {
|
|
746
|
+
geometry;
|
|
747
|
+
projection;
|
|
748
|
+
static ID = '763146df-6d93-4dc2-a532-0e9ba2b2d023';
|
|
749
|
+
constructor(geometry, projection = 'EPSG:4326') {
|
|
750
|
+
super();
|
|
751
|
+
this.geometry = geometry;
|
|
752
|
+
this.projection = projection;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
class GetGeometryLengthExecutorHandler {
|
|
756
|
+
handle(executor) {
|
|
757
|
+
return Math.round(getLength(executor.geometry, { projection: executor.projection }) * 100) / 100;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
738
761
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
739
762
|
layer;
|
|
740
763
|
static ID = '7fe68d71-350f-47e2-b1ae-62cc333e1572';
|
|
@@ -799,7 +822,7 @@ class DrawingGenerationService {
|
|
|
799
822
|
static getDraw(ev) {
|
|
800
823
|
return new Draw({
|
|
801
824
|
source: ev.layer.getSource(),
|
|
802
|
-
type: ev.type === DrawingType.Polygon ? 'Polygon' : 'Circle',
|
|
825
|
+
type: ev.type === DrawingType.Polygon ? 'Polygon' : ev.type === DrawingType.LineString ? 'LineString' : 'Circle',
|
|
803
826
|
style: ev.style,
|
|
804
827
|
geometryFunction: DrawingGenerationService.geometryFunc(ev.type),
|
|
805
828
|
});
|
|
@@ -944,6 +967,24 @@ class RemoveImageLayerCommand extends PostboyGenericMessage {
|
|
|
944
967
|
}
|
|
945
968
|
}
|
|
946
969
|
|
|
970
|
+
class AddRasterTileCommand extends PostboyGenericMessage {
|
|
971
|
+
layer;
|
|
972
|
+
static ID = 'd33447fe-eec0-4205-9b5d-0d79ddc74ad7';
|
|
973
|
+
constructor(layer) {
|
|
974
|
+
super();
|
|
975
|
+
this.layer = layer;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
class RemoveRasterTileCommand extends PostboyGenericMessage {
|
|
980
|
+
layer;
|
|
981
|
+
static ID = 'd1c4bf6a-e2f2-4385-a7a2-cecb525f8939';
|
|
982
|
+
constructor(layer) {
|
|
983
|
+
super();
|
|
984
|
+
this.layer = layer;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
947
988
|
class MapPostboyService extends PostboyService {
|
|
948
989
|
constructor() {
|
|
949
990
|
super();
|
|
@@ -968,19 +1009,11 @@ class MapManagementService {
|
|
|
968
1009
|
this.observeRemoveLayer();
|
|
969
1010
|
this.observePlaceFeatures();
|
|
970
1011
|
this.observeAddTile();
|
|
971
|
-
this.observeRemoveTile();
|
|
972
1012
|
this.observeLayerQuery();
|
|
973
1013
|
this.observeFeaturesInArea();
|
|
974
1014
|
this.observeFeaturesInPoint();
|
|
975
1015
|
this.observeImageLayer();
|
|
976
1016
|
}
|
|
977
|
-
observeRemoveTile() {
|
|
978
|
-
this.postboy.sub(RemoveTileCommand).subscribe((c) => {
|
|
979
|
-
if (!this.map)
|
|
980
|
-
return;
|
|
981
|
-
this.map.removeLayer(c.layer);
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
1017
|
observeLayerQuery() {
|
|
985
1018
|
this.postboy.sub(GetLayerQuery).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
|
|
986
1019
|
}
|
|
@@ -990,6 +1023,21 @@ class MapManagementService {
|
|
|
990
1023
|
return;
|
|
991
1024
|
this.map.addLayer(c.layer);
|
|
992
1025
|
});
|
|
1026
|
+
this.postboy.sub(RemoveTileCommand).subscribe((c) => {
|
|
1027
|
+
if (!this.map)
|
|
1028
|
+
return;
|
|
1029
|
+
this.map.removeLayer(c.layer);
|
|
1030
|
+
});
|
|
1031
|
+
this.postboy.sub(AddRasterTileCommand).subscribe((c) => {
|
|
1032
|
+
if (!this.map)
|
|
1033
|
+
return;
|
|
1034
|
+
this.map.addLayer(c.layer);
|
|
1035
|
+
});
|
|
1036
|
+
this.postboy.sub(RemoveRasterTileCommand).subscribe((c) => {
|
|
1037
|
+
if (!this.map)
|
|
1038
|
+
return;
|
|
1039
|
+
this.map.removeLayer(c.layer);
|
|
1040
|
+
});
|
|
993
1041
|
}
|
|
994
1042
|
observeImageLayer() {
|
|
995
1043
|
this.postboy.sub(AddImageLayerCommand).subscribe((c) => {
|
|
@@ -1452,6 +1500,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
1452
1500
|
this.recordSubject(AddLayerCommand);
|
|
1453
1501
|
this.recordSubject(RemoveLayerCommand);
|
|
1454
1502
|
this.recordSubject(AddTileCommand);
|
|
1503
|
+
this.recordSubject(AddRasterTileCommand);
|
|
1504
|
+
this.recordSubject(RemoveRasterTileCommand);
|
|
1455
1505
|
this.recordSubject(RemoveImageLayerCommand);
|
|
1456
1506
|
this.recordSubject(AddImageLayerCommand);
|
|
1457
1507
|
this.recordSubject(RemoveTileCommand);
|
|
@@ -1481,6 +1531,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
1481
1531
|
this.recordExecutor(GenerateDrawExecutor, (e) => DrawingGenerationService.getDraw(e));
|
|
1482
1532
|
this.recordExecutor(GenerateZoomControlExecutor, (e) => ZoomControlFactory.build(e.settings));
|
|
1483
1533
|
this.recordExecutor(GetMapPositionExecutor, () => this.state.getMapPosition());
|
|
1534
|
+
this.recordExecutor(GetGeometryLengthExecutor, (e) => new GetGeometryLengthExecutorHandler().handle(e));
|
|
1484
1535
|
}
|
|
1485
1536
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: FeatureModificationService }, { token: ControlsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1486
1537
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MessageRegistratorService });
|
|
@@ -2463,6 +2514,265 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
|
|
|
2463
2514
|
type: Input
|
|
2464
2515
|
}] } });
|
|
2465
2516
|
|
|
2517
|
+
class RasterTileLayerSettings {
|
|
2518
|
+
/**
|
|
2519
|
+
* The maximum zoom level for a map view.
|
|
2520
|
+
*
|
|
2521
|
+
* @type {number}
|
|
2522
|
+
* @default 19
|
|
2523
|
+
*/
|
|
2524
|
+
maxZoom = 19;
|
|
2525
|
+
/**
|
|
2526
|
+
* The minimum zoom level allowed.
|
|
2527
|
+
*
|
|
2528
|
+
* @type {number}
|
|
2529
|
+
*/
|
|
2530
|
+
minZoom = 0;
|
|
2531
|
+
/**
|
|
2532
|
+
* The opacity of an element.
|
|
2533
|
+
*
|
|
2534
|
+
* @type {number}
|
|
2535
|
+
* @default 0.6
|
|
2536
|
+
*/
|
|
2537
|
+
opacity = 0.6;
|
|
2538
|
+
/**
|
|
2539
|
+
* Represents the tiles URL.
|
|
2540
|
+
* @typedef {string} url
|
|
2541
|
+
*
|
|
2542
|
+
* @example
|
|
2543
|
+
* 'https://example.ex/{z}/{x}/{y}.png'
|
|
2544
|
+
*/
|
|
2545
|
+
url = '';
|
|
2546
|
+
/**
|
|
2547
|
+
* The projection of the coordinate system.
|
|
2548
|
+
*
|
|
2549
|
+
* @type {string}
|
|
2550
|
+
* @default 'EPSG:3857'
|
|
2551
|
+
*/
|
|
2552
|
+
projection = 'EPSG:3857';
|
|
2553
|
+
/**
|
|
2554
|
+
* Additional headers that should be added to each tile request
|
|
2555
|
+
*
|
|
2556
|
+
* @type {Record<string, string>}
|
|
2557
|
+
* @default An empty array
|
|
2558
|
+
*/
|
|
2559
|
+
requestHeaders = null;
|
|
2560
|
+
operation = (d) => d[0] ?? [];
|
|
2561
|
+
/**
|
|
2562
|
+
* Creates a copy of the given tile layer settings.
|
|
2563
|
+
*
|
|
2564
|
+
* @param {RasterTileLayerSettings} model - The tile layer settings to be copied.
|
|
2565
|
+
* @return {RasterTileLayerSettings} - A new instance of RasterTileLayerSettings with the same properties as the model.
|
|
2566
|
+
*/
|
|
2567
|
+
static copy(model) {
|
|
2568
|
+
const result = new RasterTileLayerSettings();
|
|
2569
|
+
result.maxZoom = model.maxZoom;
|
|
2570
|
+
result.minZoom = model.minZoom;
|
|
2571
|
+
result.projection = model.projection;
|
|
2572
|
+
result.opacity = model.opacity;
|
|
2573
|
+
result.url = model.url;
|
|
2574
|
+
result.requestHeaders = model.requestHeaders;
|
|
2575
|
+
result.operation = model.operation;
|
|
2576
|
+
return result;
|
|
2577
|
+
}
|
|
2578
|
+
/**
|
|
2579
|
+
* Sets the URL of the RasterTileLayerSettings object.
|
|
2580
|
+
*
|
|
2581
|
+
* @param {string} url - The URL to be set.
|
|
2582
|
+
* @return {RasterTileLayerSettings} - The updated RasterTileLayerSettings object.
|
|
2583
|
+
*/
|
|
2584
|
+
setUrl(url) {
|
|
2585
|
+
return RasterTileLayerSettings.copy({ ...this, url });
|
|
2586
|
+
}
|
|
2587
|
+
/**
|
|
2588
|
+
* Sets the operation to apply on raster tile data.
|
|
2589
|
+
*
|
|
2590
|
+
* @param {function} operation - A function that takes an input of either a two-dimensional array of numbers or an array of ImageData objects and returns either a one-dimensional array of numbers or an ImageData object.
|
|
2591
|
+
* @return {RasterTileLayerSettings} A new instance of RasterTileLayerSettings with the updated operation.
|
|
2592
|
+
*/
|
|
2593
|
+
setOperation(operation) {
|
|
2594
|
+
return RasterTileLayerSettings.copy({ ...this, operation });
|
|
2595
|
+
}
|
|
2596
|
+
/**
|
|
2597
|
+
* Sets the requestHeaders of the RasterTileLayerSettings object.
|
|
2598
|
+
*
|
|
2599
|
+
* @param {Record<string, string>} requestHeaders - The headers which should be provided.
|
|
2600
|
+
* @return {RasterTileLayerSettings} - The updated RasterTileLayerSettings object.
|
|
2601
|
+
*/
|
|
2602
|
+
setRequestHeaders(requestHeaders) {
|
|
2603
|
+
return RasterTileLayerSettings.copy({ ...this, requestHeaders });
|
|
2604
|
+
}
|
|
2605
|
+
/**
|
|
2606
|
+
* Sets the maximum zoom level for the tile layer.
|
|
2607
|
+
*
|
|
2608
|
+
* @param {number} maxZoom - The maximum zoom level.
|
|
2609
|
+
* @returns {RasterTileLayerSettings} - The updated tile layer settings object.
|
|
2610
|
+
*/
|
|
2611
|
+
setMaxZoom(maxZoom) {
|
|
2612
|
+
return RasterTileLayerSettings.copy({ ...this, maxZoom });
|
|
2613
|
+
}
|
|
2614
|
+
/**
|
|
2615
|
+
* Sets the minimum zoom level for the Tile Layer.
|
|
2616
|
+
*
|
|
2617
|
+
* @param {number} minZoom - The minimum zoom level to be set.
|
|
2618
|
+
* @return {RasterTileLayerSettings} The modified RasterTileLayerSettings object with the updated minimum zoom level.
|
|
2619
|
+
*/
|
|
2620
|
+
setMinZoom(minZoom) {
|
|
2621
|
+
return RasterTileLayerSettings.copy({ ...this, minZoom });
|
|
2622
|
+
}
|
|
2623
|
+
/**
|
|
2624
|
+
* Sets the opacity of the RasterTileLayerSettings.
|
|
2625
|
+
*
|
|
2626
|
+
* @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
|
|
2627
|
+
* @return {RasterTileLayerSettings} - A new instance of RasterTileLayerSettings with the opacity set.
|
|
2628
|
+
*/
|
|
2629
|
+
setOpacity(opacity) {
|
|
2630
|
+
return RasterTileLayerSettings.copy({ ...this, opacity });
|
|
2631
|
+
}
|
|
2632
|
+
/**
|
|
2633
|
+
* Sets the projection for the tile layer settings.
|
|
2634
|
+
*
|
|
2635
|
+
* @param {string} projection - The desired projection for the tile layer settings.
|
|
2636
|
+
* @return {RasterTileLayerSettings} - The updated tile layer settings with the new projection.
|
|
2637
|
+
*/
|
|
2638
|
+
setProjection(projection) {
|
|
2639
|
+
return RasterTileLayerSettings.copy({ ...this, projection });
|
|
2640
|
+
}
|
|
2641
|
+
/**
|
|
2642
|
+
* Checks if the current instance of RasterTileLayerSettings is equal to the given model.
|
|
2643
|
+
* @param {RasterTileLayerSettings} model - The model to compare against.
|
|
2644
|
+
* @return {boolean} - True if all properties of the current instance matches the properties of the model;
|
|
2645
|
+
* otherwise, false.
|
|
2646
|
+
*/
|
|
2647
|
+
isSame(model) {
|
|
2648
|
+
if (this.maxZoom !== model.maxZoom)
|
|
2649
|
+
return false;
|
|
2650
|
+
if (this.minZoom !== model.minZoom)
|
|
2651
|
+
return false;
|
|
2652
|
+
if (this.url !== model.url)
|
|
2653
|
+
return false;
|
|
2654
|
+
if (this.projection !== model.projection)
|
|
2655
|
+
return false;
|
|
2656
|
+
if (this.opacity !== model.opacity)
|
|
2657
|
+
return false;
|
|
2658
|
+
if (this.requestHeaders !== model.requestHeaders)
|
|
2659
|
+
return false;
|
|
2660
|
+
if (this.operation !== model.operation)
|
|
2661
|
+
return false;
|
|
2662
|
+
return true;
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
class RasterTileLayerFactory {
|
|
2667
|
+
build(settings) {
|
|
2668
|
+
const source = new XYZ({
|
|
2669
|
+
tileSize: 256,
|
|
2670
|
+
maxZoom: settings.maxZoom || 14,
|
|
2671
|
+
minZoom: settings.minZoom || 1,
|
|
2672
|
+
projection: get(settings.projection),
|
|
2673
|
+
tileUrlFunction: this.getTileFunc(settings),
|
|
2674
|
+
crossOrigin: 'Anonymous',
|
|
2675
|
+
tileLoadFunction: !!settings.requestHeaders
|
|
2676
|
+
? (tile, src) => this.tileLoader(tile, src, settings.requestHeaders)
|
|
2677
|
+
: undefined,
|
|
2678
|
+
});
|
|
2679
|
+
const raster = new RasterSource({
|
|
2680
|
+
sources: [source],
|
|
2681
|
+
operationType: 'image',
|
|
2682
|
+
operation: settings.operation,
|
|
2683
|
+
});
|
|
2684
|
+
return new ImageLayer({ source: raster, opacity: settings.opacity });
|
|
2685
|
+
}
|
|
2686
|
+
getTileFunc(settings) {
|
|
2687
|
+
return (tileCoord) => {
|
|
2688
|
+
const zoom = tileCoord[0];
|
|
2689
|
+
const x = tileCoord[1];
|
|
2690
|
+
const y = tileCoord[2];
|
|
2691
|
+
const normalizedCoord = this.getNormalizedCoord({ x: x, y: y }, zoom);
|
|
2692
|
+
const bound = 1 << zoom;
|
|
2693
|
+
return settings.url
|
|
2694
|
+
.replace('{x}', String(normalizedCoord?.x || x))
|
|
2695
|
+
.replace('{z}', String(zoom))
|
|
2696
|
+
.replace('{y}', String(bound - (normalizedCoord?.y || y) - 1));
|
|
2697
|
+
};
|
|
2698
|
+
}
|
|
2699
|
+
tileLoader(tile, src, headers) {
|
|
2700
|
+
const client = new XMLHttpRequest();
|
|
2701
|
+
client.open('GET', src);
|
|
2702
|
+
client.responseType = 'arraybuffer';
|
|
2703
|
+
Object.keys(headers).forEach((k) => client.setRequestHeader(k, headers[k]));
|
|
2704
|
+
client.onload = function () {
|
|
2705
|
+
if (this.response !== undefined) {
|
|
2706
|
+
const arrayBufferView = new Uint8Array(this.response);
|
|
2707
|
+
const blob = new Blob([arrayBufferView], { type: 'image/png' });
|
|
2708
|
+
const urlCreator = window.URL || window.webkitURL;
|
|
2709
|
+
tile.getImage().src = urlCreator.createObjectURL(blob);
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2712
|
+
client.send();
|
|
2713
|
+
}
|
|
2714
|
+
getNormalizedCoord(coord, zoom) {
|
|
2715
|
+
const y = coord.y;
|
|
2716
|
+
let x = coord.x;
|
|
2717
|
+
const tileRange = 1 << zoom;
|
|
2718
|
+
if (y < 0 || y >= tileRange)
|
|
2719
|
+
return null;
|
|
2720
|
+
if (x < 0 || x >= tileRange)
|
|
2721
|
+
x = ((x % tileRange) + tileRange) % tileRange;
|
|
2722
|
+
return { x: x, y: y };
|
|
2723
|
+
}
|
|
2724
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2725
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerFactory, providedIn: 'root' });
|
|
2726
|
+
}
|
|
2727
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerFactory, decorators: [{
|
|
2728
|
+
type: Injectable,
|
|
2729
|
+
args: [{
|
|
2730
|
+
providedIn: 'root',
|
|
2731
|
+
}]
|
|
2732
|
+
}] });
|
|
2733
|
+
|
|
2734
|
+
class RasterTileLayerComponent extends DestructibleComponent {
|
|
2735
|
+
postboy;
|
|
2736
|
+
factory;
|
|
2737
|
+
layer;
|
|
2738
|
+
constructor(postboy, factory) {
|
|
2739
|
+
super();
|
|
2740
|
+
this.postboy = postboy;
|
|
2741
|
+
this.factory = factory;
|
|
2742
|
+
}
|
|
2743
|
+
_settings = new RasterTileLayerSettings();
|
|
2744
|
+
set settings(value) {
|
|
2745
|
+
if (!value || this._settings.isSame(value))
|
|
2746
|
+
return;
|
|
2747
|
+
this._settings = value;
|
|
2748
|
+
this.initLayer();
|
|
2749
|
+
}
|
|
2750
|
+
ngOnInit() {
|
|
2751
|
+
this.postboy
|
|
2752
|
+
.sub(MapRenderedEvent)
|
|
2753
|
+
.pipe(filter((m) => !!m), first())
|
|
2754
|
+
.subscribe((m) => this.initLayer());
|
|
2755
|
+
}
|
|
2756
|
+
onDestroy = () => this.removeLayer();
|
|
2757
|
+
initLayer() {
|
|
2758
|
+
this.removeLayer();
|
|
2759
|
+
this.layer = this.factory.build(this._settings);
|
|
2760
|
+
this.postboy.fire(new AddRasterTileCommand(this.layer));
|
|
2761
|
+
}
|
|
2762
|
+
removeLayer() {
|
|
2763
|
+
if (this.layer)
|
|
2764
|
+
this.postboy.fire(new RemoveRasterTileCommand(this.layer));
|
|
2765
|
+
}
|
|
2766
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerComponent, deps: [{ token: MapPostboyService }, { token: RasterTileLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
|
|
2767
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.7", type: RasterTileLayerComponent, selector: "art-raster-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2768
|
+
}
|
|
2769
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerComponent, decorators: [{
|
|
2770
|
+
type: Component,
|
|
2771
|
+
args: [{ selector: 'art-raster-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
|
|
2772
|
+
}], ctorParameters: () => [{ type: MapPostboyService }, { type: RasterTileLayerFactory }], propDecorators: { settings: [{
|
|
2773
|
+
type: Input
|
|
2774
|
+
}] } });
|
|
2775
|
+
|
|
2466
2776
|
class MapPlateFactory {
|
|
2467
2777
|
build(settings) {
|
|
2468
2778
|
return new Map({
|
|
@@ -2952,7 +3262,8 @@ class MapModule {
|
|
|
2952
3262
|
PolygonsComponent,
|
|
2953
3263
|
ClusterLayerComponent,
|
|
2954
3264
|
MapControlZoomComponent,
|
|
2955
|
-
ImageLayerComponent
|
|
3265
|
+
ImageLayerComponent,
|
|
3266
|
+
RasterTileLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
|
|
2956
3267
|
FeatureLayerComponent,
|
|
2957
3268
|
MarkersComponent,
|
|
2958
3269
|
TileLayerComponent,
|
|
@@ -2960,7 +3271,8 @@ class MapModule {
|
|
|
2960
3271
|
PolygonsComponent,
|
|
2961
3272
|
ClusterLayerComponent,
|
|
2962
3273
|
MapControlZoomComponent,
|
|
2963
|
-
ImageLayerComponent
|
|
3274
|
+
ImageLayerComponent,
|
|
3275
|
+
RasterTileLayerComponent] });
|
|
2964
3276
|
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MapModule, imports: [CommonModule] });
|
|
2965
3277
|
}
|
|
2966
3278
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MapModule, decorators: [{
|
|
@@ -2979,6 +3291,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
|
|
|
2979
3291
|
ClusterLayerComponent,
|
|
2980
3292
|
MapControlZoomComponent,
|
|
2981
3293
|
ImageLayerComponent,
|
|
3294
|
+
RasterTileLayerComponent,
|
|
2982
3295
|
],
|
|
2983
3296
|
exports: [
|
|
2984
3297
|
MapPlateComponent,
|
|
@@ -2990,6 +3303,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
|
|
|
2990
3303
|
ClusterLayerComponent,
|
|
2991
3304
|
MapControlZoomComponent,
|
|
2992
3305
|
ImageLayerComponent,
|
|
3306
|
+
RasterTileLayerComponent,
|
|
2993
3307
|
],
|
|
2994
3308
|
}]
|
|
2995
3309
|
}] });
|
|
@@ -3027,7 +3341,7 @@ class MarkerStyleHelper {
|
|
|
3027
3341
|
*/
|
|
3028
3342
|
static circle(radius, fill, strokeColor, strokeWidth = 1) {
|
|
3029
3343
|
return new Style({
|
|
3030
|
-
image: new Circle({
|
|
3344
|
+
image: new Circle$1({
|
|
3031
3345
|
radius,
|
|
3032
3346
|
fill: new Fill({ color: fill }),
|
|
3033
3347
|
stroke: new Stroke({ color: strokeColor, width: strokeWidth }),
|
|
@@ -3082,7 +3396,7 @@ class PolygonStyleHelper {
|
|
|
3082
3396
|
*/
|
|
3083
3397
|
static edit(fill, stroke, strokeWidth = 1, pinRadius = 5) {
|
|
3084
3398
|
return new Style({
|
|
3085
|
-
image: new Circle({
|
|
3399
|
+
image: new Circle$1({
|
|
3086
3400
|
fill: new Fill({
|
|
3087
3401
|
color: stroke,
|
|
3088
3402
|
}),
|
|
@@ -3104,14 +3418,18 @@ class PolygonStyleHelper {
|
|
|
3104
3418
|
*/
|
|
3105
3419
|
class TextStyleHelper {
|
|
3106
3420
|
/**
|
|
3107
|
-
* Creates a new
|
|
3421
|
+
* Creates and returns a new Text instance with specified styling properties.
|
|
3108
3422
|
*
|
|
3109
|
-
* @param {string} text - The text content
|
|
3110
|
-
* @param {string} font - The font style
|
|
3111
|
-
* @param {string} color - The color of the
|
|
3112
|
-
* @
|
|
3423
|
+
* @param {string} text - The text content to display.
|
|
3424
|
+
* @param {string} font - The font style to use for the text.
|
|
3425
|
+
* @param {string} color - The color of the text.
|
|
3426
|
+
* @param {string|null|undefined} [backColor] - The background color of the text. Optional.
|
|
3427
|
+
* @param {number[]|null|undefined} [padding] - The padding around the text in pixels. Optional.
|
|
3428
|
+
* @param {string|null|undefined} [textBaseline] - The text baseline alignment. Optional.
|
|
3429
|
+
* @param {number|null|undefined} [offsetY] - The vertical offset for the text. Optional.
|
|
3430
|
+
* @return {Text} A new Text instance configured with the specified properties.
|
|
3113
3431
|
*/
|
|
3114
|
-
static get(text, font, color) {
|
|
3432
|
+
static get(text, font, color, backColor, padding, textBaseline, offsetY) {
|
|
3115
3433
|
return new Text({
|
|
3116
3434
|
text: text,
|
|
3117
3435
|
font: font,
|
|
@@ -3119,6 +3437,10 @@ class TextStyleHelper {
|
|
|
3119
3437
|
fill: new Fill({
|
|
3120
3438
|
color: color,
|
|
3121
3439
|
}),
|
|
3440
|
+
backgroundFill: backColor ? new Fill({ color: backColor }) : undefined,
|
|
3441
|
+
padding: padding ?? undefined,
|
|
3442
|
+
textBaseline: textBaseline ?? undefined,
|
|
3443
|
+
offsetY: offsetY ?? undefined,
|
|
3122
3444
|
});
|
|
3123
3445
|
}
|
|
3124
3446
|
}
|
|
@@ -3190,5 +3512,5 @@ class StringifyFeatureHelper {
|
|
|
3190
3512
|
* Generated bundle index. Do not edit.
|
|
3191
3513
|
*/
|
|
3192
3514
|
|
|
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 };
|
|
3515
|
+
export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, 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, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
|
|
3194
3516
|
//# sourceMappingURL=maps-components.mjs.map
|