diff --git a/demo/src/app/context/context/context.component.html b/demo/src/app/context/context/context.component.html index 84e9b1d396..da98a5331f 100644 --- a/demo/src/app/context/context/context.component.html +++ b/demo/src/app/context/context/context.component.html @@ -11,7 +11,6 @@ diff --git a/package-lock.json b/package-lock.json index 380d3d6e45..5eafa1e5ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2057,7 +2057,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2078,12 +2079,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2098,17 +2101,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2225,7 +2231,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2237,6 +2244,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2251,6 +2259,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2258,12 +2267,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2282,6 +2293,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2362,7 +2374,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2374,6 +2387,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2459,7 +2473,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2495,6 +2510,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2514,6 +2530,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2557,12 +2574,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -8418,7 +8437,6 @@ "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8587,7 +8605,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -8595,8 +8612,7 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", @@ -8700,8 +8716,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -11883,7 +11898,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -11904,12 +11920,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -11924,17 +11942,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -12051,7 +12072,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -12063,6 +12085,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -12077,6 +12100,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -12084,12 +12108,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -12108,6 +12134,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -12188,7 +12215,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -12200,6 +12228,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -12285,7 +12314,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -12321,6 +12351,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -12340,6 +12371,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -12383,12 +12415,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -20445,7 +20479,6 @@ "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -20460,8 +20493,7 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", @@ -20472,8 +20504,7 @@ "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -20590,8 +20621,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -20603,7 +20633,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -20618,7 +20647,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -20730,8 +20758,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -20864,7 +20891,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/packages/context/src/lib/share-map/share-map/share-map-binding.directive.ts b/packages/context/src/lib/share-map/share-map/share-map-binding.directive.ts index 2b0b018f09..ee9366f2e2 100644 --- a/packages/context/src/lib/share-map/share-map/share-map-binding.directive.ts +++ b/packages/context/src/lib/share-map/share-map/share-map-binding.directive.ts @@ -1,6 +1,6 @@ import { Directive, Self, OnInit, Optional } from '@angular/core'; -import { MapService, LayerListService } from '@igo2/geo'; +import { LayerListService } from '@igo2/geo'; import { ShareMapComponent } from './share-map.component'; import { RouteService } from '@igo2/core'; @@ -12,7 +12,6 @@ export class ShareMapBindingDirective implements OnInit { constructor( @Self() component: ShareMapComponent, - private mapService: MapService, private layerListService: LayerListService, @Optional() private route: RouteService ) { @@ -20,7 +19,6 @@ export class ShareMapBindingDirective implements OnInit { } ngOnInit() { - this.component.map = this.mapService.getMap(); this.initRoutes(); } diff --git a/packages/geo/src/lib/import-export/import-export/import-export.component.ts b/packages/geo/src/lib/import-export/import-export/import-export.component.ts index 33307fce89..c0a4360b1e 100644 --- a/packages/geo/src/lib/import-export/import-export/import-export.component.ts +++ b/packages/geo/src/lib/import-export/import-export/import-export.component.ts @@ -1,8 +1,8 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Subscription } from 'rxjs'; -import { MapService } from '../../map/shared/map.service'; +import { IgoMap } from '../../map/shared/map'; import { VectorLayer } from '../../layer/shared/layers/vector-layer'; import { ExportOptions } from '../shared/import-export.interface'; import { ExportFormat } from '../shared/import-export.type'; @@ -20,9 +20,17 @@ export class ImportExportComponent implements OnDestroy, OnInit { public inputProj: string; private layers$$: Subscription; + @Input() + get map(): IgoMap { + return this._map; + } + set map(value: IgoMap) { + this._map = value; + } + private _map: IgoMap; + constructor( private importExportService: ImportExportService, - private mapService: MapService, private formBuilder: FormBuilder ) { this.buildForm(); @@ -41,7 +49,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { } ngOnInit() { - this.layers$$ = this.mapService.getMap().layers$.subscribe(layers => { + this.layers$$ = this.map.layers$.subscribe(layers => { this.layers = (layers .filter(layer => layer instanceof VectorLayer)) as VectorLayer[]; }); diff --git a/packages/geo/src/lib/map/map-browser/index.ts b/packages/geo/src/lib/map/map-browser/index.ts index 0fc04af099..23b9fdcaad 100644 --- a/packages/geo/src/lib/map/map-browser/index.ts +++ b/packages/geo/src/lib/map/map-browser/index.ts @@ -1,2 +1 @@ export * from './map-browser.component'; -export * from './map-browser-binding.directive'; diff --git a/packages/geo/src/lib/map/map-browser/map-browser-binding.directive.ts b/packages/geo/src/lib/map/map-browser/map-browser-binding.directive.ts deleted file mode 100644 index 4e7379cf1b..0000000000 --- a/packages/geo/src/lib/map/map-browser/map-browser-binding.directive.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Directive, Self, OnInit, OnDestroy } from '@angular/core'; - -import { MapService } from '../shared/map.service'; -import { MapBrowserComponent } from './map-browser.component'; - -@Directive({ - selector: '[igoMapBrowserBinding]' -}) -export class MapBrowserBindingDirective implements OnInit, OnDestroy { - private component: MapBrowserComponent; - - constructor( - @Self() component: MapBrowserComponent, - private mapService: MapService - ) { - this.component = component; - } - - ngOnInit() { - if (this.mapService.getMap() !== undefined) { - throw new Error('No more than one map be binded to the map service.'); - } - - this.mapService.setMap(this.component.map); - } - - ngOnDestroy() { - this.mapService.setMap(undefined); - } -} diff --git a/packages/geo/src/lib/map/map.module.ts b/packages/geo/src/lib/map/map.module.ts index 14fb060abc..430afefb04 100644 --- a/packages/geo/src/lib/map/map.module.ts +++ b/packages/geo/src/lib/map/map.module.ts @@ -10,7 +10,6 @@ import { import { IgoLanguageModule } from '@igo2/core'; import { IgoConfirmDialogModule } from '@igo2/common'; -import { MapBrowserBindingDirective } from './map-browser/map-browser-binding.directive'; import { MapBrowserComponent } from './map-browser/map-browser.component'; import { ZoomButtonComponent } from './zoom-button/zoom-button.component'; import { GeolocateButtonComponent } from './geolocate-button/geolocate-button.component'; @@ -29,7 +28,6 @@ import { MiniBaseMapComponent } from './baselayers-switcher/mini-basemap.compone ], exports: [ MapBrowserComponent, - MapBrowserBindingDirective, ZoomButtonComponent, GeolocateButtonComponent, RotationButtonComponent, @@ -38,7 +36,6 @@ import { MiniBaseMapComponent } from './baselayers-switcher/mini-basemap.compone ], declarations: [ MapBrowserComponent, - MapBrowserBindingDirective, ZoomButtonComponent, GeolocateButtonComponent, RotationButtonComponent, diff --git a/packages/integration/src/lib/context/context-share-tool/context-share-tool.component.html b/packages/integration/src/lib/context/context-share-tool/context-share-tool.component.html index 517dcac9ce..7df5bdbaab 100644 --- a/packages/integration/src/lib/context/context-share-tool/context-share-tool.component.html +++ b/packages/integration/src/lib/context/context-share-tool/context-share-tool.component.html @@ -1,5 +1,6 @@ diff --git a/packages/integration/src/lib/context/context-share-tool/context-share-tool.component.ts b/packages/integration/src/lib/context/context-share-tool/context-share-tool.component.ts index 6b7669e67d..96566e15e1 100644 --- a/packages/integration/src/lib/context/context-share-tool/context-share-tool.component.ts +++ b/packages/integration/src/lib/context/context-share-tool/context-share-tool.component.ts @@ -1,6 +1,9 @@ import { Component, Input } from '@angular/core'; import { ToolComponent } from '@igo2/common'; +import { IgoMap } from '@igo2/geo'; + +import { MapState } from '../../map/map.state'; @ToolComponent({ name: 'shareMap', @@ -16,5 +19,9 @@ export class ContextShareToolComponent { @Input() hasShareMapButton: boolean = true; - constructor() {} + get map(): IgoMap { return this.mapState.map; } + + constructor( + private mapState: MapState + ) {} } diff --git a/packages/integration/src/lib/import-export/import-export-tool/import-export-tool.component.html b/packages/integration/src/lib/import-export/import-export-tool/import-export-tool.component.html index 973a74f638..731f45a18d 100644 --- a/packages/integration/src/lib/import-export/import-export-tool/import-export-tool.component.html +++ b/packages/integration/src/lib/import-export/import-export-tool/import-export-tool.component.html @@ -1 +1 @@ - + diff --git a/packages/integration/src/lib/import-export/import-export-tool/import-export-tool.component.ts b/packages/integration/src/lib/import-export/import-export-tool/import-export-tool.component.ts index c12ea6baca..e3026697e1 100644 --- a/packages/integration/src/lib/import-export/import-export-tool/import-export-tool.component.ts +++ b/packages/integration/src/lib/import-export/import-export-tool/import-export-tool.component.ts @@ -1,6 +1,9 @@ -import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { Component, ChangeDetectionStrategy } from '@angular/core'; import { ToolComponent } from '@igo2/common'; +import { IgoMap } from '@igo2/geo'; + +import { MapState } from '../../map/map.state'; @ToolComponent({ name: 'importExport', @@ -9,8 +12,18 @@ import { ToolComponent } from '@igo2/common'; }) @Component({ selector: 'igo-import-export-tool', - templateUrl: './import-export-tool.component.html' + templateUrl: './import-export-tool.component.html', + changeDetection: ChangeDetectionStrategy.OnPush }) export class ImportExportToolComponent { - constructor() {} + /** + * Map to measure on + * @internal + */ + get map(): IgoMap { return this.mapState.map; } + + constructor( + private mapState: MapState + ) {} + }