@artstesh/maps 4.1.2 → 4.1.4
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/esm2020/map/map-plate/map-plate.component.mjs +4 -1
- package/dist/esm2020/map/messages/commands/add-control.command.mjs +12 -0
- package/dist/esm2020/map/messages/commands/remove-control.command.mjs +12 -0
- package/dist/esm2020/map/messages/commands/set-map-center.command.mjs +23 -0
- package/dist/esm2020/map/messages/index.mjs +4 -1
- package/dist/esm2020/map/models/index.mjs +2 -1
- package/dist/esm2020/map/models/map-control.mjs +15 -0
- package/dist/esm2020/map/models/polygon.model.mjs +4 -1
- package/dist/esm2020/map/services/controls/controls.service.mjs +37 -0
- package/dist/esm2020/map/services/map-state.service.mjs +19 -4
- package/dist/esm2020/map/services/message-registrator.service.mjs +12 -5
- package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +4 -1
- package/dist/esm2020/src/map/messages/commands/add-control.command.mjs +12 -0
- package/dist/esm2020/src/map/messages/commands/remove-control.command.mjs +12 -0
- package/dist/esm2020/src/map/messages/commands/set-map-center.command.mjs +23 -0
- package/dist/esm2020/src/map/messages/index.mjs +4 -1
- package/dist/esm2020/src/map/models/index.mjs +2 -1
- package/dist/esm2020/src/map/models/map-control.mjs +15 -0
- package/dist/esm2020/src/map/models/polygon.model.mjs +4 -1
- package/dist/esm2020/src/map/services/controls/controls.service.mjs +37 -0
- package/dist/esm2020/src/map/services/map-state.service.mjs +19 -4
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +12 -5
- package/dist/fesm2015/maps-components-src-map.mjs +121 -9
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +121 -9
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +118 -7
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +118 -7
- package/dist/fesm2020/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';
|
|
@@ -169,6 +169,8 @@ class PolygonModel {
|
|
|
169
169
|
this.info = info;
|
|
170
170
|
this.id = id == null ? IdGenerator.get() : id;
|
|
171
171
|
this._feature = feature;
|
|
172
|
+
if (this.info)
|
|
173
|
+
this._feature?.set(MapConstants.FeatureInfo, this.info);
|
|
172
174
|
[this.lng, this.lat] = getCenter(this._feature.getGeometry()?.getExtent());
|
|
173
175
|
}
|
|
174
176
|
get feature() {
|
|
@@ -246,6 +248,20 @@ class Dictionary {
|
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
|
|
251
|
+
/**
|
|
252
|
+
*
|
|
253
|
+
* 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.
|
|
254
|
+
* This is the base class for controls. You can use it for simple custom controls by creating the element with listeners, creating an instance:
|
|
255
|
+
* var myControl = new Control({element: myElement}); and then adding this to the map.
|
|
256
|
+
* 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.
|
|
257
|
+
* You can also extend this base for your own control class. See examples/custom-controls for an example of how to do this.
|
|
258
|
+
*/
|
|
259
|
+
class MapControl extends Control {
|
|
260
|
+
constructor(options) {
|
|
261
|
+
super(options);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
249
265
|
class MapRenderedEvent extends PostboyGenericMessage {
|
|
250
266
|
constructor(map) {
|
|
251
267
|
super();
|
|
@@ -346,6 +362,50 @@ class CancelFeatureModificationCommand extends PostboyGenericMessage {
|
|
|
346
362
|
}
|
|
347
363
|
CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
|
|
348
364
|
|
|
365
|
+
class AddControlCommand extends PostboyGenericMessage {
|
|
366
|
+
constructor(item) {
|
|
367
|
+
super();
|
|
368
|
+
this.item = item;
|
|
369
|
+
}
|
|
370
|
+
get id() {
|
|
371
|
+
return AddControlCommand.ID;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
AddControlCommand.ID = '8e1c06eb-b395-4fe1-929c-ebf0805eeb49';
|
|
375
|
+
|
|
376
|
+
class RemoveControlCommand extends PostboyGenericMessage {
|
|
377
|
+
constructor(item) {
|
|
378
|
+
super();
|
|
379
|
+
this.item = item;
|
|
380
|
+
}
|
|
381
|
+
get id() {
|
|
382
|
+
return RemoveControlCommand.ID;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
RemoveControlCommand.ID = '361641e0-804a-4930-8c27-0cea6330dbfc';
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Forces map to move to a specific point
|
|
389
|
+
*/
|
|
390
|
+
class SetMapCenterCommand extends PostboyGenericMessage {
|
|
391
|
+
/**
|
|
392
|
+
*
|
|
393
|
+
* @param lat - the desired latitude
|
|
394
|
+
* @param lng - the desired longitude
|
|
395
|
+
* @param zoom - the desired zoom; doesn't change zoom if undefined
|
|
396
|
+
*/
|
|
397
|
+
constructor(lat, lng, zoom) {
|
|
398
|
+
super();
|
|
399
|
+
this.lat = lat;
|
|
400
|
+
this.lng = lng;
|
|
401
|
+
this.zoom = zoom;
|
|
402
|
+
}
|
|
403
|
+
get id() {
|
|
404
|
+
return SetMapCenterCommand.ID;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
SetMapCenterCommand.ID = 'd50e89c9-6707-4f8c-ab57-65fcef232182';
|
|
408
|
+
|
|
349
409
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
350
410
|
constructor(layer) {
|
|
351
411
|
super();
|
|
@@ -637,7 +697,14 @@ class MapStateService {
|
|
|
637
697
|
this.postboy = postboy;
|
|
638
698
|
}
|
|
639
699
|
up() {
|
|
640
|
-
this.
|
|
700
|
+
this.observeMapRendering();
|
|
701
|
+
this.observeCenter();
|
|
702
|
+
}
|
|
703
|
+
observeMapRendering() {
|
|
704
|
+
this.postboy
|
|
705
|
+
.subscribe(MapRenderedEvent.ID)
|
|
706
|
+
.pipe(first())
|
|
707
|
+
.subscribe((ev) => {
|
|
641
708
|
this.map = ev.map;
|
|
642
709
|
this.map?.on('moveend', () => {
|
|
643
710
|
const zoom = Math.floor(this.map?.getView().getZoom() || -1);
|
|
@@ -646,6 +713,13 @@ class MapStateService {
|
|
|
646
713
|
});
|
|
647
714
|
});
|
|
648
715
|
}
|
|
716
|
+
observeCenter() {
|
|
717
|
+
this.postboy.subscribe(SetMapCenterCommand.ID).subscribe((c) => {
|
|
718
|
+
this.map?.getView().setCenter([c.lng, c.lat]);
|
|
719
|
+
if (c.zoom)
|
|
720
|
+
this.map?.getView().setZoom(c.zoom);
|
|
721
|
+
});
|
|
722
|
+
}
|
|
649
723
|
}
|
|
650
724
|
MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
651
725
|
MapStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService });
|
|
@@ -900,14 +974,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
900
974
|
type: Injectable
|
|
901
975
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
902
976
|
|
|
977
|
+
class ControlsService {
|
|
978
|
+
constructor(postboy) {
|
|
979
|
+
this.postboy = postboy;
|
|
980
|
+
}
|
|
981
|
+
up() {
|
|
982
|
+
this.observeMapRender();
|
|
983
|
+
}
|
|
984
|
+
observeMapRender() {
|
|
985
|
+
this.postboy
|
|
986
|
+
.subscribe(MapRenderedEvent.ID)
|
|
987
|
+
.pipe(first())
|
|
988
|
+
.subscribe((m) => {
|
|
989
|
+
this.map = m.map;
|
|
990
|
+
this.observeAdding();
|
|
991
|
+
this.observeRemoving();
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
observeAdding() {
|
|
995
|
+
this.postboy.subscribe(AddControlCommand.ID).subscribe((c) => this.map?.addControl(c.item));
|
|
996
|
+
}
|
|
997
|
+
observeRemoving() {
|
|
998
|
+
this.postboy
|
|
999
|
+
.subscribe(RemoveControlCommand.ID)
|
|
1000
|
+
.subscribe((c) => this.map?.removeControl(c.item));
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
ControlsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1004
|
+
ControlsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService });
|
|
1005
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService, decorators: [{
|
|
1006
|
+
type: Injectable
|
|
1007
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
1008
|
+
|
|
903
1009
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
904
|
-
constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
|
|
1010
|
+
constructor(service, management, state, mapFeature, interaction, drawing, featureModification, controls) {
|
|
905
1011
|
super(service);
|
|
906
|
-
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
|
|
1012
|
+
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification, controls]);
|
|
907
1013
|
}
|
|
908
1014
|
_up() {
|
|
909
1015
|
this.registerReplay(MapRenderedEvent.ID);
|
|
910
1016
|
this.registerReplay(PlaceLayerFeaturesCommand.ID);
|
|
1017
|
+
this.registerReplay(RemoveControlCommand.ID);
|
|
1018
|
+
this.registerReplay(AddControlCommand.ID);
|
|
1019
|
+
this.registerReplay(SetMapCenterCommand.ID);
|
|
911
1020
|
this.registerSubject(AddLayerCommand.ID);
|
|
912
1021
|
this.registerSubject(RemoveLayerCommand.ID);
|
|
913
1022
|
this.registerSubject(AddTileCommand.ID);
|
|
@@ -932,11 +1041,11 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
932
1041
|
this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
|
|
933
1042
|
}
|
|
934
1043
|
}
|
|
935
|
-
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: FeatureModificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1044
|
+
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", 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 });
|
|
936
1045
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
937
1046
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
938
1047
|
type: Injectable
|
|
939
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
|
|
1048
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }, { type: ControlsService }]; } });
|
|
940
1049
|
|
|
941
1050
|
class TileLayerSettings {
|
|
942
1051
|
constructor() {
|
|
@@ -1534,6 +1643,7 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
|
|
|
1534
1643
|
DrawingGenerationService,
|
|
1535
1644
|
FeatureService,
|
|
1536
1645
|
FeatureModificationService,
|
|
1646
|
+
ControlsService,
|
|
1537
1647
|
], 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 });
|
|
1538
1648
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
1539
1649
|
type: Component,
|
|
@@ -1547,6 +1657,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
1547
1657
|
DrawingGenerationService,
|
|
1548
1658
|
FeatureService,
|
|
1549
1659
|
FeatureModificationService,
|
|
1660
|
+
ControlsService,
|
|
1550
1661
|
], 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"] }]
|
|
1551
1662
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
1552
1663
|
type: Input
|
|
@@ -1984,5 +2095,5 @@ class StringifyFeatureHelper {
|
|
|
1984
2095
|
* Generated bundle index. Do not edit.
|
|
1985
2096
|
*/
|
|
1986
2097
|
|
|
1987
|
-
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 };
|
|
2098
|
+
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 };
|
|
1988
2099
|
//# sourceMappingURL=maps-components-src-map.mjs.map
|