@artstesh/maps 1.1.2 → 1.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/bundles/maps-components-src-map.umd.js +151 -9
- package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
- package/dist/bundles/maps-components.umd.js +151 -9
- package/dist/bundles/maps-components.umd.js.map +1 -1
- package/dist/esm2015/map/map-plate/map-plate.component.js +4 -1
- package/dist/esm2015/map/messages/commands/add-control.command.js +12 -0
- package/dist/esm2015/map/messages/commands/remove-control.command.js +12 -0
- package/dist/esm2015/map/messages/commands/set-map-center.command.js +23 -0
- package/dist/esm2015/map/messages/index.js +4 -1
- package/dist/esm2015/map/models/index.js +2 -1
- package/dist/esm2015/map/models/map-control.js +15 -0
- package/dist/esm2015/map/services/controls/controls.service.js +37 -0
- package/dist/esm2015/map/services/map-state.service.js +20 -4
- package/dist/esm2015/map/services/message-registrator.service.js +12 -5
- package/dist/esm2015/src/map/map-plate/map-plate.component.js +4 -1
- package/dist/esm2015/src/map/messages/commands/add-control.command.js +12 -0
- package/dist/esm2015/src/map/messages/commands/remove-control.command.js +12 -0
- package/dist/esm2015/src/map/messages/commands/set-map-center.command.js +23 -0
- package/dist/esm2015/src/map/messages/index.js +4 -1
- package/dist/esm2015/src/map/models/index.js +2 -1
- package/dist/esm2015/src/map/models/map-control.js +15 -0
- package/dist/esm2015/src/map/services/controls/controls.service.js +37 -0
- package/dist/esm2015/src/map/services/map-state.service.js +20 -4
- package/dist/esm2015/src/map/services/message-registrator.service.js +12 -5
- package/dist/fesm2015/maps-components-src-map.js +117 -7
- package/dist/fesm2015/maps-components-src-map.js.map +1 -1
- package/dist/fesm2015/maps-components.js +117 -7
- package/dist/fesm2015/maps-components.js.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';
|
|
@@ -247,6 +247,20 @@ class Dictionary {
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
* 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.
|
|
253
|
+
* This is the base class for controls. You can use it for simple custom controls by creating the element with listeners, creating an instance:
|
|
254
|
+
* var myControl = new Control({element: myElement}); and then adding this to the map.
|
|
255
|
+
* 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.
|
|
256
|
+
* You can also extend this base for your own control class. See examples/custom-controls for an example of how to do this.
|
|
257
|
+
*/
|
|
258
|
+
class MapControl extends Control {
|
|
259
|
+
constructor(options) {
|
|
260
|
+
super(options);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
250
264
|
class MapRenderedEvent extends PostboyGenericMessage {
|
|
251
265
|
constructor(map) {
|
|
252
266
|
super();
|
|
@@ -347,6 +361,50 @@ class CancelFeatureModificationCommand extends PostboyGenericMessage {
|
|
|
347
361
|
}
|
|
348
362
|
CancelFeatureModificationCommand.ID = '9c9fb40f-ea95-4704-8177-0e9ecabf36fa';
|
|
349
363
|
|
|
364
|
+
class AddControlCommand extends PostboyGenericMessage {
|
|
365
|
+
constructor(item) {
|
|
366
|
+
super();
|
|
367
|
+
this.item = item;
|
|
368
|
+
}
|
|
369
|
+
get id() {
|
|
370
|
+
return AddControlCommand.ID;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
AddControlCommand.ID = '8e1c06eb-b395-4fe1-929c-ebf0805eeb49';
|
|
374
|
+
|
|
375
|
+
class RemoveControlCommand extends PostboyGenericMessage {
|
|
376
|
+
constructor(item) {
|
|
377
|
+
super();
|
|
378
|
+
this.item = item;
|
|
379
|
+
}
|
|
380
|
+
get id() {
|
|
381
|
+
return RemoveControlCommand.ID;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
RemoveControlCommand.ID = '361641e0-804a-4930-8c27-0cea6330dbfc';
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Forces map to move to a specific point
|
|
388
|
+
*/
|
|
389
|
+
class SetMapCenterCommand extends PostboyGenericMessage {
|
|
390
|
+
/**
|
|
391
|
+
*
|
|
392
|
+
* @param lat - the desired latitude
|
|
393
|
+
* @param lng - the desired longitude
|
|
394
|
+
* @param zoom - the desired zoom; doesn't change zoom if undefined
|
|
395
|
+
*/
|
|
396
|
+
constructor(lat, lng, zoom) {
|
|
397
|
+
super();
|
|
398
|
+
this.lat = lat;
|
|
399
|
+
this.lng = lng;
|
|
400
|
+
this.zoom = zoom;
|
|
401
|
+
}
|
|
402
|
+
get id() {
|
|
403
|
+
return SetMapCenterCommand.ID;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
SetMapCenterCommand.ID = 'd50e89c9-6707-4f8c-ab57-65fcef232182';
|
|
407
|
+
|
|
350
408
|
class AddLayerCommand extends PostboyGenericMessage {
|
|
351
409
|
constructor(layer) {
|
|
352
410
|
super();
|
|
@@ -640,7 +698,14 @@ class MapStateService {
|
|
|
640
698
|
this.postboy = postboy;
|
|
641
699
|
}
|
|
642
700
|
up() {
|
|
643
|
-
this.
|
|
701
|
+
this.observeMapRendering();
|
|
702
|
+
this.observeCenter();
|
|
703
|
+
}
|
|
704
|
+
observeMapRendering() {
|
|
705
|
+
this.postboy
|
|
706
|
+
.subscribe(MapRenderedEvent.ID)
|
|
707
|
+
.pipe(first())
|
|
708
|
+
.subscribe((ev) => {
|
|
644
709
|
var _a;
|
|
645
710
|
this.map = ev.map;
|
|
646
711
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.on('moveend', () => {
|
|
@@ -651,6 +716,14 @@ class MapStateService {
|
|
|
651
716
|
});
|
|
652
717
|
});
|
|
653
718
|
}
|
|
719
|
+
observeCenter() {
|
|
720
|
+
this.postboy.subscribe(SetMapCenterCommand.ID).subscribe((c) => {
|
|
721
|
+
var _a, _b;
|
|
722
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.getView().setCenter([c.lng, c.lat]);
|
|
723
|
+
if (c.zoom)
|
|
724
|
+
(_b = this.map) === null || _b === void 0 ? void 0 : _b.getView().setZoom(c.zoom);
|
|
725
|
+
});
|
|
726
|
+
}
|
|
654
727
|
}
|
|
655
728
|
MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
656
729
|
MapStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapStateService });
|
|
@@ -914,14 +987,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
914
987
|
type: Injectable
|
|
915
988
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
916
989
|
|
|
990
|
+
class ControlsService {
|
|
991
|
+
constructor(postboy) {
|
|
992
|
+
this.postboy = postboy;
|
|
993
|
+
}
|
|
994
|
+
up() {
|
|
995
|
+
this.observeMapRender();
|
|
996
|
+
}
|
|
997
|
+
observeMapRender() {
|
|
998
|
+
this.postboy
|
|
999
|
+
.subscribe(MapRenderedEvent.ID)
|
|
1000
|
+
.pipe(first())
|
|
1001
|
+
.subscribe((m) => {
|
|
1002
|
+
this.map = m.map;
|
|
1003
|
+
this.observeAdding();
|
|
1004
|
+
this.observeRemoving();
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
observeAdding() {
|
|
1008
|
+
this.postboy.subscribe(AddControlCommand.ID).subscribe((c) => { var _a; return (_a = this.map) === null || _a === void 0 ? void 0 : _a.addControl(c.item); });
|
|
1009
|
+
}
|
|
1010
|
+
observeRemoving() {
|
|
1011
|
+
this.postboy
|
|
1012
|
+
.subscribe(RemoveControlCommand.ID)
|
|
1013
|
+
.subscribe((c) => { var _a; return (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeControl(c.item); });
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
ControlsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ControlsService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1017
|
+
ControlsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ControlsService });
|
|
1018
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ControlsService, decorators: [{
|
|
1019
|
+
type: Injectable
|
|
1020
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
1021
|
+
|
|
917
1022
|
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
918
|
-
constructor(service, management, state, mapFeature, interaction, drawing, featureModification) {
|
|
1023
|
+
constructor(service, management, state, mapFeature, interaction, drawing, featureModification, controls) {
|
|
919
1024
|
super(service);
|
|
920
|
-
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification]);
|
|
1025
|
+
this.registerServices([management, state, interaction, mapFeature, drawing, featureModification, controls]);
|
|
921
1026
|
}
|
|
922
1027
|
_up() {
|
|
923
1028
|
this.registerReplay(MapRenderedEvent.ID);
|
|
924
1029
|
this.registerReplay(PlaceLayerFeaturesCommand.ID);
|
|
1030
|
+
this.registerReplay(RemoveControlCommand.ID);
|
|
1031
|
+
this.registerReplay(AddControlCommand.ID);
|
|
1032
|
+
this.registerReplay(SetMapCenterCommand.ID);
|
|
925
1033
|
this.registerSubject(AddLayerCommand.ID);
|
|
926
1034
|
this.registerSubject(RemoveLayerCommand.ID);
|
|
927
1035
|
this.registerSubject(AddTileCommand.ID);
|
|
@@ -946,11 +1054,11 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
946
1054
|
this.registerExecutor(GenerateZoomControlExecutor.ID, (e) => ZoomControlFactory.build(e.settings));
|
|
947
1055
|
}
|
|
948
1056
|
}
|
|
949
|
-
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapFeatureService }, { token: MapClickService }, { token: DrawingService }, { token: FeatureModificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1057
|
+
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", 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
1058
|
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService });
|
|
951
1059
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
952
1060
|
type: Injectable
|
|
953
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }]; } });
|
|
1061
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapFeatureService }, { type: MapClickService }, { type: DrawingService }, { type: FeatureModificationService }, { type: ControlsService }]; } });
|
|
954
1062
|
|
|
955
1063
|
class TileLayerSettings {
|
|
956
1064
|
constructor() {
|
|
@@ -1573,6 +1681,7 @@ MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
|
|
|
1573
1681
|
DrawingGenerationService,
|
|
1574
1682
|
FeatureService,
|
|
1575
1683
|
FeatureModificationService,
|
|
1684
|
+
ControlsService,
|
|
1576
1685
|
], 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"], components: [{ type: OsmTileLayerComponent, selector: "art-osm-tile-layer", inputs: ["url", "map"] }, { type: FeatureLayerComponent, selector: "art-feature-layer", inputs: ["settings"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1577
1686
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
1578
1687
|
type: Component,
|
|
@@ -1591,6 +1700,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
1591
1700
|
DrawingGenerationService,
|
|
1592
1701
|
FeatureService,
|
|
1593
1702
|
FeatureModificationService,
|
|
1703
|
+
ControlsService,
|
|
1594
1704
|
],
|
|
1595
1705
|
}]
|
|
1596
1706
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
@@ -2056,5 +2166,5 @@ class StringifyFeatureHelper {
|
|
|
2056
2166
|
* Generated bundle index. Do not edit.
|
|
2057
2167
|
*/
|
|
2058
2168
|
|
|
2059
|
-
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 };
|
|
2169
|
+
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 };
|
|
2060
2170
|
//# sourceMappingURL=maps-components.js.map
|