@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.
Files changed (80) hide show
  1. package/README.md +3 -0
  2. package/esm2022/index.js +32 -0
  3. package/esm2022/index.js.map +1 -0
  4. package/esm2022/lib/control/attribution-control.directive.js +39 -0
  5. package/esm2022/lib/control/attribution-control.directive.js.map +1 -0
  6. package/esm2022/lib/control/control.component.js +62 -0
  7. package/esm2022/lib/control/control.component.js.map +1 -0
  8. package/esm2022/lib/control/fullscreen-control.directive.js +39 -0
  9. package/esm2022/lib/control/fullscreen-control.directive.js.map +1 -0
  10. package/esm2022/lib/control/geolocate-control.directive.js +52 -0
  11. package/esm2022/lib/control/geolocate-control.directive.js.map +1 -0
  12. package/esm2022/lib/control/navigation-control.directive.js +39 -0
  13. package/esm2022/lib/control/navigation-control.directive.js.map +1 -0
  14. package/esm2022/lib/control/scale-control.directive.js +45 -0
  15. package/esm2022/lib/control/scale-control.directive.js.map +1 -0
  16. package/esm2022/lib/draggable/draggable.directive.js +121 -0
  17. package/esm2022/lib/draggable/draggable.directive.js.map +1 -0
  18. package/esm2022/lib/image/image.component.js +79 -0
  19. package/esm2022/lib/image/image.component.js.map +1 -0
  20. package/esm2022/lib/layer/layer.component.js +139 -0
  21. package/esm2022/lib/layer/layer.component.js.map +1 -0
  22. package/esm2022/lib/map/map.component.js +381 -0
  23. package/esm2022/lib/map/map.component.js.map +1 -0
  24. package/esm2022/lib/map/map.service.js +725 -0
  25. package/esm2022/lib/map/map.service.js.map +1 -0
  26. package/esm2022/lib/map/map.types.js +30 -0
  27. package/esm2022/lib/map/map.types.js.map +1 -0
  28. package/esm2022/lib/marker/marker.component.js +114 -0
  29. package/esm2022/lib/marker/marker.component.js.map +1 -0
  30. package/esm2022/lib/markers-for-clusters/markers-for-clusters.component.js +168 -0
  31. package/esm2022/lib/markers-for-clusters/markers-for-clusters.component.js.map +1 -0
  32. package/esm2022/lib/popup/popup.component.js +124 -0
  33. package/esm2022/lib/popup/popup.component.js.map +1 -0
  34. package/esm2022/lib/provide-mapbox-gl.js +8 -0
  35. package/esm2022/lib/provide-mapbox-gl.js.map +1 -0
  36. package/esm2022/lib/source/canvas-source.component.js +74 -0
  37. package/esm2022/lib/source/canvas-source.component.js.map +1 -0
  38. package/esm2022/lib/source/geojson/feature.component.js +42 -0
  39. package/esm2022/lib/source/geojson/feature.component.js.map +1 -0
  40. package/esm2022/lib/source/geojson/geojson-source.component.js +204 -0
  41. package/esm2022/lib/source/geojson/geojson-source.component.js.map +1 -0
  42. package/esm2022/lib/source/image-source.component.js +58 -0
  43. package/esm2022/lib/source/image-source.component.js.map +1 -0
  44. package/esm2022/lib/source/raster-dem-source.component.js +91 -0
  45. package/esm2022/lib/source/raster-dem-source.component.js.map +1 -0
  46. package/esm2022/lib/source/raster-source.component.js +85 -0
  47. package/esm2022/lib/source/raster-source.component.js.map +1 -0
  48. package/esm2022/lib/source/vector-source.component.js +99 -0
  49. package/esm2022/lib/source/vector-source.component.js.map +1 -0
  50. package/esm2022/lib/source/video-source.component.js +80 -0
  51. package/esm2022/lib/source/video-source.component.js.map +1 -0
  52. package/esm2022/ngx-mapbox-gl.js +5 -0
  53. package/esm2022/ngx-mapbox-gl.js.map +1 -0
  54. package/index.d.ts +24 -0
  55. package/lib/control/attribution-control.directive.d.ts +11 -0
  56. package/lib/control/control.component.d.ts +21 -0
  57. package/lib/control/fullscreen-control.directive.d.ts +11 -0
  58. package/lib/control/geolocate-control.directive.d.ts +15 -0
  59. package/lib/control/navigation-control.directive.d.ts +11 -0
  60. package/lib/control/scale-control.directive.d.ts +12 -0
  61. package/lib/draggable/draggable.directive.d.ts +20 -0
  62. package/lib/image/image.component.d.ts +34 -0
  63. package/lib/layer/layer.component.d.ts +422 -0
  64. package/lib/map/map.component.d.ts +185 -0
  65. package/lib/map/map.service.d.ts +123 -0
  66. package/lib/map/map.types.d.ts +72 -0
  67. package/lib/marker/marker.component.d.ts +31 -0
  68. package/lib/markers-for-clusters/markers-for-clusters.component.d.ts +28 -0
  69. package/lib/popup/popup.component.d.ts +33 -0
  70. package/lib/provide-mapbox-gl.d.ts +6 -0
  71. package/lib/source/canvas-source.component.d.ts +23 -0
  72. package/lib/source/geojson/feature.component.d.ts +16 -0
  73. package/lib/source/geojson/geojson-source.component.d.ts +63 -0
  74. package/lib/source/image-source.component.d.ts +22 -0
  75. package/lib/source/raster-dem-source.component.d.ts +23 -0
  76. package/lib/source/raster-source.component.d.ts +23 -0
  77. package/lib/source/vector-source.component.d.ts +24 -0
  78. package/lib/source/video-source.component.d.ts +24 -0
  79. package/ngx-mapbox-gl.d.ts +5 -0
  80. package/package.json +44 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # ngx-mapbox-gl
2
+
3
+ https://wykks.github.io/ngx-mapbox-gl
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Public API Surface of ngx-mapbox-gl
3
+ */
4
+ export * from './lib/provide-mapbox-gl';
5
+ // Expose NgxMapboxGlModule and GeocoderControlDirective provided injection tokens
6
+ export * from './lib/control/attribution-control.directive';
7
+ // Expose control component to allow custom directives
8
+ export * from './lib/control/control.component';
9
+ export * from './lib/control/fullscreen-control.directive';
10
+ export * from './lib/control/geolocate-control.directive';
11
+ export * from './lib/control/navigation-control.directive';
12
+ export * from './lib/control/scale-control.directive';
13
+ export * from './lib/draggable/draggable.directive';
14
+ export * from './lib/image/image.component';
15
+ export * from './lib/layer/layer.component';
16
+ export * from './lib/map/map.component';
17
+ // Expose MapService for ngx-mapbox-gl extensions
18
+ export * from './lib/map/map.service';
19
+ export * from './lib/map/map.types';
20
+ export * from './lib/marker/marker.component';
21
+ export * from './lib/markers-for-clusters/markers-for-clusters.component';
22
+ export * from './lib/popup/popup.component';
23
+ export * from './lib/source/canvas-source.component';
24
+ export * from './lib/source/geojson/feature.component';
25
+ // Expose GeoJSONSourceComponent to access cluster functions
26
+ export * from './lib/source/geojson/geojson-source.component';
27
+ export * from './lib/source/image-source.component';
28
+ export * from './lib/source/raster-dem-source.component';
29
+ export * from './lib/source/raster-source.component';
30
+ export * from './lib/source/vector-source.component';
31
+ export * from './lib/source/video-source.component';
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/ngx-mapbox-gl/src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,yBAAyB,CAAC;AACxC,kFAAkF;AAClF,cAAc,6CAA6C,CAAC;AAC5D,sDAAsD;AACtD,cAAc,iCAAiC,CAAC;AAChD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,iDAAiD;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2DAA2D,CAAC;AAC1E,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,4DAA4D;AAC5D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC","sourcesContent":["/*\n * Public API Surface of ngx-mapbox-gl\n */\n\nexport * from './lib/provide-mapbox-gl';\n// Expose NgxMapboxGlModule and GeocoderControlDirective provided injection tokens\nexport * from './lib/control/attribution-control.directive';\n// Expose control component to allow custom directives\nexport * from './lib/control/control.component';\nexport * from './lib/control/fullscreen-control.directive';\nexport * from './lib/control/geolocate-control.directive';\nexport * from './lib/control/navigation-control.directive';\nexport * from './lib/control/scale-control.directive';\nexport * from './lib/draggable/draggable.directive';\nexport * from './lib/image/image.component';\nexport * from './lib/layer/layer.component';\nexport * from './lib/map/map.component';\n// Expose MapService for ngx-mapbox-gl extensions\nexport * from './lib/map/map.service';\nexport * from './lib/map/map.types';\nexport * from './lib/marker/marker.component';\nexport * from './lib/markers-for-clusters/markers-for-clusters.component';\nexport * from './lib/popup/popup.component';\nexport * from './lib/source/canvas-source.component';\nexport * from './lib/source/geojson/feature.component';\n// Expose GeoJSONSourceComponent to access cluster functions\nexport * from './lib/source/geojson/geojson-source.component';\nexport * from './lib/source/image-source.component';\nexport * from './lib/source/raster-dem-source.component';\nexport * from './lib/source/raster-source.component';\nexport * from './lib/source/vector-source.component';\nexport * from './lib/source/video-source.component';\n"]}
@@ -0,0 +1,39 @@
1
+ import { Directive, inject, input } from '@angular/core';
2
+ import { AttributionControl } from 'mapbox-gl';
3
+ import { MapService } from '../map/map.service';
4
+ import { ControlComponent } from './control.component';
5
+ import * as i0 from "@angular/core";
6
+ export class AttributionControlDirective {
7
+ mapService = inject(MapService);
8
+ controlComponent = inject((ControlComponent), { host: true });
9
+ /* Init inputs */
10
+ compact = input(...(ngDevMode ? [undefined, { debugName: "compact" }] : []));
11
+ customAttribution = input(...(ngDevMode ? [undefined, { debugName: "customAttribution" }] : []));
12
+ ngAfterContentInit() {
13
+ this.mapService.mapCreated$.subscribe(() => {
14
+ if (this.controlComponent.control) {
15
+ throw new Error('Another control is already set for this control');
16
+ }
17
+ const options = {};
18
+ const compact = this.compact();
19
+ const customAttribution = this.customAttribution();
20
+ if (compact !== undefined) {
21
+ options.compact = compact;
22
+ }
23
+ if (customAttribution !== undefined) {
24
+ options.customAttribution = customAttribution;
25
+ }
26
+ this.controlComponent.control = new AttributionControl(options);
27
+ this.mapService.addControl(this.controlComponent.control, this.controlComponent.position());
28
+ });
29
+ }
30
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: AttributionControlDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
31
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: AttributionControlDirective, isStandalone: true, selector: "[mglAttribution]", inputs: { compact: { classPropertyName: "compact", publicName: "compact", isSignal: true, isRequired: false, transformFunction: null }, customAttribution: { classPropertyName: "customAttribution", publicName: "customAttribution", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
32
+ }
33
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: AttributionControlDirective, decorators: [{
34
+ type: Directive,
35
+ args: [{
36
+ selector: '[mglAttribution]',
37
+ }]
38
+ }], propDecorators: { compact: [{ type: i0.Input, args: [{ isSignal: true, alias: "compact", required: false }] }], customAttribution: [{ type: i0.Input, args: [{ isSignal: true, alias: "customAttribution", required: false }] }] } });
39
+ //# sourceMappingURL=attribution-control.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribution-control.directive.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/control/attribution-control.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;;AAKvD,MAAM,OAAO,2BAA2B;IAC9B,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,gBAAgB,GAAG,MAAM,CAC/B,CAAA,gBAAoC,CAAA,EACpC,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IAEF,iBAAiB;IACjB,OAAO,GAAG,KAAK,6DAAW,CAAC;IAC3B,iBAAiB,GAAG,KAAK,uEAAqB,CAAC;IAE/C,kBAAkB;QAChB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE;YACzC,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YACrE,CAAC;YACD,MAAM,OAAO,GAGT,EAAE,CAAC;YACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAC/B,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACnD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;YAC5B,CAAC;YACD,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;gBACpC,OAAO,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;YAChD,CAAC;YACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU,CAAC,UAAU,CACxB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAC7B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;uGAlCU,2BAA2B;2FAA3B,2BAA2B;;2FAA3B,2BAA2B;kBAHvC,SAAS;mBAAC;oBACT,QAAQ,EAAE,kBAAkB;iBAC7B","sourcesContent":["import { AfterContentInit, Directive, inject, input } from '@angular/core';\nimport { AttributionControl } from 'mapbox-gl';\nimport { MapService } from '../map/map.service';\nimport { ControlComponent } from './control.component';\n\n@Directive({\n selector: '[mglAttribution]',\n})\nexport class AttributionControlDirective implements AfterContentInit {\n private mapService = inject(MapService);\n private controlComponent = inject<ControlComponent<AttributionControl>>(\n ControlComponent<AttributionControl>,\n { host: true },\n );\n\n /* Init inputs */\n compact = input<boolean>();\n customAttribution = input<string | string[]>();\n\n ngAfterContentInit() {\n this.mapService.mapCreated$.subscribe(() => {\n if (this.controlComponent.control) {\n throw new Error('Another control is already set for this control');\n }\n const options: {\n compact?: boolean;\n customAttribution?: string | string[];\n } = {};\n const compact = this.compact();\n const customAttribution = this.customAttribution();\n if (compact !== undefined) {\n options.compact = compact;\n }\n if (customAttribution !== undefined) {\n options.customAttribution = customAttribution;\n }\n this.controlComponent.control = new AttributionControl(options);\n this.mapService.addControl(\n this.controlComponent.control,\n this.controlComponent.position(),\n );\n });\n }\n}\n"]}
@@ -0,0 +1,62 @@
1
+ import { ChangeDetectionStrategy, Component, ElementRef, ViewChild, inject, input, } from '@angular/core';
2
+ import { MapService } from '../map/map.service';
3
+ import * as i0 from "@angular/core";
4
+ export class CustomControl {
5
+ container;
6
+ constructor(container) {
7
+ this.container = container;
8
+ }
9
+ onAdd() {
10
+ return this.container;
11
+ }
12
+ onRemove() {
13
+ return this.container.parentNode.removeChild(this.container);
14
+ }
15
+ getDefaultPosition() {
16
+ return 'top-right';
17
+ }
18
+ }
19
+ export class ControlComponent {
20
+ mapService = inject(MapService);
21
+ /* Init inputs */
22
+ position = input(...(ngDevMode ? [undefined, { debugName: "position" }] : []));
23
+ content;
24
+ control;
25
+ controlAdded = false;
26
+ ngAfterContentInit() {
27
+ if (this.content.nativeElement.childNodes.length) {
28
+ this.control = new CustomControl(this.content.nativeElement);
29
+ this.mapService.mapCreated$.subscribe(() => {
30
+ this.mapService.addControl(this.control, this.position());
31
+ this.controlAdded = true;
32
+ });
33
+ }
34
+ }
35
+ ngOnDestroy() {
36
+ if (this.controlAdded) {
37
+ this.mapService.removeControl(this.control);
38
+ }
39
+ }
40
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
41
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: ControlComponent, isStandalone: true, selector: "mgl-control", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, static: true }], ngImport: i0, template: `
42
+ <div class="mapboxgl-ctrl" #content>
43
+ <ng-content />
44
+ </div>
45
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
46
+ }
47
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ControlComponent, decorators: [{
48
+ type: Component,
49
+ args: [{
50
+ selector: 'mgl-control',
51
+ template: `
52
+ <div class="mapboxgl-ctrl" #content>
53
+ <ng-content />
54
+ </div>
55
+ `,
56
+ changeDetection: ChangeDetectionStrategy.OnPush,
57
+ }]
58
+ }], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], content: [{
59
+ type: ViewChild,
60
+ args: ['content', { static: true }]
61
+ }] } });
62
+ //# sourceMappingURL=control.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.component.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/control/control.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACvB,SAAS,EACT,UAAU,EAEV,SAAS,EACT,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;;AAEhD,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,SAAsB;QAAtB,cAAS,GAAT,SAAS,CAAa;IAAG,CAAC;IAE9C,KAAK;QACH,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,UAAW,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;IAED,kBAAkB;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAWD,MAAM,OAAO,gBAAgB;IAGnB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAExC,iBAAiB;IACjB,QAAQ,GAAG,KAAK,8DAA6D,CAAC;IAEtC,OAAO,CAAa;IAE5D,OAAO,CAAoB;IAEnB,YAAY,GAAG,KAAK,CAAC;IAE7B,kBAAkB;QAChB,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACjD,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAC7D,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE;gBACzC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,OAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC3D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;uGA5BU,gBAAgB;2FAAhB,gBAAgB,sUAPjB;;;;GAIT;;2FAGU,gBAAgB;kBAT5B,SAAS;mBAAC;oBACT,QAAQ,EAAE,aAAa;oBACvB,QAAQ,EAAE;;;;GAIT;oBACD,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD;;sBASE,SAAS;uBAAC,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE","sourcesContent":["import {\n AfterContentInit,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n OnDestroy,\n ViewChild,\n inject,\n input,\n} from '@angular/core';\nimport { IControl, type ControlPosition } from 'mapbox-gl';\nimport { MapService } from '../map/map.service';\n\nexport class CustomControl implements IControl {\n constructor(private container: HTMLElement) {}\n\n onAdd() {\n return this.container;\n }\n\n onRemove() {\n return this.container.parentNode!.removeChild(this.container);\n }\n\n getDefaultPosition(): ControlPosition {\n return 'top-right';\n }\n}\n\n@Component({\n selector: 'mgl-control',\n template: `\n <div class=\"mapboxgl-ctrl\" #content>\n <ng-content />\n </div>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ControlComponent<T extends IControl>\n implements OnDestroy, AfterContentInit\n{\n private mapService = inject(MapService);\n\n /* Init inputs */\n position = input<'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'>();\n\n @ViewChild('content', { static: true }) content: ElementRef;\n\n control: T | CustomControl;\n\n private controlAdded = false;\n\n ngAfterContentInit() {\n if (this.content.nativeElement.childNodes.length) {\n this.control = new CustomControl(this.content.nativeElement);\n this.mapService.mapCreated$.subscribe(() => {\n this.mapService.addControl(this.control!, this.position());\n this.controlAdded = true;\n });\n }\n }\n\n ngOnDestroy() {\n if (this.controlAdded) {\n this.mapService.removeControl(this.control);\n }\n }\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import { Directive, HostListener, inject, input, } from '@angular/core';
2
+ import { FullscreenControl } from 'mapbox-gl';
3
+ import { MapService } from '../map/map.service';
4
+ import { ControlComponent } from './control.component';
5
+ import * as i0 from "@angular/core";
6
+ export class FullscreenControlDirective {
7
+ mapService = inject(MapService);
8
+ controlComponent = inject((ControlComponent), { host: true });
9
+ /* Init inputs */
10
+ container = input(...(ngDevMode ? [undefined, { debugName: "container" }] : []));
11
+ onFullscreen(target) {
12
+ if (target) {
13
+ this.mapService.mapInstance.resize();
14
+ }
15
+ }
16
+ ngAfterContentInit() {
17
+ this.mapService.mapCreated$.subscribe(() => {
18
+ if (this.controlComponent.control) {
19
+ throw new Error('Another control is already set for this control');
20
+ }
21
+ this.controlComponent.control = new FullscreenControl({
22
+ container: this.container(),
23
+ });
24
+ this.mapService.addControl(this.controlComponent.control, this.controlComponent.position());
25
+ });
26
+ }
27
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FullscreenControlDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
28
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: FullscreenControlDirective, isStandalone: true, selector: "[mglFullscreen]", inputs: { container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "window:webkitfullscreenchange": "onFullscreen($event.target)" } }, ngImport: i0 });
29
+ }
30
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FullscreenControlDirective, decorators: [{
31
+ type: Directive,
32
+ args: [{
33
+ selector: '[mglFullscreen]',
34
+ }]
35
+ }], propDecorators: { container: [{ type: i0.Input, args: [{ isSignal: true, alias: "container", required: false }] }], onFullscreen: [{
36
+ type: HostListener,
37
+ args: ['window:webkitfullscreenchange', ['$event.target']]
38
+ }] } });
39
+ //# sourceMappingURL=fullscreen-control.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fullscreen-control.directive.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/control/fullscreen-control.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,YAAY,EACZ,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;;AAKvD,MAAM,OAAO,0BAA0B;IAC7B,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,gBAAgB,GAAG,MAAM,CAC/B,CAAA,gBAAmC,CAAA,EACnC,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IAEF,iBAAiB;IACjB,SAAS,GAAG,KAAK,+DAAe,CAAC;IAGjC,YAAY,CAAC,MAA0B;QACrC,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE;YACzC,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YACrE,CAAC;YACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,iBAAiB,CAAC;gBACpD,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;aAC5B,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,UAAU,CACxB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAC7B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;uGA9BU,0BAA0B;2FAA1B,0BAA0B;;2FAA1B,0BAA0B;kBAHtC,SAAS;mBAAC;oBACT,QAAQ,EAAE,iBAAiB;iBAC5B;;sBAWE,YAAY;uBAAC,+BAA+B,EAAE,CAAC,eAAe,CAAC","sourcesContent":["import {\n AfterContentInit,\n Directive,\n HostListener,\n inject,\n input,\n} from '@angular/core';\nimport { FullscreenControl } from 'mapbox-gl';\nimport { MapService } from '../map/map.service';\nimport { ControlComponent } from './control.component';\n\n@Directive({\n selector: '[mglFullscreen]',\n})\nexport class FullscreenControlDirective implements AfterContentInit {\n private mapService = inject(MapService);\n private controlComponent = inject<ControlComponent<FullscreenControl>>(\n ControlComponent<FullscreenControl>,\n { host: true },\n );\n\n /* Init inputs */\n container = input<HTMLElement>();\n\n @HostListener('window:webkitfullscreenchange', ['$event.target'])\n onFullscreen(target: EventTarget | null) {\n if (target) {\n this.mapService.mapInstance.resize();\n }\n }\n\n ngAfterContentInit() {\n this.mapService.mapCreated$.subscribe(() => {\n if (this.controlComponent.control) {\n throw new Error('Another control is already set for this control');\n }\n this.controlComponent.control = new FullscreenControl({\n container: this.container(),\n });\n this.mapService.addControl(\n this.controlComponent.control,\n this.controlComponent.position(),\n );\n });\n }\n}\n"]}
@@ -0,0 +1,52 @@
1
+ import { Directive, EventEmitter, Output, inject, input, } from '@angular/core';
2
+ import { GeolocateControl } from 'mapbox-gl';
3
+ import { MapService } from '../map/map.service';
4
+ import { ControlComponent } from './control.component';
5
+ import * as i0 from "@angular/core";
6
+ export class GeolocateControlDirective {
7
+ mapService = inject(MapService);
8
+ controlComponent = inject((ControlComponent), { host: true });
9
+ /* Init inputs */
10
+ positionOptions = input(...(ngDevMode ? [undefined, { debugName: "positionOptions" }] : []));
11
+ fitBoundsOptions = input(...(ngDevMode ? [undefined, { debugName: "fitBoundsOptions" }] : []));
12
+ trackUserLocation = input(...(ngDevMode ? [undefined, { debugName: "trackUserLocation" }] : []));
13
+ showUserLocation = input(...(ngDevMode ? [undefined, { debugName: "showUserLocation" }] : []));
14
+ showUserHeading = input(...(ngDevMode ? [undefined, { debugName: "showUserHeading" }] : []));
15
+ geolocate = new EventEmitter();
16
+ ngAfterContentInit() {
17
+ this.mapService.mapCreated$.subscribe(() => {
18
+ if (this.controlComponent.control) {
19
+ throw new Error('Another control is already set for this control');
20
+ }
21
+ const options = {
22
+ positionOptions: this.positionOptions(),
23
+ fitBoundsOptions: this.fitBoundsOptions(),
24
+ trackUserLocation: this.trackUserLocation(),
25
+ showUserLocation: this.showUserLocation(),
26
+ showUserHeading: this.showUserHeading(),
27
+ };
28
+ Object.keys(options).forEach((key) => {
29
+ const tkey = key;
30
+ if (options[tkey] === undefined) {
31
+ delete options[tkey];
32
+ }
33
+ });
34
+ this.controlComponent.control = new GeolocateControl(options);
35
+ this.controlComponent.control.on('geolocate', (data) => {
36
+ this.geolocate.emit(data);
37
+ });
38
+ this.mapService.addControl(this.controlComponent.control, this.controlComponent.position());
39
+ });
40
+ }
41
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: GeolocateControlDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
42
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: GeolocateControlDirective, isStandalone: true, selector: "[mglGeolocate]", inputs: { positionOptions: { classPropertyName: "positionOptions", publicName: "positionOptions", isSignal: true, isRequired: false, transformFunction: null }, fitBoundsOptions: { classPropertyName: "fitBoundsOptions", publicName: "fitBoundsOptions", isSignal: true, isRequired: false, transformFunction: null }, trackUserLocation: { classPropertyName: "trackUserLocation", publicName: "trackUserLocation", isSignal: true, isRequired: false, transformFunction: null }, showUserLocation: { classPropertyName: "showUserLocation", publicName: "showUserLocation", isSignal: true, isRequired: false, transformFunction: null }, showUserHeading: { classPropertyName: "showUserHeading", publicName: "showUserHeading", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { geolocate: "geolocate" }, ngImport: i0 });
43
+ }
44
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: GeolocateControlDirective, decorators: [{
45
+ type: Directive,
46
+ args: [{
47
+ selector: '[mglGeolocate]',
48
+ }]
49
+ }], propDecorators: { positionOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "positionOptions", required: false }] }], fitBoundsOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "fitBoundsOptions", required: false }] }], trackUserLocation: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackUserLocation", required: false }] }], showUserLocation: [{ type: i0.Input, args: [{ isSignal: true, alias: "showUserLocation", required: false }] }], showUserHeading: [{ type: i0.Input, args: [{ isSignal: true, alias: "showUserHeading", required: false }] }], geolocate: [{
50
+ type: Output
51
+ }] } });
52
+ //# sourceMappingURL=geolocate-control.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geolocate-control.directive.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/control/geolocate-control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C,CAAC,GAAW,EAAE,EAAE;gBAC3C,MAAM,IAAI,GAAG,GAA2B,CAAC;gBACzC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;oBAChC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC9D,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE;gBACrD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,UAAU,CACxB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAC7B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;uGA9CU,yBAAyB;2FAAzB,yBAAyB;;2FAAzB,yBAAyB;kBAHrC,SAAS;mBAAC;oBACT,QAAQ,EAAE,gBAAgB;iBAC3B;;sBAeE,MAAM","sourcesContent":["import {\n AfterContentInit,\n Directive,\n EventEmitter,\n Output,\n inject,\n input,\n} from '@angular/core';\nimport { GeolocateControl, type MapOptions } from 'mapbox-gl';\nimport { MapService } from '../map/map.service';\nimport { ControlComponent } from './control.component';\n\n@Directive({\n selector: '[mglGeolocate]',\n})\nexport class GeolocateControlDirective implements AfterContentInit {\n private mapService = inject(MapService);\n private controlComponent = inject<ControlComponent<GeolocateControl>>(\n ControlComponent<GeolocateControl>,\n { host: true },\n );\n\n /* Init inputs */\n positionOptions = input<PositionOptions>();\n fitBoundsOptions = input<MapOptions['fitBoundsOptions']>();\n trackUserLocation = input<boolean>();\n showUserLocation = input<boolean>();\n showUserHeading = input<boolean>();\n\n @Output()\n geolocate: EventEmitter<GeolocationPosition> =\n new EventEmitter<GeolocationPosition>();\n\n ngAfterContentInit() {\n this.mapService.mapCreated$.subscribe(() => {\n if (this.controlComponent.control) {\n throw new Error('Another control is already set for this control');\n }\n const options = {\n positionOptions: this.positionOptions(),\n fitBoundsOptions: this.fitBoundsOptions(),\n trackUserLocation: this.trackUserLocation(),\n showUserLocation: this.showUserLocation(),\n showUserHeading: this.showUserHeading(),\n };\n\n Object.keys(options).forEach((key: string) => {\n const tkey = key as keyof typeof options;\n if (options[tkey] === undefined) {\n delete options[tkey];\n }\n });\n this.controlComponent.control = new GeolocateControl(options);\n this.controlComponent.control.on('geolocate', (data) => {\n this.geolocate.emit(data);\n });\n this.mapService.addControl(\n this.controlComponent.control,\n this.controlComponent.position(),\n );\n });\n }\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import { Directive, inject, input } from '@angular/core';
2
+ import { NavigationControl } from 'mapbox-gl';
3
+ import { MapService } from '../map/map.service';
4
+ import { ControlComponent } from './control.component';
5
+ import * as i0 from "@angular/core";
6
+ export class NavigationControlDirective {
7
+ mapService = inject(MapService);
8
+ controlComponent = inject((ControlComponent), { host: true });
9
+ /* Init inputs */
10
+ showCompass = input(...(ngDevMode ? [undefined, { debugName: "showCompass" }] : []));
11
+ showZoom = input(...(ngDevMode ? [undefined, { debugName: "showZoom" }] : []));
12
+ ngAfterContentInit() {
13
+ this.mapService.mapCreated$.subscribe(() => {
14
+ if (this.controlComponent.control) {
15
+ throw new Error('Another control is already set for this control');
16
+ }
17
+ const options = {};
18
+ const showCompass = this.showCompass();
19
+ const showZoom = this.showZoom();
20
+ if (showCompass !== undefined) {
21
+ options.showCompass = showCompass;
22
+ }
23
+ if (showZoom !== undefined) {
24
+ options.showZoom = showZoom;
25
+ }
26
+ this.controlComponent.control = new NavigationControl(options);
27
+ this.mapService.addControl(this.controlComponent.control, this.controlComponent.position());
28
+ });
29
+ }
30
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NavigationControlDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
31
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: NavigationControlDirective, isStandalone: true, selector: "[mglNavigation]", inputs: { showCompass: { classPropertyName: "showCompass", publicName: "showCompass", isSignal: true, isRequired: false, transformFunction: null }, showZoom: { classPropertyName: "showZoom", publicName: "showZoom", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
32
+ }
33
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NavigationControlDirective, decorators: [{
34
+ type: Directive,
35
+ args: [{
36
+ selector: '[mglNavigation]',
37
+ }]
38
+ }], propDecorators: { showCompass: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCompass", required: false }] }], showZoom: [{ type: i0.Input, args: [{ isSignal: true, alias: "showZoom", required: false }] }] } });
39
+ //# sourceMappingURL=navigation-control.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-control.directive.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/control/navigation-control.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;;AAKvD,MAAM,OAAO,0BAA0B;IAC7B,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,gBAAgB,GAAG,MAAM,CAC/B,CAAA,gBAAmC,CAAA,EACnC,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IAEF,iBAAiB;IACjB,WAAW,GAAG,KAAK,iEAAW,CAAC;IAC/B,QAAQ,GAAG,KAAK,8DAAW,CAAC;IAE5B,kBAAkB;QAChB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE;YACzC,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YACrE,CAAC;YACD,MAAM,OAAO,GAAkD,EAAE,CAAC;YAClE,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;YACpC,CAAC;YACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAC9B,CAAC;YACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC/D,IAAI,CAAC,UAAU,CAAC,UAAU,CACxB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAC7B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;uGA/BU,0BAA0B;2FAA1B,0BAA0B;;2FAA1B,0BAA0B;kBAHtC,SAAS;mBAAC;oBACT,QAAQ,EAAE,iBAAiB;iBAC5B","sourcesContent":["import { AfterContentInit, Directive, inject, input } from '@angular/core';\nimport { NavigationControl } from 'mapbox-gl';\nimport { MapService } from '../map/map.service';\nimport { ControlComponent } from './control.component';\n\n@Directive({\n selector: '[mglNavigation]',\n})\nexport class NavigationControlDirective implements AfterContentInit {\n private mapService = inject(MapService);\n private controlComponent = inject<ControlComponent<NavigationControl>>(\n ControlComponent<NavigationControl>,\n { host: true },\n );\n\n /* Init inputs */\n showCompass = input<boolean>();\n showZoom = input<boolean>();\n\n ngAfterContentInit() {\n this.mapService.mapCreated$.subscribe(() => {\n if (this.controlComponent.control) {\n throw new Error('Another control is already set for this control');\n }\n const options: { showCompass?: boolean; showZoom?: boolean } = {};\n const showCompass = this.showCompass();\n const showZoom = this.showZoom();\n if (showCompass !== undefined) {\n options.showCompass = showCompass;\n }\n if (showZoom !== undefined) {\n options.showZoom = showZoom;\n }\n this.controlComponent.control = new NavigationControl(options);\n this.mapService.addControl(\n this.controlComponent.control,\n this.controlComponent.position(),\n );\n });\n }\n}\n"]}
@@ -0,0 +1,45 @@
1
+ import { Directive, inject, input, } from '@angular/core';
2
+ import { ScaleControl } from 'mapbox-gl';
3
+ import { MapService } from '../map/map.service';
4
+ import { ControlComponent } from './control.component';
5
+ import * as i0 from "@angular/core";
6
+ export class ScaleControlDirective {
7
+ mapService = inject(MapService);
8
+ controlComponent = inject((ControlComponent), { host: true });
9
+ /* Init inputs */
10
+ maxWidth = input(...(ngDevMode ? [undefined, { debugName: "maxWidth" }] : []));
11
+ /* Dynamic inputs */
12
+ unit = input(...(ngDevMode ? [undefined, { debugName: "unit" }] : []));
13
+ ngOnChanges(changes) {
14
+ if (changes['unit'] && !changes['unit'].isFirstChange()) {
15
+ this.controlComponent.control.setUnit(changes['unit'].currentValue);
16
+ }
17
+ }
18
+ ngAfterContentInit() {
19
+ this.mapService.mapCreated$.subscribe(() => {
20
+ if (this.controlComponent.control) {
21
+ throw new Error('Another control is already set for this control');
22
+ }
23
+ const options = {};
24
+ const maxWidth = this.maxWidth();
25
+ const unit = this.unit();
26
+ if (maxWidth !== undefined) {
27
+ options.maxWidth = maxWidth;
28
+ }
29
+ if (unit !== undefined) {
30
+ options.unit = unit;
31
+ }
32
+ this.controlComponent.control = new ScaleControl(options);
33
+ this.mapService.addControl(this.controlComponent.control, this.controlComponent.position());
34
+ });
35
+ }
36
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ScaleControlDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
37
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: ScaleControlDirective, isStandalone: true, selector: "[mglScale]", inputs: { maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, unit: { classPropertyName: "unit", publicName: "unit", isSignal: true, isRequired: false, transformFunction: null } }, usesOnChanges: true, ngImport: i0 });
38
+ }
39
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ScaleControlDirective, decorators: [{
40
+ type: Directive,
41
+ args: [{
42
+ selector: '[mglScale]',
43
+ }]
44
+ }], propDecorators: { maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], unit: [{ type: i0.Input, args: [{ isSignal: true, alias: "unit", required: false }] }] } });
45
+ //# sourceMappingURL=scale-control.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale-control.directive.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/control/scale-control.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAGT,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAA4B,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;;AAKvD,MAAM,OAAO,qBAAqB;IACxB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,gBAAgB,GAAG,MAAM,CAC/B,CAAA,gBAA8B,CAAA,EAC9B,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IAEF,iBAAiB;IACjB,QAAQ,GAAG,KAAK,8DAAU,CAAC;IAE3B,oBAAoB;IACpB,IAAI,GAAG,KAAK,0DAAsC,CAAC;IAEnD,WAAW,CAAC,OAAsB;QAChC,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC;YACvD,IAAI,CAAC,gBAAgB,CAAC,OAAwB,CAAC,OAAO,CACrD,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAC7B,CAAC;QACJ,CAAC;IACH,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE;YACzC,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YACrE,CAAC;YACD,MAAM,OAAO,GAAwB,EAAE,CAAC;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACzB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAC9B,CAAC;YACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;YACtB,CAAC;YACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;YAC1D,IAAI,CAAC,UAAU,CAAC,UAAU,CACxB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAC7B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;uGAzCU,qBAAqB;2FAArB,qBAAqB;;2FAArB,qBAAqB;kBAHjC,SAAS;mBAAC;oBACT,QAAQ,EAAE,YAAY;iBACvB","sourcesContent":["import {\n AfterContentInit,\n Directive,\n OnChanges,\n SimpleChanges,\n inject,\n input,\n} from '@angular/core';\nimport { ScaleControl, type ScaleControlOptions } from 'mapbox-gl';\nimport { MapService } from '../map/map.service';\nimport { ControlComponent } from './control.component';\n\n@Directive({\n selector: '[mglScale]',\n})\nexport class ScaleControlDirective implements AfterContentInit, OnChanges {\n private mapService = inject(MapService);\n private controlComponent = inject<ControlComponent<ScaleControl>>(\n ControlComponent<ScaleControl>,\n { host: true },\n );\n\n /* Init inputs */\n maxWidth = input<number>();\n\n /* Dynamic inputs */\n unit = input<'imperial' | 'metric' | 'nautical'>();\n\n ngOnChanges(changes: SimpleChanges) {\n if (changes['unit'] && !changes['unit'].isFirstChange()) {\n (this.controlComponent.control as ScaleControl).setUnit(\n changes['unit'].currentValue,\n );\n }\n }\n\n ngAfterContentInit() {\n this.mapService.mapCreated$.subscribe(() => {\n if (this.controlComponent.control) {\n throw new Error('Another control is already set for this control');\n }\n const options: ScaleControlOptions = {};\n const maxWidth = this.maxWidth();\n const unit = this.unit();\n if (maxWidth !== undefined) {\n options.maxWidth = maxWidth;\n }\n if (unit !== undefined) {\n options.unit = unit;\n }\n this.controlComponent.control = new ScaleControl(options);\n this.mapService.addControl(\n this.controlComponent.control,\n this.controlComponent.position(),\n );\n });\n }\n}\n"]}
@@ -0,0 +1,121 @@
1
+ import { Directive, EventEmitter, NgZone, Output, inject, input, } from '@angular/core';
2
+ import { fromEvent, Subscription } from 'rxjs';
3
+ import { filter, switchMap, take, takeUntil, tap } from 'rxjs/operators';
4
+ import { MapService } from '../map/map.service';
5
+ import { FeatureComponent } from '../source/geojson/feature.component';
6
+ import * as i0 from "@angular/core";
7
+ export class DraggableDirective {
8
+ mapService = inject(MapService);
9
+ ngZone = inject(NgZone);
10
+ featureComponent = inject(FeatureComponent, {
11
+ optional: true,
12
+ host: true,
13
+ });
14
+ layer = input(undefined, { ...(ngDevMode ? { debugName: "layer" } : {}), alias: 'mglDraggable' });
15
+ featureDragStart = new EventEmitter();
16
+ featureDragEnd = new EventEmitter();
17
+ featureDrag = new EventEmitter();
18
+ sub = new Subscription();
19
+ ngOnInit() {
20
+ let enter$;
21
+ let leave$;
22
+ let updateCoords;
23
+ const layer = this.layer();
24
+ if (this.featureComponent && layer) {
25
+ enter$ = layer.layerMouseEnter;
26
+ leave$ = layer.layerMouseLeave;
27
+ updateCoords = this.featureComponent.updateCoordinates.bind(this.featureComponent);
28
+ if (this.featureComponent.geometry().type !== 'Point') {
29
+ throw new Error('mglDraggable only support point feature');
30
+ }
31
+ }
32
+ else {
33
+ throw new Error('mglDraggable can only be used on Feature (with a layer as input) or Marker');
34
+ }
35
+ this.handleDraggable(enter$, leave$, updateCoords);
36
+ }
37
+ ngOnDestroy() {
38
+ this.sub.unsubscribe();
39
+ }
40
+ handleDraggable(enter$, leave$, updateCoords) {
41
+ let moving = false;
42
+ let inside = false;
43
+ this.mapService.mapCreated$.subscribe(() => {
44
+ const mouseUp$ = fromEvent(this.mapService.mapInstance, 'mouseup');
45
+ const dragStart$ = enter$.pipe(filter(() => !moving), filter((evt) => this.filterFeature(evt)), tap(() => {
46
+ inside = true;
47
+ this.mapService.changeCanvasCursor('move');
48
+ this.mapService.updateDragPan(false);
49
+ }), switchMap(() => fromEvent(this.mapService.mapInstance, 'mousedown').pipe(takeUntil(leave$))));
50
+ const dragging$ = dragStart$.pipe(switchMap(() => fromEvent(this.mapService.mapInstance, 'mousemove').pipe(takeUntil(mouseUp$))));
51
+ const dragEnd$ = dragStart$.pipe(switchMap(() => mouseUp$.pipe(take(1))));
52
+ this.sub.add(dragStart$.subscribe((evt) => {
53
+ moving = true;
54
+ if (this.featureDragStart.observed) {
55
+ this.ngZone.run(() => {
56
+ this.featureDragStart.emit(evt);
57
+ });
58
+ }
59
+ }));
60
+ this.sub.add(dragging$.subscribe((evt) => {
61
+ updateCoords([evt.lngLat.lng, evt.lngLat.lat]);
62
+ if (this.featureDrag.observed) {
63
+ this.ngZone.run(() => {
64
+ this.featureDrag.emit(evt);
65
+ });
66
+ }
67
+ }));
68
+ this.sub.add(dragEnd$.subscribe((evt) => {
69
+ moving = false;
70
+ if (this.featureDragEnd.observed) {
71
+ this.ngZone.run(() => {
72
+ this.featureDragEnd.emit(evt);
73
+ });
74
+ }
75
+ if (!inside) {
76
+ // It's possible to dragEnd outside the target (small input lag)
77
+ this.mapService.changeCanvasCursor('');
78
+ this.mapService.updateDragPan(true);
79
+ }
80
+ }));
81
+ this.sub.add(leave$
82
+ .pipe(tap(() => (inside = false)), filter(() => !moving))
83
+ .subscribe(() => {
84
+ this.mapService.changeCanvasCursor('');
85
+ this.mapService.updateDragPan(true);
86
+ }));
87
+ });
88
+ }
89
+ filterFeature(evt) {
90
+ const layer = this.layer();
91
+ if (this.featureComponent && layer) {
92
+ const feature = this.mapService.queryRenderedFeatures(evt.point, {
93
+ layers: [layer.id()],
94
+ filter: [
95
+ 'all',
96
+ ['==', '$type', 'Point'],
97
+ ['==', '$id', this.featureComponent.id()],
98
+ ],
99
+ })[0];
100
+ if (!feature) {
101
+ return false;
102
+ }
103
+ }
104
+ return true;
105
+ }
106
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: DraggableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
107
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: DraggableDirective, isStandalone: true, selector: "[mglDraggable]", inputs: { layer: { classPropertyName: "layer", publicName: "mglDraggable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { featureDragStart: "featureDragStart", featureDragEnd: "featureDragEnd", featureDrag: "featureDrag" }, ngImport: i0 });
108
+ }
109
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: DraggableDirective, decorators: [{
110
+ type: Directive,
111
+ args: [{
112
+ selector: '[mglDraggable]',
113
+ }]
114
+ }], propDecorators: { layer: [{ type: i0.Input, args: [{ isSignal: true, alias: "mglDraggable", required: false }] }], featureDragStart: [{
115
+ type: Output
116
+ }], featureDragEnd: [{
117
+ type: Output
118
+ }], featureDrag: [{
119
+ type: Output
120
+ }] } });
121
+ //# sourceMappingURL=draggable.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draggable.directive.js","sourceRoot":"","sources":["../../../../../../libs/ngx-mapbox-gl/src/lib/draggable/draggable.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,MAAM,EAGN,MAAM,EACN,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAc,YAAY,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;;AAKvE,MAAM,OAAO,kBAAkB;IACrB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,EAAE;QAClD,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IAEH,KAAK,GAAG,KAAK,CAAiB,SAAS,kDAAI,KAAK,EAAE,cAAc,GAAG,CAAC;IAE1D,gBAAgB,GAAG,IAAI,YAAY,EAAiB,CAAC;IACrD,cAAc,GAAG,IAAI,YAAY,EAAiB,CAAC;IACnD,WAAW,GAAG,IAAI,YAAY,EAAiB,CAAC;IAElD,GAAG,GAAG,IAAI,YAAY,EAAE,CAAC;IAEjC,QAAQ;QACN,IAAI,MAAM,CAAC;QACX,IAAI,MAAM,CAAC;QACX,IAAI,YAAY,CAAC;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,gBAAgB,IAAI,KAAK,EAAE,CAAC;YACnC,MAAM,GAAG,KAA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B,CAAC,GAAG,CAAC,KAAK,EAAE;gBAC/C,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;gBACpB,MAAM,EAAE;oBACN,KAAK;oBACL,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;oBACxB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC;iBAC1C;aACF,CAAC,CAAC,CAAC,CAAC,CAAC;YACR,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;uGAjJU,kBAAkB;2FAAlB,kBAAkB;;2FAAlB,kBAAkB;kBAH9B,SAAS;mBAAC;oBACT,QAAQ,EAAE,gBAAgB;iBAC3B;;sBAWE,MAAM;;sBACN,MAAM;;sBACN,MAAM","sourcesContent":["import {\n Directive,\n EventEmitter,\n NgZone,\n OnDestroy,\n OnInit,\n Output,\n inject,\n input,\n} from '@angular/core';\nimport { MapMouseEvent } from 'mapbox-gl';\nimport { fromEvent, Observable, Subscription } from 'rxjs';\nimport { filter, switchMap, take, takeUntil, tap } from 'rxjs/operators';\nimport { LayerComponent } from '../layer/layer.component';\nimport { MapService } from '../map/map.service';\nimport { FeatureComponent } from '../source/geojson/feature.component';\n\n@Directive({\n selector: '[mglDraggable]',\n})\nexport class DraggableDirective implements OnInit, OnDestroy {\n private mapService = inject(MapService);\n private ngZone = inject(NgZone);\n private featureComponent = inject(FeatureComponent, {\n optional: true,\n host: true,\n });\n\n layer = input<LayerComponent>(undefined, { alias: 'mglDraggable' });\n\n @Output() featureDragStart = new EventEmitter<MapMouseEvent>();\n @Output() featureDragEnd = new EventEmitter<MapMouseEvent>();\n @Output() featureDrag = new EventEmitter<MapMouseEvent>();\n\n private sub = new Subscription();\n\n ngOnInit() {\n let enter$;\n let leave$;\n let updateCoords;\n const layer = this.layer();\n if (this.featureComponent && layer) {\n enter$ = layer.layerMouseEnter;\n leave$ = layer.layerMouseLeave;\n updateCoords = this.featureComponent.updateCoordinates.bind(\n this.featureComponent,\n );\n if (this.featureComponent.geometry().type !== 'Point') {\n throw new Error('mglDraggable only support point feature');\n }\n } else {\n throw new Error(\n 'mglDraggable can only be used on Feature (with a layer as input) or Marker',\n );\n }\n\n this.handleDraggable(enter$, leave$, updateCoords);\n }\n\n ngOnDestroy() {\n this.sub.unsubscribe();\n }\n\n private handleDraggable(\n enter$: Observable<MapMouseEvent>,\n leave$: Observable<MapMouseEvent>,\n updateCoords: (coord: number[]) => void,\n ) {\n let moving = false;\n let inside = false;\n this.mapService.mapCreated$.subscribe(() => {\n const mouseUp$ = fromEvent<MapMouseEvent>(\n this.mapService.mapInstance,\n 'mouseup',\n );\n const dragStart$ = enter$.pipe(\n filter(() => !moving),\n filter((evt) => this.filterFeature(evt)),\n tap(() => {\n inside = true;\n this.mapService.changeCanvasCursor('move');\n this.mapService.updateDragPan(false);\n }),\n switchMap(() =>\n fromEvent<MapMouseEvent>(\n this.mapService.mapInstance,\n 'mousedown',\n ).pipe(takeUntil(leave$)),\n ),\n );\n const dragging$ = dragStart$.pipe(\n switchMap(() =>\n fromEvent<MapMouseEvent>(\n this.mapService.mapInstance,\n 'mousemove',\n ).pipe(takeUntil(mouseUp$)),\n ),\n );\n const dragEnd$ = dragStart$.pipe(switchMap(() => mouseUp$.pipe(take(1))));\n this.sub.add(\n dragStart$.subscribe((evt) => {\n moving = true;\n if (this.featureDragStart.observed) {\n this.ngZone.run(() => {\n this.featureDragStart.emit(evt);\n });\n }\n }),\n );\n this.sub.add(\n dragging$.subscribe((evt) => {\n updateCoords([evt.lngLat.lng, evt.lngLat.lat]);\n if (this.featureDrag.observed) {\n this.ngZone.run(() => {\n this.featureDrag.emit(evt);\n });\n }\n }),\n );\n this.sub.add(\n dragEnd$.subscribe((evt) => {\n moving = false;\n if (this.featureDragEnd.observed) {\n this.ngZone.run(() => {\n this.featureDragEnd.emit(evt);\n });\n }\n if (!inside) {\n // It's possible to dragEnd outside the target (small input lag)\n this.mapService.changeCanvasCursor('');\n this.mapService.updateDragPan(true);\n }\n }),\n );\n this.sub.add(\n leave$\n .pipe(\n tap(() => (inside = false)),\n filter(() => !moving),\n )\n .subscribe(() => {\n this.mapService.changeCanvasCursor('');\n this.mapService.updateDragPan(true);\n }),\n );\n });\n }\n\n private filterFeature(evt: MapMouseEvent) {\n const layer = this.layer();\n if (this.featureComponent && layer) {\n const feature: GeoJSON.Feature<GeoJSON.GeometryObject> =\n this.mapService.queryRenderedFeatures(evt.point, {\n layers: [layer.id()],\n filter: [\n 'all',\n ['==', '$type', 'Point'],\n ['==', '$id', this.featureComponent.id()],\n ],\n })[0];\n if (!feature) {\n return false;\n }\n }\n return true;\n }\n}\n"]}
@@ -0,0 +1,79 @@
1
+ import { Component, EventEmitter, NgZone, Output, inject, input, } from '@angular/core';
2
+ import { fromEvent } from 'rxjs';
3
+ import { filter, startWith, switchMap } from 'rxjs/operators';
4
+ import { MapService } from '../map/map.service';
5
+ import * as i0 from "@angular/core";
6
+ export class ImageComponent {
7
+ mapService = inject(MapService);
8
+ zone = inject(NgZone);
9
+ /* Init inputs */
10
+ id = input.required(...(ngDevMode ? [{ debugName: "id" }] : []));
11
+ /* Dynamic inputs */
12
+ data = input(...(ngDevMode ? [undefined, { debugName: "data" }] : []));
13
+ options = input(...(ngDevMode ? [undefined, { debugName: "options" }] : []));
14
+ url = input(...(ngDevMode ? [undefined, { debugName: "url" }] : []));
15
+ imageError = new EventEmitter();
16
+ imageLoaded = new EventEmitter();
17
+ isAdded = false;
18
+ isAdding = false;
19
+ sub;
20
+ ngOnInit() {
21
+ this.sub = this.mapService.mapLoaded$
22
+ .pipe(switchMap(() => fromEvent(this.mapService.mapInstance, 'styledata').pipe(startWith(undefined), filter(() => !this.isAdding &&
23
+ !this.mapService.mapInstance.hasImage(this.id())))))
24
+ .subscribe(() => this.init());
25
+ }
26
+ ngOnChanges(changes) {
27
+ if ((changes['data'] && !changes['data'].isFirstChange()) ||
28
+ (changes['options'] && !changes['options'].isFirstChange()) ||
29
+ (changes['url'] && !changes['url'].isFirstChange())) {
30
+ this.ngOnDestroy();
31
+ this.ngOnInit();
32
+ }
33
+ }
34
+ ngOnDestroy() {
35
+ if (this.isAdded) {
36
+ this.mapService.removeImage(this.id());
37
+ }
38
+ if (this.sub) {
39
+ this.sub.unsubscribe();
40
+ }
41
+ }
42
+ async init() {
43
+ this.isAdding = true;
44
+ if (this.data()) {
45
+ this.mapService.addImage(this.id(), this.data(), this.options());
46
+ this.isAdded = true;
47
+ this.isAdding = false;
48
+ }
49
+ else if (this.url()) {
50
+ try {
51
+ await this.mapService.loadAndAddImage(this.id(), this.url(), this.options());
52
+ this.isAdded = true;
53
+ this.isAdding = false;
54
+ this.zone.run(() => {
55
+ this.imageLoaded.emit();
56
+ });
57
+ }
58
+ catch (error) {
59
+ this.zone.run(() => {
60
+ this.imageError.emit(error);
61
+ });
62
+ }
63
+ }
64
+ }
65
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
66
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: ImageComponent, isStandalone: true, selector: "mgl-image", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: true, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { imageError: "imageError", imageLoaded: "imageLoaded" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true });
67
+ }
68
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ImageComponent, decorators: [{
69
+ type: Component,
70
+ args: [{
71
+ selector: 'mgl-image',
72
+ template: '',
73
+ }]
74
+ }], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], url: [{ type: i0.Input, args: [{ isSignal: true, alias: "url", required: false }] }], imageError: [{
75
+ type: Output
76
+ }], imageLoaded: [{
77
+ type: Output
78
+ }] } });
79
+ //# sourceMappingURL=image.component.js.map