@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';
|
|
@@ -166,11 +166,13 @@ class PolygonModel {
|
|
|
166
166
|
return new PolygonModel(feature, id, info);
|
|
167
167
|
}
|
|
168
168
|
constructor(feature, id, info) {
|
|
169
|
-
var _a;
|
|
169
|
+
var _a, _b;
|
|
170
170
|
this.info = info;
|
|
171
171
|
this.id = id == null ? IdGenerator.get() : id;
|
|
172
172
|
this._feature = feature;
|
|
173
|
-
|
|
173
|
+
if (this.info)
|
|
174
|
+
(_a = this._feature) === null || _a === void 0 ? void 0 : _a.set(MapConstants.FeatureInfo, this.info);
|
|
175
|
+
[this.lng, this.lat] = getCenter((_b = this._feature.getGeometry()) === null || _b === void 0 ? void 0 : _b.getExtent());
|
|
174
176
|
}
|
|
175
177
|
get feature() {
|
|
176
178
|
return this._feature;
|
|
@@ -247,6 +249,20 @@ class Dictionary {
|
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
|
|
252
|
+
/**
|
|
253
|
+
*
|
|
254
|
+
* 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.
|
|
255
|
+
* This is the base class for controls. You can use it for simple custom controls by creating the element with listeners, creating an instance:
|
|
256
|
+
* var myControl = new Control({element: myElement}); and then adding this to the map.
|
|
257
|
+
* 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.
|
|
258
|
+
* You can also extend this base for your own control class. See examples/custom-controls for an example of how to do this.
|
|
259
|
+
*/
|
|
260
|
+
class MapControl extends Control {
|
|
261
|
+
constructor(options) {
|
|
262
|
+
super(options);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
250
266
|
class MapRenderedEvent extends PostboyGenericMessage {
|
|
251
267
|
constructor(map) {
|
|
252
268
|
super();
|
|
@@ -347,6 +363,50 @@ class CancelFeatureModificationCommand extends PostboyGenericMessage {
|
|
|
347
363
|
}
|
|
348
364
|
CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
|
|
349
365
|
|
|
366
|
+
class AddControlCommand extends PostboyGenericMessage {
|
|
367
|
+
constructor(item) {
|
|
368
|
+
super();
|
|
369
|
+
this.item = item;
|
|
370
|
+
}
|
|
371
|
+
get id() {
|
|
372
|
+
return AddControlCommand.ID;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
AddControlCommand.ID = '8e1c06eb-b395-4fe1-929c-ebf0805eeb49';
|
|
376
|
+
|
|
377
|
+
class RemoveControlCommand extends PostboyGenericMessage {
|
|
378
|
+
constructor(item) {
|
|
379
|
+
super();
|
|
380
|
+
this.item = item;
|
|
381
|
+
}
|
|
382
|
+
get id() {
|
|
383
|
+
return RemoveControlCommand.ID;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
RemoveControlCommand.ID = '361641e0-804a-4930-8c27-0cea6330dbfc';
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Forces map to move to a specific point
|
|
390
|
+
*/
|
|
391
|
+
class SetMapCenterCommand extends PostboyGenericMessage {
|
|
392
|
+
/**
|
|
393
|
+
*
|
|
394
|
+
* @param lat - the desired latitude
|
|
395
|
+
* @param lng - the desired longitude
|
|
396
|
+
* @param zoom - the desired zoom; doesn't change zoom if undefined
|
|
397
|
+
*/
|
|
398
|
+
constructor(lat, lng, zoom) {
|
|
399
|
+
super();
|
|
400
|
+
this.lat = lat;
|
|
401
|
+
this.lng = lng;
|
|
402
|
+
this.zoom = zoom;
|
|
403
|
+
}
|
|
404
|
+
get id() {
|
|
405
|
+
return SetMapCenterCommand.ID;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
SetMapCenterCommand.ID = 'd50e89c9-6707-4f8c-ab57-65fcef232182';
|
|
409
|
+
|
|
350
410
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
351
411
|
constructor(layer) {
|
|
352
412
|
super();
|
|
@@ -640,7 +700,14 @@ class MapStateService {
|
|
|
640
700
|
this.postboy = postboy;
|
|
641
701
|
}
|
|
642
702
|
up() {
|
|
643
|
-
this.
|
|
703
|
+
this.observeMapRendering();
|
|
704
|
+
this.observeCenter();
|
|
705
|
+
}
|
|
706
|
+
observeMapRendering() {
|
|
707
|
+
this.postboy
|
|
708
|
+
.subscribe(MapRenderedEvent.ID)
|
|
709
|
+
.pipe(first())
|
|
710
|
+
.subscribe((ev) => {
|
|
644
711
|
var _a;
|
|
645
712
|
this.map = ev.map;
|
|
646
713
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.on('moveend', () => {
|
|
@@ -651,6 +718,14 @@ class MapStateService {
|
|
|
651
718
|
});
|
|
652
719
|
});
|
|
653
720
|
}
|
|
721
|
+
observeCenter() {
|
|
722
|
+
this.postboy.subscribe(SetMapCenterCommand.ID).subscribe((c) => {
|
|
723
|
+
var _a, _b;
|
|
724
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.getView().setCenter([c.lng, c.lat]);
|
|
725
|
+
if (c.zoom)
|
|
726
|
+
(_b = this.map) === null || _b === void 0 ? void 0 : _b.getView().setZoom(c.zoom);
|
|
727
|
+
});
|
|
728
|
+
}
|
|
654
729
|
}
|
|
655
730
|
MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
656
731
|
MapStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService });
|
|
@@ -914,14 +989,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
914
989
|
type: Injectable
|
|
915
990
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
916
991
|
|
|
992
|
+
class ControlsService {
|
|
993
|
+
constructor(postboy) {
|
|
994
|
+
this.postboy = postboy;
|
|
995
|
+
}
|
|
996
|
+
up() {
|
|
997
|
+
this.observeMapRender();
|
|
998
|
+
}
|
|
999
|
+
observeMapRender() {
|
|
1000
|
+
this.postboy
|
|
1001
|
+
.subscribe(MapRenderedEvent.ID)
|
|
1002
|
+
.pipe(first())
|
|
1003
|
+
.subscribe((m) => {
|
|
1004
|
+
this.map = m.map;
|
|
1005
|
+
this.observeAdding();
|
|
1006
|
+
this.observeRemoving();
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
observeAdding() {
|
|
1010
|
+
this.postboy.subscribe(AddControlCommand.ID).subscribe((c) => { var _a; return (_a = this.map) === null || _a === void 0 ? void 0 : _a.addControl(c.item); });
|
|
1011
|
+
}
|
|
1012
|
+
observeRemoving() {
|
|
1013
|
+
this.postboy
|
|
1014
|
+
.subscribe(RemoveControlCommand.ID)
|
|
1015
|
+
.subscribe((c) => { var _a; return (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeControl(c.item); });
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
ControlsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1019
|
+
ControlsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService });
|
|
1020
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ControlsService, decorators: [{
|
|
1021
|
+
type: Injectable
|
|
1022
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
1023
|
+
|
|
917
1024
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
918
|
-
constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
|
|
1025
|
+
constructor(service, management, state, mapFeature, interaction, drawing, featureModification, controls) {
|
|
919
1026
|
super(service);
|
|
920
|
-
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
|
|
1027
|
+
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification, controls]);
|
|
921
1028
|
}
|
|
922
1029
|
_up() {
|
|
923
1030
|
this.registerReplay(MapRenderedEvent.ID);
|
|
924
1031
|
this.registerReplay(PlaceLayerFeaturesCommand.ID);
|
|
1032
|
+
this.registerReplay(RemoveControlCommand.ID);
|
|
1033
|
+
this.registerReplay(AddControlCommand.ID);
|
|
1034
|
+
this.registerReplay(SetMapCenterCommand.ID);
|
|
925
1035
|
this.registerSubject(AddLayerCommand.ID);
|
|
926
1036
|
this.registerSubject(RemoveLayerCommand.ID);
|
|
927
1037
|
this.registerSubject(AddTileCommand.ID);
|
|
@@ -946,11 +1056,11 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
946
1056
|
this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
|
|
947
1057
|
}
|
|
948
1058
|
}
|
|
949
|
-
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 });
|
|
1059
|
+
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 });
|
|
950
1060
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
951
1061
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
952
1062
|
type: Injectable
|
|
953
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
|
|
1063
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }, { type: ControlsService }]; } });
|
|
954
1064
|
|
|
955
1065
|
class TileLayerSettings {
|
|
956
1066
|
constructor() {
|
|
@@ -1553,6 +1663,7 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
|
|
|
1553
1663
|
DrawingGenerationService,
|
|
1554
1664
|
FeatureService,
|
|
1555
1665
|
FeatureModificationService,
|
|
1666
|
+
ControlsService,
|
|
1556
1667
|
], 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 });
|
|
1557
1668
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
1558
1669
|
type: Component,
|
|
@@ -1566,6 +1677,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
1566
1677
|
DrawingGenerationService,
|
|
1567
1678
|
FeatureService,
|
|
1568
1679
|
FeatureModificationService,
|
|
1680
|
+
ControlsService,
|
|
1569
1681
|
], 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"] }]
|
|
1570
1682
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
1571
1683
|
type: Input
|
|
@@ -2010,5 +2122,5 @@ class StringifyFeatureHelper {
|
|
|
2010
2122
|
* Generated bundle index. Do not edit.
|
|
2011
2123
|
*/
|
|
2012
2124
|
|
|
2013
|
-
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 };
|
|
2125
|
+
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 };
|
|
2014
2126
|
//# sourceMappingURL=maps-components.mjs.map
|