@tic-nova/ngx-mapbox-gl 14.0.0
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/README.md +3 -0
- package/esm2022/index.js +32 -0
- package/esm2022/index.js.map +1 -0
- package/esm2022/lib/control/attribution-control.directive.js +39 -0
- package/esm2022/lib/control/attribution-control.directive.js.map +1 -0
- package/esm2022/lib/control/control.component.js +62 -0
- package/esm2022/lib/control/control.component.js.map +1 -0
- package/esm2022/lib/control/fullscreen-control.directive.js +39 -0
- package/esm2022/lib/control/fullscreen-control.directive.js.map +1 -0
- package/esm2022/lib/control/geolocate-control.directive.js +52 -0
- package/esm2022/lib/control/geolocate-control.directive.js.map +1 -0
- package/esm2022/lib/control/navigation-control.directive.js +39 -0
- package/esm2022/lib/control/navigation-control.directive.js.map +1 -0
- package/esm2022/lib/control/scale-control.directive.js +45 -0
- package/esm2022/lib/control/scale-control.directive.js.map +1 -0
- package/esm2022/lib/draggable/draggable.directive.js +121 -0
- package/esm2022/lib/draggable/draggable.directive.js.map +1 -0
- package/esm2022/lib/image/image.component.js +79 -0
- package/esm2022/lib/image/image.component.js.map +1 -0
- package/esm2022/lib/layer/layer.component.js +139 -0
- package/esm2022/lib/layer/layer.component.js.map +1 -0
- package/esm2022/lib/map/map.component.js +381 -0
- package/esm2022/lib/map/map.component.js.map +1 -0
- package/esm2022/lib/map/map.service.js +725 -0
- package/esm2022/lib/map/map.service.js.map +1 -0
- package/esm2022/lib/map/map.types.js +30 -0
- package/esm2022/lib/map/map.types.js.map +1 -0
- package/esm2022/lib/marker/marker.component.js +114 -0
- package/esm2022/lib/marker/marker.component.js.map +1 -0
- package/esm2022/lib/markers-for-clusters/markers-for-clusters.component.js +168 -0
- package/esm2022/lib/markers-for-clusters/markers-for-clusters.component.js.map +1 -0
- package/esm2022/lib/popup/popup.component.js +124 -0
- package/esm2022/lib/popup/popup.component.js.map +1 -0
- package/esm2022/lib/provide-mapbox-gl.js +8 -0
- package/esm2022/lib/provide-mapbox-gl.js.map +1 -0
- package/esm2022/lib/source/canvas-source.component.js +74 -0
- package/esm2022/lib/source/canvas-source.component.js.map +1 -0
- package/esm2022/lib/source/geojson/feature.component.js +42 -0
- package/esm2022/lib/source/geojson/feature.component.js.map +1 -0
- package/esm2022/lib/source/geojson/geojson-source.component.js +204 -0
- package/esm2022/lib/source/geojson/geojson-source.component.js.map +1 -0
- package/esm2022/lib/source/image-source.component.js +58 -0
- package/esm2022/lib/source/image-source.component.js.map +1 -0
- package/esm2022/lib/source/raster-dem-source.component.js +91 -0
- package/esm2022/lib/source/raster-dem-source.component.js.map +1 -0
- package/esm2022/lib/source/raster-source.component.js +85 -0
- package/esm2022/lib/source/raster-source.component.js.map +1 -0
- package/esm2022/lib/source/vector-source.component.js +99 -0
- package/esm2022/lib/source/vector-source.component.js.map +1 -0
- package/esm2022/lib/source/video-source.component.js +80 -0
- package/esm2022/lib/source/video-source.component.js.map +1 -0
- package/esm2022/ngx-mapbox-gl.js +5 -0
- package/esm2022/ngx-mapbox-gl.js.map +1 -0
- package/index.d.ts +24 -0
- package/lib/control/attribution-control.directive.d.ts +11 -0
- package/lib/control/control.component.d.ts +21 -0
- package/lib/control/fullscreen-control.directive.d.ts +11 -0
- package/lib/control/geolocate-control.directive.d.ts +15 -0
- package/lib/control/navigation-control.directive.d.ts +11 -0
- package/lib/control/scale-control.directive.d.ts +12 -0
- package/lib/draggable/draggable.directive.d.ts +20 -0
- package/lib/image/image.component.d.ts +34 -0
- package/lib/layer/layer.component.d.ts +422 -0
- package/lib/map/map.component.d.ts +185 -0
- package/lib/map/map.service.d.ts +123 -0
- package/lib/map/map.types.d.ts +72 -0
- package/lib/marker/marker.component.d.ts +31 -0
- package/lib/markers-for-clusters/markers-for-clusters.component.d.ts +28 -0
- package/lib/popup/popup.component.d.ts +33 -0
- package/lib/provide-mapbox-gl.d.ts +6 -0
- package/lib/source/canvas-source.component.d.ts +23 -0
- package/lib/source/geojson/feature.component.d.ts +16 -0
- package/lib/source/geojson/geojson-source.component.d.ts +63 -0
- package/lib/source/image-source.component.d.ts +22 -0
- package/lib/source/raster-dem-source.component.d.ts +23 -0
- package/lib/source/raster-source.component.d.ts +23 -0
- package/lib/source/vector-source.component.d.ts +24 -0
- package/lib/source/video-source.component.d.ts +24 -0
- package/ngx-mapbox-gl.d.ts +5 -0
- package/package.json +44 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Output, ViewChild, inject, input, } from '@angular/core';
|
|
2
|
+
import { MapService } from '../map/map.service';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export class PopupComponent {
|
|
5
|
+
mapService = inject(MapService);
|
|
6
|
+
/* Init input */
|
|
7
|
+
closeButton = input(...(ngDevMode ? [undefined, { debugName: "closeButton" }] : []));
|
|
8
|
+
closeOnClick = input(...(ngDevMode ? [undefined, { debugName: "closeOnClick" }] : []));
|
|
9
|
+
closeOnMove = input(...(ngDevMode ? [undefined, { debugName: "closeOnMove" }] : []));
|
|
10
|
+
focusAfterOpen = input(...(ngDevMode ? [undefined, { debugName: "focusAfterOpen" }] : []));
|
|
11
|
+
anchor = input(...(ngDevMode ? [undefined, { debugName: "anchor" }] : []));
|
|
12
|
+
className = input(...(ngDevMode ? [undefined, { debugName: "className" }] : []));
|
|
13
|
+
maxWidth = input(...(ngDevMode ? [undefined, { debugName: "maxWidth" }] : []));
|
|
14
|
+
/* Dynamic input */
|
|
15
|
+
feature = input(...(ngDevMode ? [undefined, { debugName: "feature" }] : []));
|
|
16
|
+
lngLat = input(...(ngDevMode ? [undefined, { debugName: "lngLat" }] : []));
|
|
17
|
+
marker = input(...(ngDevMode ? [undefined, { debugName: "marker" }] : []));
|
|
18
|
+
offset = input(...(ngDevMode ? [undefined, { debugName: "offset" }] : []));
|
|
19
|
+
popupClose = new EventEmitter();
|
|
20
|
+
popupOpen = new EventEmitter();
|
|
21
|
+
content;
|
|
22
|
+
popupInstance;
|
|
23
|
+
ngOnInit() {
|
|
24
|
+
if ((this.lngLat() && this.marker()) ||
|
|
25
|
+
(this.feature() && this.lngLat()) ||
|
|
26
|
+
(this.feature() && this.marker())) {
|
|
27
|
+
throw new Error('marker, lngLat, feature input are mutually exclusive');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
ngOnChanges(changes) {
|
|
31
|
+
if ((changes['lngLat'] && !changes['lngLat'].isFirstChange()) ||
|
|
32
|
+
(changes['feature'] && !changes['feature'].isFirstChange())) {
|
|
33
|
+
const newlngLat = changes['lngLat']
|
|
34
|
+
? this.lngLat()
|
|
35
|
+
: this.feature().geometry.coordinates;
|
|
36
|
+
this.mapService.removePopupFromMap(this.popupInstance, true);
|
|
37
|
+
const popupInstanceTmp = this.createPopup();
|
|
38
|
+
this.mapService.addPopupToMap(popupInstanceTmp, newlngLat, this.popupInstance.isOpen());
|
|
39
|
+
this.popupInstance = popupInstanceTmp;
|
|
40
|
+
}
|
|
41
|
+
if (changes['marker'] && !changes['marker'].isFirstChange()) {
|
|
42
|
+
const previousMarker = changes['marker'].previousValue;
|
|
43
|
+
if (previousMarker.markerInstance) {
|
|
44
|
+
this.mapService.removePopupFromMarker(previousMarker.markerInstance);
|
|
45
|
+
}
|
|
46
|
+
if (this.marker() &&
|
|
47
|
+
this.marker().markerInstance &&
|
|
48
|
+
this.popupInstance) {
|
|
49
|
+
this.mapService.addPopupToMarker(this.marker().markerInstance, this.popupInstance);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (changes['offset'] &&
|
|
53
|
+
!changes['offset'].isFirstChange() &&
|
|
54
|
+
this.popupInstance) {
|
|
55
|
+
this.popupInstance.setOffset(this.offset());
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
ngAfterViewInit() {
|
|
59
|
+
this.popupInstance = this.createPopup();
|
|
60
|
+
this.addPopup(this.popupInstance);
|
|
61
|
+
}
|
|
62
|
+
ngOnDestroy() {
|
|
63
|
+
if (this.popupInstance) {
|
|
64
|
+
if (this.lngLat() || this.feature()) {
|
|
65
|
+
this.mapService.removePopupFromMap(this.popupInstance);
|
|
66
|
+
}
|
|
67
|
+
else if (this.marker() && this.marker().markerInstance) {
|
|
68
|
+
this.mapService.removePopupFromMarker(this.marker().markerInstance);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
this.popupInstance = undefined;
|
|
72
|
+
}
|
|
73
|
+
createPopup() {
|
|
74
|
+
return this.mapService.createPopup({
|
|
75
|
+
popupOptions: {
|
|
76
|
+
closeButton: this.closeButton(),
|
|
77
|
+
closeOnClick: this.closeOnClick(),
|
|
78
|
+
closeOnMove: this.closeOnMove(),
|
|
79
|
+
focusAfterOpen: this.focusAfterOpen(),
|
|
80
|
+
anchor: this.anchor(),
|
|
81
|
+
offset: this.offset(),
|
|
82
|
+
className: this.className(),
|
|
83
|
+
maxWidth: this.maxWidth(),
|
|
84
|
+
},
|
|
85
|
+
popupEvents: {
|
|
86
|
+
popupOpen: this.popupOpen,
|
|
87
|
+
popupClose: this.popupClose,
|
|
88
|
+
},
|
|
89
|
+
}, this.content.nativeElement);
|
|
90
|
+
}
|
|
91
|
+
addPopup(popup) {
|
|
92
|
+
this.mapService.mapCreated$.subscribe(() => {
|
|
93
|
+
if (this.lngLat() || this.feature()) {
|
|
94
|
+
this.mapService.addPopupToMap(popup, this.lngLat()
|
|
95
|
+
? this.lngLat()
|
|
96
|
+
: this.feature().geometry.coordinates);
|
|
97
|
+
}
|
|
98
|
+
else if (this.marker() && this.marker().markerInstance) {
|
|
99
|
+
this.mapService.addPopupToMarker(this.marker().markerInstance, popup);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw new Error('mgl-popup need either lngLat/marker/feature to be set');
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: PopupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
107
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: PopupComponent, isStandalone: true, selector: "mgl-popup", inputs: { closeButton: { classPropertyName: "closeButton", publicName: "closeButton", isSignal: true, isRequired: false, transformFunction: null }, closeOnClick: { classPropertyName: "closeOnClick", publicName: "closeOnClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnMove: { classPropertyName: "closeOnMove", publicName: "closeOnMove", isSignal: true, isRequired: false, transformFunction: null }, focusAfterOpen: { classPropertyName: "focusAfterOpen", publicName: "focusAfterOpen", isSignal: true, isRequired: false, transformFunction: null }, anchor: { classPropertyName: "anchor", publicName: "anchor", isSignal: true, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, feature: { classPropertyName: "feature", publicName: "feature", isSignal: true, isRequired: false, transformFunction: null }, lngLat: { classPropertyName: "lngLat", publicName: "lngLat", isSignal: true, isRequired: false, transformFunction: null }, marker: { classPropertyName: "marker", publicName: "marker", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "offset", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { popupClose: "popupClose", popupOpen: "popupOpen" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: '<div #content><ng-content/></div>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
108
|
+
}
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: PopupComponent, decorators: [{
|
|
110
|
+
type: Component,
|
|
111
|
+
args: [{
|
|
112
|
+
selector: 'mgl-popup',
|
|
113
|
+
template: '<div #content><ng-content/></div>',
|
|
114
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
115
|
+
}]
|
|
116
|
+
}], propDecorators: { closeButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeButton", required: false }] }], closeOnClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnClick", required: false }] }], closeOnMove: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnMove", required: false }] }], focusAfterOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusAfterOpen", required: false }] }], anchor: [{ type: i0.Input, args: [{ isSignal: true, alias: "anchor", required: false }] }], className: [{ type: i0.Input, args: [{ isSignal: true, alias: "className", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], feature: [{ type: i0.Input, args: [{ isSignal: true, alias: "feature", required: false }] }], lngLat: [{ type: i0.Input, args: [{ isSignal: true, alias: "lngLat", required: false }] }], marker: [{ type: i0.Input, args: [{ isSignal: true, alias: "marker", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], popupClose: [{
|
|
117
|
+
type: Output
|
|
118
|
+
}], popupOpen: [{
|
|
119
|
+
type: Output
|
|
120
|
+
}], content: [{
|
|
121
|
+
type: ViewChild,
|
|
122
|
+
args: ['content', { static: true }]
|
|
123
|
+
}] } });
|
|
124
|
+
//# sourceMappingURL=popup.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popup.component.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/popup/popup.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,YAAY,EAIZ,MAAM,EAEN,SAAS,EACT,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;;AAShD,MAAM,OAAO,cAAc;IAGjB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAExC,gBAAgB;IAChB,WAAW,GAAG,KA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AI,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;gBACpC,IAAI,CAAC,UAAU,CAAC,aAAa,CAC3B,KAAK,EACL,IAAI,CAAC,MAAM,EAAE;oBACX,CAAC,CAAC,IAAI,CAAC,MAAM,EAAG;oBAChB,CAAC,CAAE,IAAI,CAAC,OAAO,EAAG,CAAC,QAAS,CAAC,WAAiC,CACjE,CAAC;YACJ,CAAC;iBAAM,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,MAAM,EAAG,CAAC,cAAc,EAAE,CAAC;gBAC1D,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAG,CAAC,cAAe,EAAE,KAAK,CAAC,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CACb,uDAAuD,CACxD,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;uGA5IU,cAAc;2FAAd,cAAc,0rDAHf,mCAAmC;;2FAGlC,cAAc;kBAL1B,SAAS;mBAAC;oBACT,QAAQ,EAAE,WAAW;oBACrB,QAAQ,EAAE,mCAAmC;oBAC7C,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD;;sBA2BE,MAAM;;sBACN,MAAM;;sBAEN,SAAS;uBAAC,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE","sourcesContent":["import {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n EventEmitter,\n OnChanges,\n OnDestroy,\n OnInit,\n Output,\n SimpleChanges,\n ViewChild,\n inject,\n input,\n} from '@angular/core';\nimport { LngLatLike, PointLike, Popup, PopupOptions } from 'mapbox-gl';\nimport { MapService } from '../map/map.service';\nimport { MarkerComponent } from '../marker/marker.component';\nimport { Feature, Point } from 'geojson';\n\n@Component({\n selector: 'mgl-popup',\n template: '<div #content><ng-content/></div>',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class PopupComponent\n implements OnChanges, OnDestroy, AfterViewInit, OnInit\n{\n private mapService = inject(MapService);\n\n /* Init input */\n closeButton = input<PopupOptions['closeButton']>();\n closeOnClick = input<PopupOptions['closeOnClick']>();\n closeOnMove = input<PopupOptions['closeOnMove']>();\n focusAfterOpen = input<PopupOptions['focusAfterOpen']>();\n anchor = input<PopupOptions['anchor']>();\n className = input<PopupOptions['className']>();\n maxWidth = input<PopupOptions['maxWidth']>();\n\n /* Dynamic input */\n feature = input<Feature<Point>>();\n lngLat = input<LngLatLike>();\n marker = input<MarkerComponent>();\n offset = input<\n | number\n | PointLike\n | {\n [anchor: string]: [number, number];\n }\n >();\n\n @Output() popupClose = new EventEmitter<void>();\n @Output() popupOpen = new EventEmitter<void>();\n\n @ViewChild('content', { static: true }) content: ElementRef;\n\n popupInstance?: Popup;\n\n ngOnInit() {\n if (\n (this.lngLat() && this.marker()) ||\n (this.feature() && this.lngLat()) ||\n (this.feature() && this.marker())\n ) {\n throw new Error('marker, lngLat, feature input are mutually exclusive');\n }\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (\n (changes['lngLat'] && !changes['lngLat'].isFirstChange()) ||\n (changes['feature'] && !changes['feature'].isFirstChange())\n ) {\n const newlngLat = changes['lngLat']\n ? this.lngLat()!\n : (this.feature()!.geometry!.coordinates! as [number, number]);\n this.mapService.removePopupFromMap(this.popupInstance!, true);\n const popupInstanceTmp = this.createPopup();\n this.mapService.addPopupToMap(\n popupInstanceTmp,\n newlngLat,\n this.popupInstance!.isOpen(),\n );\n this.popupInstance = popupInstanceTmp;\n }\n if (changes['marker'] && !changes['marker'].isFirstChange()) {\n const previousMarker: MarkerComponent = changes['marker'].previousValue;\n if (previousMarker.markerInstance) {\n this.mapService.removePopupFromMarker(previousMarker.markerInstance);\n }\n if (\n this.marker() &&\n this.marker()!.markerInstance &&\n this.popupInstance\n ) {\n this.mapService.addPopupToMarker(\n this.marker()!.markerInstance!,\n this.popupInstance,\n );\n }\n }\n if (\n changes['offset'] &&\n !changes['offset'].isFirstChange() &&\n this.popupInstance\n ) {\n this.popupInstance.setOffset(this.offset());\n }\n }\n\n ngAfterViewInit() {\n this.popupInstance = this.createPopup();\n this.addPopup(this.popupInstance);\n }\n\n ngOnDestroy() {\n if (this.popupInstance) {\n if (this.lngLat() || this.feature()) {\n this.mapService.removePopupFromMap(this.popupInstance);\n } else if (this.marker() && this.marker()!.markerInstance) {\n this.mapService.removePopupFromMarker(this.marker()!.markerInstance!);\n }\n }\n this.popupInstance = undefined;\n }\n\n private createPopup() {\n return this.mapService.createPopup(\n {\n popupOptions: {\n closeButton: this.closeButton(),\n closeOnClick: this.closeOnClick(),\n closeOnMove: this.closeOnMove(),\n focusAfterOpen: this.focusAfterOpen(),\n anchor: this.anchor(),\n offset: this.offset(),\n className: this.className(),\n maxWidth: this.maxWidth(),\n },\n popupEvents: {\n popupOpen: this.popupOpen,\n popupClose: this.popupClose,\n },\n },\n this.content.nativeElement,\n );\n }\n\n private addPopup(popup: Popup) {\n this.mapService.mapCreated$.subscribe(() => {\n if (this.lngLat() || this.feature()) {\n this.mapService.addPopupToMap(\n popup,\n this.lngLat()\n ? this.lngLat()!\n : (this.feature()!.geometry!.coordinates! as [number, number]),\n );\n } else if (this.marker() && this.marker()!.markerInstance) {\n this.mapService.addPopupToMarker(this.marker()!.markerInstance!, popup);\n } else {\n throw new Error(\n 'mgl-popup need either lngLat/marker/feature to be set',\n );\n }\n });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provide-mapbox-gl.js","sourceRoot":"","sources":["../../../../../libs/ngx-mapbox-gl/src/lib/provide-mapbox-gl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,UAAU,eAAe,CAAC,MAA+B;IAC7D,OAAO;QACL,OAAO,EAAE,cAAc;QACvB,QAAQ,EAAE,MAAM,CAAC,WAAW;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["import { MAPBOX_API_KEY } from './map/map.service';\n\nexport function provideMapboxGL(config: { accessToken: string }) {\n return {\n provide: MAPBOX_API_KEY,\n useValue: config.accessToken,\n };\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject, input, } from '@angular/core';
|
|
2
|
+
import { fromEvent, Subscription } from 'rxjs';
|
|
3
|
+
import { filter } from 'rxjs/operators';
|
|
4
|
+
import { MapService } from '../map/map.service';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export class CanvasSourceComponent {
|
|
7
|
+
mapService = inject(MapService);
|
|
8
|
+
/* Init inputs */
|
|
9
|
+
id = input.required(...(ngDevMode ? [{ debugName: "id" }] : []));
|
|
10
|
+
/* Dynamic inputs */
|
|
11
|
+
coordinates = input.required(...(ngDevMode ? [{ debugName: "coordinates" }] : []));
|
|
12
|
+
canvas = input.required(...(ngDevMode ? [{ debugName: "canvas" }] : []));
|
|
13
|
+
animate = input(...(ngDevMode ? [undefined, { debugName: "animate" }] : []));
|
|
14
|
+
sourceAdded = false;
|
|
15
|
+
sub = new Subscription();
|
|
16
|
+
ngOnInit() {
|
|
17
|
+
const sub1 = this.mapService.mapLoaded$.subscribe(() => {
|
|
18
|
+
this.init();
|
|
19
|
+
const sub = fromEvent(this.mapService.mapInstance, 'styledata')
|
|
20
|
+
.pipe(filter(() => !this.mapService.mapInstance.getSource(this.id())))
|
|
21
|
+
.subscribe(() => {
|
|
22
|
+
this.init();
|
|
23
|
+
});
|
|
24
|
+
this.sub.add(sub);
|
|
25
|
+
});
|
|
26
|
+
this.sub.add(sub1);
|
|
27
|
+
}
|
|
28
|
+
ngOnChanges(changes) {
|
|
29
|
+
if (!this.sourceAdded) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if ((changes['canvas'] && !changes['canvas'].isFirstChange()) ||
|
|
33
|
+
(changes['animate'] && !changes['animate'].isFirstChange())) {
|
|
34
|
+
this.ngOnDestroy();
|
|
35
|
+
this.ngOnInit();
|
|
36
|
+
}
|
|
37
|
+
else if (changes['coordinates'] &&
|
|
38
|
+
!changes['coordinates'].isFirstChange()) {
|
|
39
|
+
const source = this.mapService.getSource(this.id());
|
|
40
|
+
if (source === undefined) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
source.setCoordinates(this.coordinates());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
ngOnDestroy() {
|
|
47
|
+
this.sub.unsubscribe();
|
|
48
|
+
if (this.sourceAdded) {
|
|
49
|
+
this.mapService.removeSource(this.id());
|
|
50
|
+
this.sourceAdded = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
init() {
|
|
54
|
+
const source = {
|
|
55
|
+
type: 'canvas',
|
|
56
|
+
coordinates: this.coordinates(),
|
|
57
|
+
canvas: this.canvas(),
|
|
58
|
+
animate: this.animate(),
|
|
59
|
+
};
|
|
60
|
+
this.mapService.addSource(this.id(), source);
|
|
61
|
+
this.sourceAdded = true;
|
|
62
|
+
}
|
|
63
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: CanvasSourceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
64
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: CanvasSourceComponent, isStandalone: true, selector: "mgl-canvas-source", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: true, transformFunction: null }, coordinates: { classPropertyName: "coordinates", publicName: "coordinates", isSignal: true, isRequired: true, transformFunction: null }, canvas: { classPropertyName: "canvas", publicName: "canvas", isSignal: true, isRequired: true, transformFunction: null }, animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null } }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
65
|
+
}
|
|
66
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: CanvasSourceComponent, decorators: [{
|
|
67
|
+
type: Component,
|
|
68
|
+
args: [{
|
|
69
|
+
selector: 'mgl-canvas-source',
|
|
70
|
+
template: '',
|
|
71
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
72
|
+
}]
|
|
73
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: true }] }], coordinates: [{ type: i0.Input, args: [{ isSignal: true, alias: "coordinates", required: true }] }], canvas: [{ type: i0.Input, args: [{ isSignal: true, alias: "canvas", required: true }] }], animate: [{ type: i0.Input, args: [{ isSignal: true, alias: "animate", required: false }] }] } });
|
|
74
|
+
//# sourceMappingURL=canvas-source.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-source.component.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/source/canvas-source.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EAKT,MAAM,EACN,KAAK,GAEN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;;AAehD,MAAM,OAAO,qBAAqB;IAGxB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAExC,iBAAiB;IACjB,EAAE,GAAG,KAAK,CAAC,QAAQ,6CAAU,CAAC;IAE9B,oBAAoB;IACpB,WAAW,GAAG,KAAK,CAAC,QAAQ,sDAA0C,CAAC;IACvE,MAAM,GAAG,KAAK,CAAC,QAAQ,iDAAqC,CAAC;IAC7D,OAAO,GAAG,KAAK,6DAAsC,CAAC;IAE9C,WAAW,GAAG,KAAK,CAAC;IACpB,GAAG,GAAG,IAAI,YAA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K,SAAS,EAAE,CAAC;gBACzB,OAAO;YACT,CAAC;YACD,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,WAAW;QACT,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;YACxC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;IAEO,IAAI;QACV,MAAM,MAAM,GAA4B;YACtC,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;SACxB,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;uGApEU,qBAAqB;2FAArB,qBAAqB,6lBAHtB,EAAE;;2FAGD,qBAAqB;kBALjC,SAAS;mBAAC;oBACT,QAAQ,EAAE,mBAAmB;oBAC7B,QAAQ,EAAE,EAAE;oBACZ,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n OnChanges,\n OnDestroy,\n OnInit,\n SimpleChanges,\n inject,\n input,\n type InputSignal,\n} from '@angular/core';\nimport { fromEvent, Subscription } from 'rxjs';\nimport { filter } from 'rxjs/operators';\nimport { MapService } from '../map/map.service';\nimport type { CanvasSource } from 'mapbox-gl';\n\ntype CanvasSourceSpecification = CanvasSource['options'];\ntype CanvasSourceInputs = {\n [K in keyof Omit<CanvasSourceSpecification, 'type'>]: InputSignal<\n Omit<CanvasSourceSpecification, 'type'>[K]\n >;\n};\n\n@Component({\n selector: 'mgl-canvas-source',\n template: '',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class CanvasSourceComponent\n implements OnInit, OnDestroy, OnChanges, CanvasSourceInputs\n{\n private mapService = inject(MapService);\n\n /* Init inputs */\n id = input.required<string>();\n\n /* Dynamic inputs */\n coordinates = input.required<CanvasSource['options']['coordinates']>();\n canvas = input.required<CanvasSource['options']['canvas']>();\n animate = input<CanvasSource['options']['animate']>();\n\n private sourceAdded = false;\n private sub = new Subscription();\n\n ngOnInit() {\n const sub1 = this.mapService.mapLoaded$.subscribe(() => {\n this.init();\n const sub = fromEvent(this.mapService.mapInstance, 'styledata')\n .pipe(filter(() => !this.mapService.mapInstance.getSource(this.id())))\n .subscribe(() => {\n this.init();\n });\n this.sub.add(sub);\n });\n this.sub.add(sub1);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (!this.sourceAdded) {\n return;\n }\n if (\n (changes['canvas'] && !changes['canvas'].isFirstChange()) ||\n (changes['animate'] && !changes['animate'].isFirstChange())\n ) {\n this.ngOnDestroy();\n this.ngOnInit();\n } else if (\n changes['coordinates'] &&\n !changes['coordinates'].isFirstChange()\n ) {\n const source = this.mapService.getSource<CanvasSource>(this.id());\n if (source === undefined) {\n return;\n }\n source.setCoordinates(this.coordinates());\n }\n }\n\n ngOnDestroy() {\n this.sub.unsubscribe();\n if (this.sourceAdded) {\n this.mapService.removeSource(this.id());\n this.sourceAdded = false;\n }\n }\n\n private init() {\n const source: CanvasSource['options'] = {\n type: 'canvas',\n coordinates: this.coordinates(),\n canvas: this.canvas(),\n animate: this.animate(),\n };\n this.mapService.addSource(this.id(), source);\n this.sourceAdded = true;\n }\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, forwardRef, inject, input, model, } from '@angular/core';
|
|
2
|
+
import { GeoJSONSourceComponent } from './geojson-source.component';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export class FeatureComponent {
|
|
5
|
+
GeoJSONSourceComponent = inject(forwardRef(() => GeoJSONSourceComponent));
|
|
6
|
+
/* Init inputs */
|
|
7
|
+
id = model(...(ngDevMode ? [undefined, { debugName: "id" }] : [])); // FIXME number only for now https://github.com/mapbox/mapbox-gl-js/issues/2716
|
|
8
|
+
geometry = input.required(...(ngDevMode ? [{ debugName: "geometry" }] : []));
|
|
9
|
+
properties = input(...(ngDevMode ? [undefined, { debugName: "properties" }] : []));
|
|
10
|
+
type = 'Feature';
|
|
11
|
+
feature;
|
|
12
|
+
ngOnInit() {
|
|
13
|
+
if (!this.id()) {
|
|
14
|
+
this.id.set(this.GeoJSONSourceComponent._getNewFeatureId());
|
|
15
|
+
}
|
|
16
|
+
this.feature = {
|
|
17
|
+
type: this.type,
|
|
18
|
+
geometry: this.geometry(),
|
|
19
|
+
properties: this.properties() ? this.properties() : {},
|
|
20
|
+
};
|
|
21
|
+
this.feature.id = this.id();
|
|
22
|
+
this.GeoJSONSourceComponent._addFeature(this.feature);
|
|
23
|
+
}
|
|
24
|
+
ngOnDestroy() {
|
|
25
|
+
this.GeoJSONSourceComponent._removeFeature(this.feature);
|
|
26
|
+
}
|
|
27
|
+
updateCoordinates(coordinates) {
|
|
28
|
+
this.feature.geometry.coordinates = coordinates;
|
|
29
|
+
this.GeoJSONSourceComponent.updateFeatureData.next(null);
|
|
30
|
+
}
|
|
31
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FeatureComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
32
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: FeatureComponent, isStandalone: true, selector: "mgl-feature", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, geometry: { classPropertyName: "geometry", publicName: "geometry", isSignal: true, isRequired: true, transformFunction: null }, properties: { classPropertyName: "properties", publicName: "properties", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { id: "idChange" }, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
33
|
+
}
|
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FeatureComponent, decorators: [{
|
|
35
|
+
type: Component,
|
|
36
|
+
args: [{
|
|
37
|
+
selector: 'mgl-feature',
|
|
38
|
+
template: '',
|
|
39
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
40
|
+
}]
|
|
41
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }, { type: i0.Output, args: ["idChange"] }], geometry: [{ type: i0.Input, args: [{ isSignal: true, alias: "geometry", required: true }] }], properties: [{ type: i0.Input, args: [{ isSignal: true, alias: "properties", required: false }] }] } });
|
|
42
|
+
//# sourceMappingURL=feature.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.component.js","sourceRoot":"","sources":["../../../../../../../libs/ngx-mapbox-gl/src/lib/source/geojson/feature.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EAGT,UAAU,EACV,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;;AAQpE,MAAM,OAAO,gBAAgB;IACnB,sBAAsB,GAAG,MAAM,CACrC,UAAU,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,CACzC,CAAC;IAEF,iBAAiB;IACjB,EAAE,GAAG,KAAK,wDAAU,CAAC,CAAC,+EAA+E;IACrG,QAAQ,GAAG,KAAK,CAAC,QAAQ,mDAAkB,CAAC;IAC5C,UAAU,GAAG,KAAK,gEAAqB,CAAC;IACxC,IAAI,GAAG,SAAkB,CAAC;IAElB,OAAO,CAA0B;IAEzC,QAAQ;QACN,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;YACf,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,OAAO,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;YACzB,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAG,CAAC,CAAC,CAAC,EAAE;SACxD,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC5B,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,WAAW;QACT,IAAI,CAAC,sBAAsB,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,iBAAiB,CAAC,WAAqB;QACpC,IAAI,CAAC,OAAO,CAAC,QAAkB,CAAC,WAAW,GAAG,WAAW,CAAC;QAC3D,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;uGAjCU,gBAAgB;2FAAhB,gBAAgB,seAHjB,EAAE;;2FAGD,gBAAgB;kBAL5B,SAAS;mBAAC;oBACT,QAAQ,EAAE,aAAa;oBACvB,QAAQ,EAAE,EAAE;oBACZ,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n OnDestroy,\n OnInit,\n forwardRef,\n inject,\n input,\n model,\n} from '@angular/core';\nimport { GeoJSONSourceComponent } from './geojson-source.component';\nimport { Feature, GeometryObject, GeoJsonProperties, Point } from 'geojson';\n\n@Component({\n selector: 'mgl-feature',\n template: '',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class FeatureComponent implements OnInit, OnDestroy {\n private GeoJSONSourceComponent = inject<GeoJSONSourceComponent>(\n forwardRef(() => GeoJSONSourceComponent),\n );\n\n /* Init inputs */\n id = model<number>(); // FIXME number only for now https://github.com/mapbox/mapbox-gl-js/issues/2716\n geometry = input.required<GeometryObject>();\n properties = input<GeoJsonProperties>();\n type = 'Feature' as const;\n\n private feature: Feature<GeometryObject>;\n\n ngOnInit() {\n if (!this.id()) {\n this.id.set(this.GeoJSONSourceComponent._getNewFeatureId());\n }\n this.feature = {\n type: this.type,\n geometry: this.geometry(),\n properties: this.properties() ? this.properties()! : {},\n };\n this.feature.id = this.id();\n this.GeoJSONSourceComponent._addFeature(this.feature);\n }\n\n ngOnDestroy() {\n this.GeoJSONSourceComponent._removeFeature(this.feature);\n }\n\n updateCoordinates(coordinates: number[]) {\n (this.feature.geometry as Point).coordinates = coordinates;\n this.GeoJSONSourceComponent.updateFeatureData.next(null);\n }\n}\n"]}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, NgZone, inject, input, model, } from '@angular/core';
|
|
2
|
+
import { fromEvent, Subject, Subscription } from 'rxjs';
|
|
3
|
+
import { debounceTime, filter } from 'rxjs/operators';
|
|
4
|
+
import { MapService } from '../../map/map.service';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export class GeoJSONSourceComponent {
|
|
7
|
+
mapService = inject(MapService);
|
|
8
|
+
zone = inject(NgZone);
|
|
9
|
+
/* Init inputs */
|
|
10
|
+
id = input.required(...(ngDevMode ? [{ debugName: "id" }] : []));
|
|
11
|
+
/* Dynamic inputs */
|
|
12
|
+
data = model(...(ngDevMode ? [undefined, { debugName: "data" }] : []));
|
|
13
|
+
minzoom = input(...(ngDevMode ? [undefined, { debugName: "minzoom" }] : []));
|
|
14
|
+
maxzoom = input(...(ngDevMode ? [undefined, { debugName: "maxzoom" }] : []));
|
|
15
|
+
attribution = input(...(ngDevMode ? [undefined, { debugName: "attribution" }] : []));
|
|
16
|
+
buffer = input(...(ngDevMode ? [undefined, { debugName: "buffer" }] : []));
|
|
17
|
+
tolerance = input(...(ngDevMode ? [undefined, { debugName: "tolerance" }] : []));
|
|
18
|
+
cluster = input(...(ngDevMode ? [undefined, { debugName: "cluster" }] : []));
|
|
19
|
+
clusterRadius = input(...(ngDevMode ? [undefined, { debugName: "clusterRadius" }] : []));
|
|
20
|
+
clusterMaxZoom = input(...(ngDevMode ? [undefined, { debugName: "clusterMaxZoom" }] : []));
|
|
21
|
+
clusterMinPoints = input(...(ngDevMode ? [undefined, { debugName: "clusterMinPoints" }] : []));
|
|
22
|
+
clusterProperties = input(...(ngDevMode ? [undefined, { debugName: "clusterProperties" }] : []));
|
|
23
|
+
lineMetrics = input(...(ngDevMode ? [undefined, { debugName: "lineMetrics" }] : []));
|
|
24
|
+
generateId = input(...(ngDevMode ? [undefined, { debugName: "generateId" }] : []));
|
|
25
|
+
promoteId = input(...(ngDevMode ? [undefined, { debugName: "promoteId" }] : []));
|
|
26
|
+
filter = input(...(ngDevMode ? [undefined, { debugName: "filter" }] : []));
|
|
27
|
+
dynamic = input(...(ngDevMode ? [undefined, { debugName: "dynamic" }] : []));
|
|
28
|
+
updateFeatureData = new Subject();
|
|
29
|
+
sub = new Subscription();
|
|
30
|
+
sourceAdded = false;
|
|
31
|
+
featureIdCounter = 0;
|
|
32
|
+
ngOnInit() {
|
|
33
|
+
if (!this.data()) {
|
|
34
|
+
this.data.set({
|
|
35
|
+
type: 'FeatureCollection',
|
|
36
|
+
features: [],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const sub1 = this.mapService.mapLoaded$.subscribe(() => {
|
|
40
|
+
this.init();
|
|
41
|
+
const sub = fromEvent(this.mapService.mapInstance, 'styledata')
|
|
42
|
+
.pipe(filter(() => !this.mapService.mapInstance.getSource(this.id())))
|
|
43
|
+
.subscribe(() => {
|
|
44
|
+
this.init();
|
|
45
|
+
});
|
|
46
|
+
this.sub.add(sub);
|
|
47
|
+
});
|
|
48
|
+
this.sub.add(sub1);
|
|
49
|
+
}
|
|
50
|
+
ngOnChanges(changes) {
|
|
51
|
+
if (!this.sourceAdded) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if ((changes['minzoom'] && !changes['minzoom'].isFirstChange()) ||
|
|
55
|
+
(changes['maxzoom'] && !changes['maxzoom'].isFirstChange()) ||
|
|
56
|
+
(changes['attribution'] && !changes['attribution'].isFirstChange()) ||
|
|
57
|
+
(changes['buffer'] && !changes['buffer'].isFirstChange()) ||
|
|
58
|
+
(changes['tolerance'] && !changes['tolerance'].isFirstChange()) ||
|
|
59
|
+
(changes['cluster'] && !changes['cluster'].isFirstChange()) ||
|
|
60
|
+
(changes['clusterRadius'] && !changes['clusterRadius'].isFirstChange()) ||
|
|
61
|
+
(changes['clusterMaxZoom'] &&
|
|
62
|
+
!changes['clusterMaxZoom'].isFirstChange()) ||
|
|
63
|
+
(changes['clusterMinPoints'] &&
|
|
64
|
+
!changes['clusterMinPoints'].isFirstChange()) ||
|
|
65
|
+
(changes['clusterProperties'] &&
|
|
66
|
+
!changes['clusterProperties'].isFirstChange()) ||
|
|
67
|
+
(changes['lineMetrics'] && !changes['lineMetrics'].isFirstChange()) ||
|
|
68
|
+
(changes['generateId'] && !changes['generateId'].isFirstChange()) ||
|
|
69
|
+
(changes['promoteId'] && !changes['promoteId'].isFirstChange()) ||
|
|
70
|
+
(changes['filter'] && !changes['filter'].isFirstChange()) ||
|
|
71
|
+
(changes['dynamic'] && !changes['dynamic'].isFirstChange())) {
|
|
72
|
+
this.ngOnDestroy();
|
|
73
|
+
this.ngOnInit();
|
|
74
|
+
}
|
|
75
|
+
if (changes['data'] && !changes['data'].isFirstChange()) {
|
|
76
|
+
const source = this.mapService.getSource(this.id());
|
|
77
|
+
if (source === undefined) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
source.setData(this.data());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
ngOnDestroy() {
|
|
84
|
+
this.sub.unsubscribe();
|
|
85
|
+
if (this.sourceAdded) {
|
|
86
|
+
this.mapService.removeSource(this.id());
|
|
87
|
+
this.sourceAdded = false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* For clustered sources, fetches the zoom at which the given cluster expands.
|
|
92
|
+
*
|
|
93
|
+
* @param clusterId The value of the cluster's cluster_id property.
|
|
94
|
+
*/
|
|
95
|
+
async getClusterExpansionZoom(clusterId) {
|
|
96
|
+
const source = this.mapService.getSource(this.id());
|
|
97
|
+
return this.zone.run(async () => new Promise((resolve, reject) => {
|
|
98
|
+
source.getClusterExpansionZoom(clusterId, (error, zoom) => {
|
|
99
|
+
if (error) {
|
|
100
|
+
reject(error);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
resolve(zoom);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features).
|
|
110
|
+
*
|
|
111
|
+
* @param clusterId The value of the cluster's cluster_id property.
|
|
112
|
+
*/
|
|
113
|
+
async getClusterChildren(clusterId) {
|
|
114
|
+
const source = this.mapService.getSource(this.id());
|
|
115
|
+
return this.zone.run(async () => new Promise((resolve, reject) => {
|
|
116
|
+
source.getClusterChildren(clusterId, (error, features) => {
|
|
117
|
+
if (error) {
|
|
118
|
+
reject(error);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
resolve(features);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features).
|
|
128
|
+
*
|
|
129
|
+
* @param clusterId The value of the cluster's cluster_id property.
|
|
130
|
+
* @param limit The maximum number of features to return.
|
|
131
|
+
* @param offset The number of features to skip (e.g. for pagination).
|
|
132
|
+
*/
|
|
133
|
+
async getClusterLeaves(clusterId, limit, offset) {
|
|
134
|
+
const source = this.mapService.getSource(this.id());
|
|
135
|
+
return this.zone.run(async () => new Promise((resolve, reject) => {
|
|
136
|
+
source.getClusterLeaves(clusterId, limit, offset, (error, features) => {
|
|
137
|
+
if (error) {
|
|
138
|
+
reject(error);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
resolve(features || []);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
_addFeature(feature) {
|
|
147
|
+
const collection = this.data();
|
|
148
|
+
collection.features.push(feature);
|
|
149
|
+
this.updateFeatureData.next(null);
|
|
150
|
+
}
|
|
151
|
+
_removeFeature(feature) {
|
|
152
|
+
const collection = this.data();
|
|
153
|
+
const index = collection.features.indexOf(feature);
|
|
154
|
+
if (index > -1) {
|
|
155
|
+
collection.features.splice(index, 1);
|
|
156
|
+
}
|
|
157
|
+
this.updateFeatureData.next(null);
|
|
158
|
+
}
|
|
159
|
+
_getNewFeatureId() {
|
|
160
|
+
return ++this.featureIdCounter;
|
|
161
|
+
}
|
|
162
|
+
init() {
|
|
163
|
+
const source = {
|
|
164
|
+
type: 'geojson',
|
|
165
|
+
data: this.data(),
|
|
166
|
+
minzoom: this.minzoom(),
|
|
167
|
+
maxzoom: this.maxzoom(),
|
|
168
|
+
attribution: this.attribution(),
|
|
169
|
+
buffer: this.buffer(),
|
|
170
|
+
tolerance: this.tolerance(),
|
|
171
|
+
cluster: this.cluster(),
|
|
172
|
+
clusterRadius: this.clusterRadius(),
|
|
173
|
+
clusterMaxZoom: this.clusterMaxZoom(),
|
|
174
|
+
clusterMinPoints: this.clusterMinPoints(),
|
|
175
|
+
clusterProperties: this.clusterProperties(),
|
|
176
|
+
lineMetrics: this.lineMetrics(),
|
|
177
|
+
generateId: this.generateId(),
|
|
178
|
+
promoteId: this.promoteId(),
|
|
179
|
+
filter: this.filter(),
|
|
180
|
+
dynamic: this.dynamic(),
|
|
181
|
+
};
|
|
182
|
+
this.mapService.addSource(this.id(), source);
|
|
183
|
+
const sub = this.updateFeatureData.pipe(debounceTime(0)).subscribe(() => {
|
|
184
|
+
const source = this.mapService.getSource(this.id());
|
|
185
|
+
if (source === undefined) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
source.setData(this.data());
|
|
189
|
+
});
|
|
190
|
+
this.sub.add(sub);
|
|
191
|
+
this.sourceAdded = true;
|
|
192
|
+
}
|
|
193
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: GeoJSONSourceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
194
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: GeoJSONSourceComponent, isStandalone: true, selector: "mgl-geojson-source", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: true, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, minzoom: { classPropertyName: "minzoom", publicName: "minzoom", isSignal: true, isRequired: false, transformFunction: null }, maxzoom: { classPropertyName: "maxzoom", publicName: "maxzoom", isSignal: true, isRequired: false, transformFunction: null }, attribution: { classPropertyName: "attribution", publicName: "attribution", isSignal: true, isRequired: false, transformFunction: null }, buffer: { classPropertyName: "buffer", publicName: "buffer", isSignal: true, isRequired: false, transformFunction: null }, tolerance: { classPropertyName: "tolerance", publicName: "tolerance", isSignal: true, isRequired: false, transformFunction: null }, cluster: { classPropertyName: "cluster", publicName: "cluster", isSignal: true, isRequired: false, transformFunction: null }, clusterRadius: { classPropertyName: "clusterRadius", publicName: "clusterRadius", isSignal: true, isRequired: false, transformFunction: null }, clusterMaxZoom: { classPropertyName: "clusterMaxZoom", publicName: "clusterMaxZoom", isSignal: true, isRequired: false, transformFunction: null }, clusterMinPoints: { classPropertyName: "clusterMinPoints", publicName: "clusterMinPoints", isSignal: true, isRequired: false, transformFunction: null }, clusterProperties: { classPropertyName: "clusterProperties", publicName: "clusterProperties", isSignal: true, isRequired: false, transformFunction: null }, lineMetrics: { classPropertyName: "lineMetrics", publicName: "lineMetrics", isSignal: true, isRequired: false, transformFunction: null }, generateId: { classPropertyName: "generateId", publicName: "generateId", isSignal: true, isRequired: false, transformFunction: null }, promoteId: { classPropertyName: "promoteId", publicName: "promoteId", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, dynamic: { classPropertyName: "dynamic", publicName: "dynamic", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { data: "dataChange" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
195
|
+
}
|
|
196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: GeoJSONSourceComponent, decorators: [{
|
|
197
|
+
type: Component,
|
|
198
|
+
args: [{
|
|
199
|
+
selector: 'mgl-geojson-source',
|
|
200
|
+
template: '',
|
|
201
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
202
|
+
}]
|
|
203
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }, { type: i0.Output, args: ["dataChange"] }], minzoom: [{ type: i0.Input, args: [{ isSignal: true, alias: "minzoom", required: false }] }], maxzoom: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxzoom", required: false }] }], attribution: [{ type: i0.Input, args: [{ isSignal: true, alias: "attribution", required: false }] }], buffer: [{ type: i0.Input, args: [{ isSignal: true, alias: "buffer", required: false }] }], tolerance: [{ type: i0.Input, args: [{ isSignal: true, alias: "tolerance", required: false }] }], cluster: [{ type: i0.Input, args: [{ isSignal: true, alias: "cluster", required: false }] }], clusterRadius: [{ type: i0.Input, args: [{ isSignal: true, alias: "clusterRadius", required: false }] }], clusterMaxZoom: [{ type: i0.Input, args: [{ isSignal: true, alias: "clusterMaxZoom", required: false }] }], clusterMinPoints: [{ type: i0.Input, args: [{ isSignal: true, alias: "clusterMinPoints", required: false }] }], clusterProperties: [{ type: i0.Input, args: [{ isSignal: true, alias: "clusterProperties", required: false }] }], lineMetrics: [{ type: i0.Input, args: [{ isSignal: true, alias: "lineMetrics", required: false }] }], generateId: [{ type: i0.Input, args: [{ isSignal: true, alias: "generateId", required: false }] }], promoteId: [{ type: i0.Input, args: [{ isSignal: true, alias: "promoteId", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], dynamic: [{ type: i0.Input, args: [{ isSignal: true, alias: "dynamic", required: false }] }] } });
|
|
204
|
+
//# sourceMappingURL=geojson-source.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geojson-source.component.js","sourceRoot":"","sources":["../../../../../../../libs/ngx-mapbox-gl/src/lib/source/geojson/geojson-source.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,MAAM,EAKN,MAAM,EACN,KAAK,EACL,KAAK,GAEN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;;AAcnD,MAAM,OAAO,sBAAsB;IAGzB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,iBAAiB;IACjB,EAAE,GAAG,KAAK,CAAC,QAAQ,6CAAU,CAAC;IAE9B,oBAAoB;IACpB,IAAI,GAAG,KAAK,0DAAoB,CAAC;IACjC,OAA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QAC/B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;uGA1NU,sBAAsB;2FAAtB,sBAAsB,41EAHvB,EAAE;;2FAGD,sBAAsB;kBALlC,SAAS;mBAAC;oBACT,QAAQ,EAAE,oBAAoB;oBAC9B,QAAQ,EAAE,EAAE;oBACZ,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n NgZone,\n OnChanges,\n OnDestroy,\n OnInit,\n SimpleChanges,\n inject,\n input,\n model,\n type InputSignal,\n} from '@angular/core';\nimport type { GeoJSONSource, GeoJSONSourceSpecification } from 'mapbox-gl';\nimport { fromEvent, Subject, Subscription } from 'rxjs';\nimport { debounceTime, filter } from 'rxjs/operators';\nimport { MapService } from '../../map/map.service';\nimport type { Feature, GeometryObject, GeoJSON } from 'geojson';\n\ntype GeoJSONSourceInputs = {\n [K in keyof Omit<GeoJSONSourceSpecification, 'type'>]: InputSignal<\n Omit<GeoJSONSourceSpecification, 'type'>[K]\n >;\n};\n\n@Component({\n selector: 'mgl-geojson-source',\n template: '',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class GeoJSONSourceComponent\n implements OnInit, OnDestroy, OnChanges, GeoJSONSourceInputs\n{\n private mapService = inject(MapService);\n private zone = inject(NgZone);\n /* Init inputs */\n id = input.required<string>();\n\n /* Dynamic inputs */\n data = model<GeoJSON | string>();\n minzoom = input<GeoJSONSourceSpecification['minzoom']>();\n maxzoom = input<GeoJSONSourceSpecification['maxzoom']>();\n attribution = input<GeoJSONSourceSpecification['attribution']>();\n buffer = input<GeoJSONSourceSpecification['buffer']>();\n tolerance = input<GeoJSONSourceSpecification['tolerance']>();\n cluster = input<GeoJSONSourceSpecification['cluster']>();\n clusterRadius = input<GeoJSONSourceSpecification['clusterRadius']>();\n clusterMaxZoom = input<GeoJSONSourceSpecification['clusterMaxZoom']>();\n clusterMinPoints = input<GeoJSONSourceSpecification['clusterMinPoints']>();\n clusterProperties = input<GeoJSONSourceSpecification['clusterProperties']>();\n lineMetrics = input<GeoJSONSourceSpecification['lineMetrics']>();\n generateId = input<GeoJSONSourceSpecification['generateId']>();\n promoteId = input<GeoJSONSourceSpecification['promoteId']>();\n filter = input<GeoJSONSourceSpecification['filter']>();\n dynamic = input<GeoJSONSourceSpecification['dynamic']>();\n\n updateFeatureData = new Subject();\n\n private sub = new Subscription();\n private sourceAdded = false;\n private featureIdCounter = 0;\n\n ngOnInit() {\n if (!this.data()) {\n this.data.set({\n type: 'FeatureCollection',\n features: [],\n });\n }\n const sub1 = this.mapService.mapLoaded$.subscribe(() => {\n this.init();\n const sub = fromEvent(this.mapService.mapInstance, 'styledata')\n .pipe(filter(() => !this.mapService.mapInstance.getSource(this.id())))\n .subscribe(() => {\n this.init();\n });\n this.sub.add(sub);\n });\n this.sub.add(sub1);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (!this.sourceAdded) {\n return;\n }\n if (\n (changes['minzoom'] && !changes['minzoom'].isFirstChange()) ||\n (changes['maxzoom'] && !changes['maxzoom'].isFirstChange()) ||\n (changes['attribution'] && !changes['attribution'].isFirstChange()) ||\n (changes['buffer'] && !changes['buffer'].isFirstChange()) ||\n (changes['tolerance'] && !changes['tolerance'].isFirstChange()) ||\n (changes['cluster'] && !changes['cluster'].isFirstChange()) ||\n (changes['clusterRadius'] && !changes['clusterRadius'].isFirstChange()) ||\n (changes['clusterMaxZoom'] &&\n !changes['clusterMaxZoom'].isFirstChange()) ||\n (changes['clusterMinPoints'] &&\n !changes['clusterMinPoints'].isFirstChange()) ||\n (changes['clusterProperties'] &&\n !changes['clusterProperties'].isFirstChange()) ||\n (changes['lineMetrics'] && !changes['lineMetrics'].isFirstChange()) ||\n (changes['generateId'] && !changes['generateId'].isFirstChange()) ||\n (changes['promoteId'] && !changes['promoteId'].isFirstChange()) ||\n (changes['filter'] && !changes['filter'].isFirstChange()) ||\n (changes['dynamic'] && !changes['dynamic'].isFirstChange())\n ) {\n this.ngOnDestroy();\n this.ngOnInit();\n }\n if (changes['data'] && !changes['data'].isFirstChange()) {\n const source = this.mapService.getSource<GeoJSONSource>(this.id());\n if (source === undefined) {\n return;\n }\n source.setData(this.data()!);\n }\n }\n\n ngOnDestroy() {\n this.sub.unsubscribe();\n if (this.sourceAdded) {\n this.mapService.removeSource(this.id());\n this.sourceAdded = false;\n }\n }\n\n /**\n * For clustered sources, fetches the zoom at which the given cluster expands.\n *\n * @param clusterId The value of the cluster's cluster_id property.\n */\n async getClusterExpansionZoom(clusterId: number) {\n const source = this.mapService.getSource<GeoJSONSource>(this.id())!;\n return this.zone.run(\n async () =>\n new Promise<number | null | undefined>((resolve, reject) => {\n source.getClusterExpansionZoom(clusterId, (error, zoom) => {\n if (error) {\n reject(error);\n } else {\n resolve(zoom);\n }\n });\n }),\n );\n }\n\n /**\n * For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features).\n *\n * @param clusterId The value of the cluster's cluster_id property.\n */\n async getClusterChildren(clusterId: number) {\n const source = this.mapService.getSource<GeoJSONSource>(this.id())!;\n return this.zone.run(\n async () =>\n new Promise<Feature<GeometryObject>[] | null | undefined>(\n (resolve, reject) => {\n source.getClusterChildren(clusterId, (error, features) => {\n if (error) {\n reject(error);\n } else {\n resolve(features);\n }\n });\n },\n ),\n );\n }\n\n /**\n * For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features).\n *\n * @param clusterId The value of the cluster's cluster_id property.\n * @param limit The maximum number of features to return.\n * @param offset The number of features to skip (e.g. for pagination).\n */\n async getClusterLeaves(clusterId: number, limit: number, offset: number) {\n const source = this.mapService.getSource<GeoJSONSource>(this.id())!;\n return this.zone.run(\n async () =>\n new Promise<Feature<GeometryObject>[]>((resolve, reject) => {\n source.getClusterLeaves(\n clusterId,\n limit,\n offset,\n (error, features) => {\n if (error) {\n reject(error);\n } else {\n resolve(features || []);\n }\n },\n );\n }),\n );\n }\n\n _addFeature(feature: GeoJSON.Feature<GeoJSON.GeometryObject>) {\n const collection =\n this.data() as GeoJSON.FeatureCollection<GeoJSON.GeometryObject>;\n collection.features.push(feature);\n this.updateFeatureData.next(null);\n }\n\n _removeFeature(feature: GeoJSON.Feature<GeoJSON.GeometryObject>) {\n const collection =\n this.data() as GeoJSON.FeatureCollection<GeoJSON.GeometryObject>;\n const index = collection.features.indexOf(feature);\n if (index > -1) {\n collection.features.splice(index, 1);\n }\n this.updateFeatureData.next(null);\n }\n\n _getNewFeatureId() {\n return ++this.featureIdCounter;\n }\n\n private init() {\n const source: GeoJSONSourceSpecification = {\n type: 'geojson',\n data: this.data(),\n minzoom: this.minzoom(),\n maxzoom: this.maxzoom(),\n attribution: this.attribution(),\n buffer: this.buffer(),\n tolerance: this.tolerance(),\n cluster: this.cluster(),\n clusterRadius: this.clusterRadius(),\n clusterMaxZoom: this.clusterMaxZoom(),\n clusterMinPoints: this.clusterMinPoints(),\n clusterProperties: this.clusterProperties(),\n lineMetrics: this.lineMetrics(),\n generateId: this.generateId(),\n promoteId: this.promoteId(),\n filter: this.filter(),\n dynamic: this.dynamic(),\n };\n this.mapService.addSource(this.id(), source);\n const sub = this.updateFeatureData.pipe(debounceTime(0)).subscribe(() => {\n const source = this.mapService.getSource<GeoJSONSource>(this.id());\n if (source === undefined) {\n return;\n }\n source.setData(this.data()!);\n });\n this.sub.add(sub);\n this.sourceAdded = true;\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject, input, } from '@angular/core';
|
|
2
|
+
import { MapService } from '../map/map.service';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export class ImageSourceComponent {
|
|
5
|
+
mapService = inject(MapService);
|
|
6
|
+
/* Init inputs */
|
|
7
|
+
id = input.required(...(ngDevMode ? [{ debugName: "id" }] : []));
|
|
8
|
+
/* Dynamic inputs */
|
|
9
|
+
url = input(...(ngDevMode ? [undefined, { debugName: "url" }] : []));
|
|
10
|
+
coordinates = input.required(...(ngDevMode ? [{ debugName: "coordinates" }] : []));
|
|
11
|
+
sub;
|
|
12
|
+
sourceId;
|
|
13
|
+
ngOnInit() {
|
|
14
|
+
this.sub = this.mapService.mapLoaded$.subscribe(() => this.init());
|
|
15
|
+
}
|
|
16
|
+
ngOnChanges(changes) {
|
|
17
|
+
if (this.sourceId === undefined) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const source = this.mapService.getSource(this.sourceId);
|
|
21
|
+
if (source === undefined) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
source.updateImage({
|
|
25
|
+
url: this.url(),
|
|
26
|
+
coordinates: changes['coordinates'] === undefined ? undefined : this.coordinates(),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
ngOnDestroy() {
|
|
30
|
+
if (this.sub !== undefined) {
|
|
31
|
+
this.sub.unsubscribe();
|
|
32
|
+
}
|
|
33
|
+
if (this.sourceId !== undefined) {
|
|
34
|
+
this.mapService.removeSource(this.sourceId);
|
|
35
|
+
this.sourceId = undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
init() {
|
|
39
|
+
const imageSource = {
|
|
40
|
+
type: 'image',
|
|
41
|
+
url: this.url(),
|
|
42
|
+
coordinates: this.coordinates(),
|
|
43
|
+
};
|
|
44
|
+
this.mapService.addSource(this.id(), imageSource);
|
|
45
|
+
this.sourceId = this.id();
|
|
46
|
+
}
|
|
47
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ImageSourceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
48
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: ImageSourceComponent, isStandalone: true, selector: "mgl-image-source", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: true, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: false, transformFunction: null }, coordinates: { classPropertyName: "coordinates", publicName: "coordinates", isSignal: true, isRequired: true, transformFunction: null } }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
49
|
+
}
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ImageSourceComponent, decorators: [{
|
|
51
|
+
type: Component,
|
|
52
|
+
args: [{
|
|
53
|
+
selector: 'mgl-image-source',
|
|
54
|
+
template: '',
|
|
55
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
56
|
+
}]
|
|
57
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: true }] }], url: [{ type: i0.Input, args: [{ isSignal: true, alias: "url", required: false }] }], coordinates: [{ type: i0.Input, args: [{ isSignal: true, alias: "coordinates", required: true }] }] } });
|
|
58
|
+
//# sourceMappingURL=image-source.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-source.component.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/source/image-source.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EAKT,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;;AAchD,MAAM,OAAO,oBAAoB;IAGvB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACxC,iBAAiB;IACjB,EAAE,GAAG,KAAK,CAAC,QAAQ,6CAAU,CAAC;IAE9B,oBAAoB;IACpB,GAAG,GAAG,KAAK,yDAAU,CAAC;IACtB,WAAW,GAAG,KAAK,CAAC,QAAQ,sDAA2C,CAAC;IAEhE,GAAG,CAAe;IAClB,QAAQ,CAAU;IAE1B,QAAQ;QACN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AAE,CAAC;IAC5B,CAAC;uGApDU,oBAAoB;2FAApB,oBAAoB,sdAHrB,EAAE;;2FAGD,oBAAoB;kBALhC,SAAS;mBAAC;oBACT,QAAQ,EAAE,kBAAkB;oBAC5B,QAAQ,EAAE,EAAE;oBACZ,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n OnChanges,\n OnDestroy,\n OnInit,\n SimpleChanges,\n inject,\n input,\n} from '@angular/core';\nimport type { ImageSource, ImageSourceSpecification } from 'mapbox-gl';\nimport { Subscription } from 'rxjs';\nimport { MapService } from '../map/map.service';\nimport type { InputSignal } from '@angular/core';\n\ntype ImageSourceInputs = {\n [K in keyof Omit<ImageSourceSpecification, 'type'>]: InputSignal<\n Omit<ImageSourceSpecification, 'type'>[K]\n >;\n};\n\n@Component({\n selector: 'mgl-image-source',\n template: '',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ImageSourceComponent\n implements OnInit, OnDestroy, OnChanges, ImageSourceInputs\n{\n private mapService = inject(MapService);\n /* Init inputs */\n id = input.required<string>();\n\n /* Dynamic inputs */\n url = input<string>();\n coordinates = input.required<ImageSourceSpecification['coordinates']>();\n\n private sub: Subscription;\n private sourceId?: string;\n\n ngOnInit() {\n this.sub = this.mapService.mapLoaded$.subscribe(() => this.init());\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (this.sourceId === undefined) {\n return;\n }\n const source = this.mapService.getSource<ImageSource>(this.sourceId);\n if (source === undefined) {\n return;\n }\n source.updateImage({\n url: this.url()!,\n coordinates:\n changes['coordinates'] === undefined ? undefined : this.coordinates(),\n });\n }\n\n ngOnDestroy() {\n if (this.sub !== undefined) {\n this.sub.unsubscribe();\n }\n\n if (this.sourceId !== undefined) {\n this.mapService.removeSource(this.sourceId);\n this.sourceId = undefined;\n }\n }\n\n private init() {\n const imageSource: ImageSourceSpecification = {\n type: 'image',\n url: this.url(),\n coordinates: this.coordinates(),\n };\n this.mapService.addSource(this.id(), imageSource);\n this.sourceId = this.id();\n }\n}\n"]}
|