@artstesh/maps 5.1.2 → 5.1.3
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/map-plate/map-plate.component.mjs +4 -1
- package/dist/esm2022/map/messages/commands/add-control.command.mjs +13 -0
- package/dist/esm2022/map/messages/commands/remove-control.command.mjs +13 -0
- package/dist/esm2022/map/messages/commands/set-map-center.command.mjs +26 -0
- package/dist/esm2022/map/messages/index.mjs +4 -1
- package/dist/esm2022/map/models/index.mjs +2 -1
- package/dist/esm2022/map/models/map-control.mjs +15 -0
- package/dist/esm2022/map/services/controls/controls.service.mjs +39 -0
- package/dist/esm2022/map/services/map-state.service.mjs +19 -4
- package/dist/esm2022/map/services/message-registrator.service.mjs +12 -5
- package/dist/esm2022/src/map/map-plate/map-plate.component.mjs +4 -1
- package/dist/esm2022/src/map/messages/commands/add-control.command.mjs +13 -0
- package/dist/esm2022/src/map/messages/commands/remove-control.command.mjs +13 -0
- package/dist/esm2022/src/map/messages/commands/set-map-center.command.mjs +26 -0
- package/dist/esm2022/src/map/messages/index.mjs +4 -1
- package/dist/esm2022/src/map/models/index.mjs +2 -1
- package/dist/esm2022/src/map/models/map-control.mjs +15 -0
- package/dist/esm2022/src/map/services/controls/controls.service.mjs +39 -0
- package/dist/esm2022/src/map/services/map-state.service.mjs +19 -4
- package/dist/esm2022/src/map/services/message-registrator.service.mjs +12 -5
- package/dist/fesm2022/maps-components-src-map.mjs +123 -7
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +123 -7
- package/dist/fesm2022/maps-components.mjs.map +1 -1
- package/dist/map/messages/commands/add-control.command.d.ts +8 -0
- package/dist/map/messages/commands/remove-control.command.d.ts +8 -0
- package/dist/map/messages/commands/set-map-center.command.d.ts +18 -0
- package/dist/map/messages/index.d.ts +3 -0
- package/dist/map/models/index.d.ts +1 -0
- package/dist/map/models/map-control.d.ts +13 -0
- package/dist/map/services/controls/controls.service.d.ts +14 -0
- package/dist/map/services/map-state.service.d.ts +2 -0
- package/dist/map/services/message-registrator.service.d.ts +2 -1
- package/dist/src/map/messages/commands/add-control.command.d.ts +8 -0
- package/dist/src/map/messages/commands/remove-control.command.d.ts +8 -0
- package/dist/src/map/messages/commands/set-map-center.command.d.ts +18 -0
- package/dist/src/map/messages/index.d.ts +3 -0
- package/dist/src/map/models/index.d.ts +1 -0
- package/dist/src/map/models/map-control.d.ts +13 -0
- package/dist/src/map/services/controls/controls.service.d.ts +14 -0
- package/dist/src/map/services/map-state.service.d.ts +2 -0
- package/dist/src/map/services/message-registrator.service.d.ts +2 -1
- package/package.json +1 -1
|
@@ -6,11 +6,11 @@ import { Feature, Collection } from 'ol';
|
|
|
6
6
|
import { Point, LineString } from 'ol/geom';
|
|
7
7
|
import { GeoJSON, WKT } from 'ol/format';
|
|
8
8
|
import { getCenter, createEmpty, extend } from 'ol/extent';
|
|
9
|
+
import { Control, Zoom } from 'ol/control';
|
|
9
10
|
import { get, useGeographic, transform } from 'ol/proj';
|
|
10
11
|
import { PostboyGenericMessage, PostboyCallbackMessage, PostboyExecutor, PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
11
12
|
import { Draw, Modify, Translate } from 'ol/interaction';
|
|
12
13
|
import { createRegularPolygon, createBox } from 'ol/interaction/Draw';
|
|
13
|
-
import { Zoom } from 'ol/control';
|
|
14
14
|
import { first, filter, auditTime } from 'rxjs/operators';
|
|
15
15
|
import { Vector, XYZ } from 'ol/source';
|
|
16
16
|
import TileLayer from 'ol/layer/Tile';
|
|
@@ -251,6 +251,20 @@ class Dictionary {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
*
|
|
256
|
+
* A control is a visible widget with a DOM element in a fixed position on the screen. They can involve user input (buttons), or be informational only; the position is determined using CSS. By default these are placed in the container with CSS class name ol-overlaycontainer-stopevent, but can use any outside DOM element.
|
|
257
|
+
* This is the base class for controls. You can use it for simple custom controls by creating the element with listeners, creating an instance:
|
|
258
|
+
* var myControl = new Control({element: myElement}); and then adding this to the map.
|
|
259
|
+
* The main advantage of having this as a control rather than a simple separate DOM element is that preventing propagation is handled for you. Controls will also be objects in a module:ol/Collection~Collection, so you can use their methods.
|
|
260
|
+
* You can also extend this base for your own control class. See examples/custom-controls for an example of how to do this.
|
|
261
|
+
*/
|
|
262
|
+
class MapControl extends Control {
|
|
263
|
+
constructor(options) {
|
|
264
|
+
super(options);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
254
268
|
class MapRenderedEvent extends PostboyGenericMessage {
|
|
255
269
|
map;
|
|
256
270
|
static ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
|
|
@@ -367,6 +381,55 @@ class CancelFeatureModificationCommand extends PostboyGenericMessage {
|
|
|
367
381
|
}
|
|
368
382
|
}
|
|
369
383
|
|
|
384
|
+
class AddControlCommand extends PostboyGenericMessage {
|
|
385
|
+
item;
|
|
386
|
+
static ID = '8e1c06eb-b395-4fe1-929c-ebf0805eeb49';
|
|
387
|
+
constructor(item) {
|
|
388
|
+
super();
|
|
389
|
+
this.item = item;
|
|
390
|
+
}
|
|
391
|
+
get id() {
|
|
392
|
+
return AddControlCommand.ID;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
class RemoveControlCommand extends PostboyGenericMessage {
|
|
397
|
+
item;
|
|
398
|
+
static ID = '361641e0-804a-4930-8c27-0cea6330dbfc';
|
|
399
|
+
constructor(item) {
|
|
400
|
+
super();
|
|
401
|
+
this.item = item;
|
|
402
|
+
}
|
|
403
|
+
get id() {
|
|
404
|
+
return RemoveControlCommand.ID;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Forces map to move to a specific point
|
|
410
|
+
*/
|
|
411
|
+
class SetMapCenterCommand extends PostboyGenericMessage {
|
|
412
|
+
lat;
|
|
413
|
+
lng;
|
|
414
|
+
zoom;
|
|
415
|
+
static ID = 'd50e89c9-6707-4f8c-ab57-65fcef232182';
|
|
416
|
+
/**
|
|
417
|
+
*
|
|
418
|
+
* @param lat - the desired latitude
|
|
419
|
+
* @param lng - the desired longitude
|
|
420
|
+
* @param zoom - the desired zoom; doesn't change zoom if undefined
|
|
421
|
+
*/
|
|
422
|
+
constructor(lat, lng, zoom) {
|
|
423
|
+
super();
|
|
424
|
+
this.lat = lat;
|
|
425
|
+
this.lng = lng;
|
|
426
|
+
this.zoom = zoom;
|
|
427
|
+
}
|
|
428
|
+
get id() {
|
|
429
|
+
return SetMapCenterCommand.ID;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
370
433
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
371
434
|
layer;
|
|
372
435
|
static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
|
|
@@ -679,7 +742,14 @@ class MapStateService {
|
|
|
679
742
|
this.postboy = postboy;
|
|
680
743
|
}
|
|
681
744
|
up() {
|
|
682
|
-
this.
|
|
745
|
+
this.observeMapRendering();
|
|
746
|
+
this.observeCenter();
|
|
747
|
+
}
|
|
748
|
+
observeMapRendering() {
|
|
749
|
+
this.postboy
|
|
750
|
+
.subscribe(MapRenderedEvent.ID)
|
|
751
|
+
.pipe(first())
|
|
752
|
+
.subscribe((ev) => {
|
|
683
753
|
this.map = ev.map;
|
|
684
754
|
this.map?.on('moveend', () => {
|
|
685
755
|
const zoom = Math.floor(this.map?.getView().getZoom() || -1);
|
|
@@ -688,6 +758,13 @@ class MapStateService {
|
|
|
688
758
|
});
|
|
689
759
|
});
|
|
690
760
|
}
|
|
761
|
+
observeCenter() {
|
|
762
|
+
this.postboy.subscribe(SetMapCenterCommand.ID).subscribe((c) => {
|
|
763
|
+
this.map?.getView().setCenter([c.lng, c.lat]);
|
|
764
|
+
if (c.zoom)
|
|
765
|
+
this.map?.getView().setZoom(c.zoom);
|
|
766
|
+
});
|
|
767
|
+
}
|
|
691
768
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
692
769
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapStateService });
|
|
693
770
|
}
|
|
@@ -953,14 +1030,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
953
1030
|
type: Injectable
|
|
954
1031
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
955
1032
|
|
|
1033
|
+
class ControlsService {
|
|
1034
|
+
postboy;
|
|
1035
|
+
map;
|
|
1036
|
+
constructor(postboy) {
|
|
1037
|
+
this.postboy = postboy;
|
|
1038
|
+
}
|
|
1039
|
+
up() {
|
|
1040
|
+
this.observeMapRender();
|
|
1041
|
+
}
|
|
1042
|
+
observeMapRender() {
|
|
1043
|
+
this.postboy
|
|
1044
|
+
.subscribe(MapRenderedEvent.ID)
|
|
1045
|
+
.pipe(first())
|
|
1046
|
+
.subscribe((m) => {
|
|
1047
|
+
this.map = m.map;
|
|
1048
|
+
this.observeAdding();
|
|
1049
|
+
this.observeRemoving();
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
observeAdding() {
|
|
1053
|
+
this.postboy.subscribe(AddControlCommand.ID).subscribe((c) => this.map?.addControl(c.item));
|
|
1054
|
+
}
|
|
1055
|
+
observeRemoving() {
|
|
1056
|
+
this.postboy
|
|
1057
|
+
.subscribe(RemoveControlCommand.ID)
|
|
1058
|
+
.subscribe((c) => this.map?.removeControl(c.item));
|
|
1059
|
+
}
|
|
1060
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ControlsService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1061
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ControlsService });
|
|
1062
|
+
}
|
|
1063
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ControlsService, decorators: [{
|
|
1064
|
+
type: Injectable
|
|
1065
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
1066
|
+
|
|
956
1067
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
957
|
-
constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
|
|
1068
|
+
constructor(service, management, state, mapFeature, interaction, drawing, featureModification, controls) {
|
|
958
1069
|
super(service);
|
|
959
|
-
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
|
|
1070
|
+
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification, controls]);
|
|
960
1071
|
}
|
|
961
1072
|
_up() {
|
|
962
1073
|
this.registerReplay(MapRenderedEvent.ID);
|
|
963
1074
|
this.registerReplay(PlaceLayerFeaturesCommand.ID);
|
|
1075
|
+
this.registerReplay(RemoveControlCommand.ID);
|
|
1076
|
+
this.registerReplay(AddControlCommand.ID);
|
|
1077
|
+
this.registerReplay(SetMapCenterCommand.ID);
|
|
964
1078
|
this.registerSubject(AddLayerCommand.ID);
|
|
965
1079
|
this.registerSubject(RemoveLayerCommand.ID);
|
|
966
1080
|
this.registerSubject(AddTileCommand.ID);
|
|
@@ -984,12 +1098,12 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
984
1098
|
this.registerExecutor(GenerateDrawExecutor.ID, (e) => DrawingGenerationService.getDraw(e));
|
|
985
1099
|
this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
|
|
986
1100
|
}
|
|
987
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: FeatureModificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1101
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", 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 });
|
|
988
1102
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService });
|
|
989
1103
|
}
|
|
990
1104
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
991
1105
|
type: Injectable
|
|
992
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
|
|
1106
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }, { type: ControlsService }]; } });
|
|
993
1107
|
|
|
994
1108
|
class TileLayerSettings {
|
|
995
1109
|
maxZoom = 19;
|
|
@@ -1603,6 +1717,7 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
1603
1717
|
DrawingGenerationService,
|
|
1604
1718
|
FeatureService,
|
|
1605
1719
|
FeatureModificationService,
|
|
1720
|
+
ControlsService,
|
|
1606
1721
|
], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\r\n<art-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></art-osm-tile-layer>\r\n<art-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></art-feature-layer>\r\n", styles: ["art-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "art-osm-tile-layer", inputs: ["url", "map"] }, { kind: "component", type: FeatureLayerComponent, selector: "art-feature-layer", inputs: ["settings"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1607
1722
|
}
|
|
1608
1723
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
@@ -1617,6 +1732,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1617
1732
|
DrawingGenerationService,
|
|
1618
1733
|
FeatureService,
|
|
1619
1734
|
FeatureModificationService,
|
|
1735
|
+
ControlsService,
|
|
1620
1736
|
], template: "<ng-content></ng-content>\r\n<art-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></art-osm-tile-layer>\r\n<art-feature-layer *ngIf=\"map\" [settings]=\"drawingLayerSettings\"></art-feature-layer>\r\n", styles: ["art-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"] }]
|
|
1621
1737
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
1622
1738
|
type: Input
|
|
@@ -2067,5 +2183,5 @@ class StringifyFeatureHelper {
|
|
|
2067
2183
|
* Generated bundle index. Do not edit.
|
|
2068
2184
|
*/
|
|
2069
2185
|
|
|
2070
|
-
export { CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
|
|
2186
|
+
export { AddControlCommand, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, MapClickEvent, 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 };
|
|
2071
2187
|
//# sourceMappingURL=maps-components.mjs.map
|