@artstesh/maps 4.0.4 → 4.0.6
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/helpers/index.mjs +2 -1
- package/dist/esm2020/map/helpers/polygon-style.helper.mjs +16 -0
- package/dist/esm2020/map/map-plate/features/index.mjs +2 -1
- package/dist/esm2020/map/map-plate/features/polygons/polygons.component.mjs +41 -0
- package/dist/esm2020/map/map-plate/layers/feature-layer/feature-layer.component.mjs +1 -1
- package/dist/esm2020/map/map-plate/tooltips/index.mjs +3 -0
- package/dist/esm2020/map/map-plate/tooltips/tooltip/tooltip.component.mjs +76 -0
- package/dist/esm2020/map/map-plate/tooltips/tooltip/tooltip.settings.mjs +30 -0
- package/dist/esm2020/map/map.module.mjs +21 -3
- package/dist/esm2020/map/messages/commands/close-tooltip.command.mjs +12 -0
- package/dist/esm2020/map/messages/index.mjs +2 -1
- package/dist/esm2020/map/models/index.mjs +2 -1
- package/dist/esm2020/map/models/polygon.model.mjs +25 -0
- package/dist/esm2020/map/public-api.mjs +2 -1
- package/dist/esm2020/map/services/map-click.service.mjs +2 -2
- package/dist/esm2020/map/services/message-registrator.service.mjs +3 -1
- package/dist/esm2020/src/map/helpers/index.mjs +2 -1
- package/dist/esm2020/src/map/helpers/polygon-style.helper.mjs +16 -0
- package/dist/esm2020/src/map/map-plate/features/index.mjs +2 -1
- package/dist/esm2020/src/map/map-plate/features/polygons/polygons.component.mjs +41 -0
- package/dist/esm2020/src/map/map-plate/layers/feature-layer/feature-layer.component.mjs +1 -1
- package/dist/esm2020/src/map/map-plate/tooltips/index.mjs +3 -0
- package/dist/esm2020/src/map/map-plate/tooltips/tooltip/tooltip.component.mjs +76 -0
- package/dist/esm2020/src/map/map-plate/tooltips/tooltip/tooltip.settings.mjs +30 -0
- package/dist/esm2020/src/map/map.module.mjs +21 -3
- package/dist/esm2020/src/map/messages/commands/close-tooltip.command.mjs +12 -0
- package/dist/esm2020/src/map/messages/index.mjs +2 -1
- package/dist/esm2020/src/map/models/index.mjs +2 -1
- package/dist/esm2020/src/map/models/polygon.model.mjs +25 -0
- package/dist/esm2020/src/map/public-api.mjs +2 -1
- package/dist/esm2020/src/map/services/map-click.service.mjs +2 -2
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +3 -1
- package/dist/fesm2015/maps-components-src-map.mjs +207 -5
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +207 -5
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +202 -5
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +202 -5
- package/dist/fesm2020/maps-components.mjs.map +1 -1
- package/dist/map/helpers/index.d.ts +1 -0
- package/dist/map/helpers/polygon-style.helper.d.ts +4 -0
- package/dist/map/map-plate/features/index.d.ts +1 -0
- package/dist/map/map-plate/features/polygons/polygons.component.d.ts +16 -0
- package/dist/map/map-plate/layers/feature-layer/feature-layer.component.d.ts +1 -1
- package/dist/map/map-plate/tooltips/index.d.ts +2 -0
- package/dist/map/map-plate/tooltips/tooltip/tooltip.component.d.ts +26 -0
- package/dist/map/map-plate/tooltips/tooltip/tooltip.settings.d.ts +11 -0
- package/dist/map/map.module.d.ts +4 -2
- package/dist/map/messages/commands/close-tooltip.command.d.ts +7 -0
- package/dist/map/messages/index.d.ts +1 -0
- package/dist/map/models/index.d.ts +1 -0
- package/dist/map/models/polygon.model.d.ts +19 -0
- package/dist/map/public-api.d.ts +1 -0
- package/dist/src/map/helpers/index.d.ts +1 -0
- package/dist/src/map/helpers/polygon-style.helper.d.ts +4 -0
- package/dist/src/map/map-plate/features/index.d.ts +1 -0
- package/dist/src/map/map-plate/features/polygons/polygons.component.d.ts +16 -0
- package/dist/src/map/map-plate/layers/feature-layer/feature-layer.component.d.ts +1 -1
- package/dist/src/map/map-plate/tooltips/index.d.ts +2 -0
- package/dist/src/map/map-plate/tooltips/tooltip/tooltip.component.d.ts +26 -0
- package/dist/src/map/map-plate/tooltips/tooltip/tooltip.settings.d.ts +11 -0
- package/dist/src/map/map.module.d.ts +4 -2
- package/dist/src/map/messages/commands/close-tooltip.command.d.ts +7 -0
- package/dist/src/map/messages/index.d.ts +1 -0
- package/dist/src/map/models/index.d.ts +1 -0
- package/dist/src/map/models/polygon.model.d.ts +19 -0
- package/dist/src/map/public-api.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, Injectable, ChangeDetectionStrategy, Input, NgModule } from '@angular/core';
|
|
2
|
+
import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgModule } from '@angular/core';
|
|
3
3
|
import * as i4 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { Feature } from 'ol';
|
|
6
6
|
import { Point } from 'ol/geom';
|
|
7
|
+
import { GeoJSON, WKT } from 'ol/format';
|
|
8
|
+
import { getCenter } from 'ol/extent';
|
|
7
9
|
import { useGeographic, get } from 'ol/proj';
|
|
8
10
|
import { Subject } from 'rxjs';
|
|
9
11
|
import { PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
@@ -14,6 +16,7 @@ import OSM from 'ol/source/OSM';
|
|
|
14
16
|
import { filter, first } from 'rxjs/operators';
|
|
15
17
|
import { XYZ, Vector } from 'ol/source';
|
|
16
18
|
import { Vector as Vector$1 } from 'ol/layer';
|
|
19
|
+
import Overlay from 'ol/Overlay';
|
|
17
20
|
import Style from 'ol/style/Style';
|
|
18
21
|
import { Icon, Circle, Fill, Stroke } from 'ol/style';
|
|
19
22
|
|
|
@@ -139,6 +142,28 @@ class MarkerModel {
|
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
|
|
145
|
+
class PolygonModel {
|
|
146
|
+
static fromGeoJson(id, json, info) {
|
|
147
|
+
let feature = new GeoJSON().readFeature(json);
|
|
148
|
+
feature.setId(id);
|
|
149
|
+
return new PolygonModel(feature, id, info);
|
|
150
|
+
}
|
|
151
|
+
static fromWKT(id, wkt, info) {
|
|
152
|
+
let feature = new WKT().readFeature(wkt);
|
|
153
|
+
feature.setId(id);
|
|
154
|
+
return new PolygonModel(feature, id, info);
|
|
155
|
+
}
|
|
156
|
+
constructor(feature, id, info) {
|
|
157
|
+
this.info = info;
|
|
158
|
+
this.id = id == null ? IdGenerator.get() : id;
|
|
159
|
+
this._feature = feature;
|
|
160
|
+
[this.lng, this.lat] = getCenter(this._feature.getGeometry()?.getExtent());
|
|
161
|
+
}
|
|
162
|
+
get feature() {
|
|
163
|
+
return this._feature;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
142
167
|
class GenericMessage {
|
|
143
168
|
}
|
|
144
169
|
class CallbackMessage extends GenericMessage {
|
|
@@ -176,6 +201,17 @@ class MapClickEvent extends GenericMessage {
|
|
|
176
201
|
}
|
|
177
202
|
MapClickEvent.ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
|
|
178
203
|
|
|
204
|
+
class CloseTooltipCommand extends GenericMessage {
|
|
205
|
+
constructor(tooltipId) {
|
|
206
|
+
super();
|
|
207
|
+
this.tooltipId = tooltipId;
|
|
208
|
+
}
|
|
209
|
+
get id() {
|
|
210
|
+
return CloseTooltipCommand.ID;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
CloseTooltipCommand.ID = '4896d52c-e34f-4994-bcfd-32832d12dbe4';
|
|
214
|
+
|
|
179
215
|
class AddLayerCommand extends GenericMessage {
|
|
180
216
|
constructor(layer) {
|
|
181
217
|
super();
|
|
@@ -340,7 +376,7 @@ class MapClickService {
|
|
|
340
376
|
const model = new MapClickEvent(ev.coordinate, {});
|
|
341
377
|
this.map?.forEachFeatureAtPixel(ev.pixel, (f, l) => {
|
|
342
378
|
this.getFeatureCollectionWithInner([f])
|
|
343
|
-
.filter((f) =>
|
|
379
|
+
.filter((f) => f.getId() != null)
|
|
344
380
|
.forEach((fs) => {
|
|
345
381
|
let layerName = l.get('name');
|
|
346
382
|
if (!model.entities[layerName])
|
|
@@ -378,6 +414,7 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
|
378
414
|
this.registerSubject(AddTileCommand.ID);
|
|
379
415
|
this.registerSubject(RemoveTileCommand.ID);
|
|
380
416
|
this.registerSubject(MapClickEvent.ID);
|
|
417
|
+
this.registerSubject(CloseTooltipCommand.ID);
|
|
381
418
|
}
|
|
382
419
|
}
|
|
383
420
|
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -783,6 +820,136 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
783
820
|
type: Input
|
|
784
821
|
}] } });
|
|
785
822
|
|
|
823
|
+
class TooltipSettings {
|
|
824
|
+
constructor(id) {
|
|
825
|
+
this.containerClass = 'custom-tooltip-class';
|
|
826
|
+
this.show = (e) => true;
|
|
827
|
+
this.id = id ?? IdGenerator.get();
|
|
828
|
+
}
|
|
829
|
+
static copy(model) {
|
|
830
|
+
const result = new TooltipSettings(model.id);
|
|
831
|
+
result.show = model.show;
|
|
832
|
+
result.containerClass = model.containerClass;
|
|
833
|
+
return result;
|
|
834
|
+
}
|
|
835
|
+
setShow(show) {
|
|
836
|
+
return TooltipSettings.copy({ ...this, show });
|
|
837
|
+
}
|
|
838
|
+
setClass(containerClass) {
|
|
839
|
+
return TooltipSettings.copy({ ...this, containerClass });
|
|
840
|
+
}
|
|
841
|
+
isSame(model) {
|
|
842
|
+
if (this.show !== model.show)
|
|
843
|
+
return false;
|
|
844
|
+
if (this.containerClass !== model.containerClass)
|
|
845
|
+
return false;
|
|
846
|
+
if (this.id !== model.id)
|
|
847
|
+
return false;
|
|
848
|
+
return true;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
class TooltipComponent extends DestructibleComponent {
|
|
853
|
+
set settings(value) {
|
|
854
|
+
if (!value || this._settings.isSame(value))
|
|
855
|
+
return;
|
|
856
|
+
this._settings = value;
|
|
857
|
+
this.detector.detectChanges();
|
|
858
|
+
}
|
|
859
|
+
constructor(postboy, detector) {
|
|
860
|
+
super();
|
|
861
|
+
this.postboy = postboy;
|
|
862
|
+
this.detector = detector;
|
|
863
|
+
this._settings = new TooltipSettings();
|
|
864
|
+
this.show = false;
|
|
865
|
+
this.removeOverlay = () => {
|
|
866
|
+
!!this.overlay && this.map?.removeOverlay(this.overlay);
|
|
867
|
+
this.show = false;
|
|
868
|
+
};
|
|
869
|
+
this.options = (coordinates) => {
|
|
870
|
+
return {
|
|
871
|
+
element: this.container?.nativeElement,
|
|
872
|
+
autoPan: false,
|
|
873
|
+
autoPanAnimation: { duration: 0 },
|
|
874
|
+
position: coordinates,
|
|
875
|
+
};
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
ngOnInit() {
|
|
879
|
+
this.subs.push(this.observeMapRender());
|
|
880
|
+
this.subs.push(this.observeMapClick());
|
|
881
|
+
this.subs.push(this.observeClose());
|
|
882
|
+
}
|
|
883
|
+
observeMapClick() {
|
|
884
|
+
return this.postboy.subscribe(MapClickEvent.ID).subscribe((ev) => {
|
|
885
|
+
this._settings.show(ev) ? this.addOverlay(ev.coordinates) : this.removeOverlay();
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
observeClose() {
|
|
889
|
+
return this.postboy
|
|
890
|
+
.subscribe(CloseTooltipCommand.ID)
|
|
891
|
+
.pipe(filter((ev) => ev.tooltipId === this._settings.id))
|
|
892
|
+
.subscribe(() => this.removeOverlay());
|
|
893
|
+
}
|
|
894
|
+
observeMapRender() {
|
|
895
|
+
return this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
896
|
+
this.map = m.map;
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
addOverlay(coordinates) {
|
|
900
|
+
this.removeOverlay();
|
|
901
|
+
this.overlay = new Overlay(this.options(coordinates));
|
|
902
|
+
this.map?.addOverlay(this.overlay);
|
|
903
|
+
this.show = true;
|
|
904
|
+
this.detector.detectChanges();
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
TooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TooltipComponent, deps: [{ token: MapPostboyService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
908
|
+
TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TooltipComponent, selector: "lib-tooltip", inputs: { settings: "settings" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["tip"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div #tip [class]=\"['tooltip-wrapper', _settings.containerClass]\" [hidden]=\"!show\">\r\n <ng-content></ng-content>\r\n</div>\r\n", styles: [".tooltip-wrapper{position:absolute}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
909
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TooltipComponent, decorators: [{
|
|
910
|
+
type: Component,
|
|
911
|
+
args: [{ selector: 'lib-tooltip', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div #tip [class]=\"['tooltip-wrapper', _settings.containerClass]\" [hidden]=\"!show\">\r\n <ng-content></ng-content>\r\n</div>\r\n", styles: [".tooltip-wrapper{position:absolute}\n"] }]
|
|
912
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { container: [{
|
|
913
|
+
type: ViewChild,
|
|
914
|
+
args: ['tip']
|
|
915
|
+
}], settings: [{
|
|
916
|
+
type: Input
|
|
917
|
+
}] } });
|
|
918
|
+
|
|
919
|
+
class PolygonsComponent extends DestructibleComponent {
|
|
920
|
+
constructor(postboy) {
|
|
921
|
+
super();
|
|
922
|
+
this.postboy = postboy;
|
|
923
|
+
this.layerName = '';
|
|
924
|
+
this._polygons = [];
|
|
925
|
+
}
|
|
926
|
+
set polygons(value) {
|
|
927
|
+
this._polygons = value;
|
|
928
|
+
this.putPolygons();
|
|
929
|
+
}
|
|
930
|
+
ngOnInit() {
|
|
931
|
+
this.postboy
|
|
932
|
+
.subscribe(MapRenderedEvent.ID)
|
|
933
|
+
.pipe(filter((m) => !!m), first())
|
|
934
|
+
.subscribe(() => this.putPolygons());
|
|
935
|
+
}
|
|
936
|
+
putPolygons() {
|
|
937
|
+
if (!this._polygons?.length)
|
|
938
|
+
return;
|
|
939
|
+
this.postboy.fire(new PlaceLayerFeaturesCommand(this.layerName, this._polygons.map((m) => m.feature)));
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
PolygonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PolygonsComponent, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Component });
|
|
943
|
+
PolygonsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: PolygonsComponent, selector: "lib-polygons", inputs: { layerName: "layerName", polygons: "polygons" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
944
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PolygonsComponent, decorators: [{
|
|
945
|
+
type: Component,
|
|
946
|
+
args: [{ selector: 'lib-polygons', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
|
|
947
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; }, propDecorators: { layerName: [{
|
|
948
|
+
type: Input
|
|
949
|
+
}], polygons: [{
|
|
950
|
+
type: Input
|
|
951
|
+
}] } });
|
|
952
|
+
|
|
786
953
|
class MapModule {
|
|
787
954
|
}
|
|
788
955
|
MapModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -791,7 +958,14 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
|
|
|
791
958
|
TileLayerComponent,
|
|
792
959
|
OsmTileLayerComponent,
|
|
793
960
|
FeatureLayerComponent,
|
|
794
|
-
MarkersComponent
|
|
961
|
+
MarkersComponent,
|
|
962
|
+
TooltipComponent,
|
|
963
|
+
PolygonsComponent], imports: [CommonModule], exports: [MapPlateComponent,
|
|
964
|
+
FeatureLayerComponent,
|
|
965
|
+
MarkersComponent,
|
|
966
|
+
TileLayerComponent,
|
|
967
|
+
TooltipComponent,
|
|
968
|
+
PolygonsComponent] });
|
|
795
969
|
MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
|
|
796
970
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
|
|
797
971
|
type: NgModule,
|
|
@@ -804,8 +978,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
804
978
|
OsmTileLayerComponent,
|
|
805
979
|
FeatureLayerComponent,
|
|
806
980
|
MarkersComponent,
|
|
981
|
+
TooltipComponent,
|
|
982
|
+
PolygonsComponent,
|
|
983
|
+
],
|
|
984
|
+
exports: [
|
|
985
|
+
MapPlateComponent,
|
|
986
|
+
FeatureLayerComponent,
|
|
987
|
+
MarkersComponent,
|
|
988
|
+
TileLayerComponent,
|
|
989
|
+
TooltipComponent,
|
|
990
|
+
PolygonsComponent,
|
|
807
991
|
],
|
|
808
|
-
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent],
|
|
809
992
|
}]
|
|
810
993
|
}] });
|
|
811
994
|
|
|
@@ -832,6 +1015,20 @@ class MarkerStyleHelper {
|
|
|
832
1015
|
}
|
|
833
1016
|
}
|
|
834
1017
|
|
|
1018
|
+
class PolygonStyleHelper {
|
|
1019
|
+
static simple(fill, stroke, strokeWidth = 1) {
|
|
1020
|
+
return new Style({
|
|
1021
|
+
fill: new Fill({
|
|
1022
|
+
color: fill,
|
|
1023
|
+
}),
|
|
1024
|
+
stroke: new Stroke({
|
|
1025
|
+
color: stroke,
|
|
1026
|
+
width: strokeWidth,
|
|
1027
|
+
}),
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
835
1032
|
/*
|
|
836
1033
|
* Public API Surface of maps
|
|
837
1034
|
*/
|
|
@@ -844,5 +1041,5 @@ class MarkerStyleHelper {
|
|
|
844
1041
|
* Generated bundle index. Do not edit.
|
|
845
1042
|
*/
|
|
846
1043
|
|
|
847
|
-
export { CallbackMessage, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings };
|
|
1044
|
+
export { CallbackMessage, CloseTooltipCommand, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings };
|
|
848
1045
|
//# sourceMappingURL=maps-components.mjs.map
|