diff --git a/packages/geo/src/lib/layer/layer-item/layer-item.component.ts b/packages/geo/src/lib/layer/layer-item/layer-item.component.ts index eb28de6066..1f1fda1895 100644 --- a/packages/geo/src/lib/layer/layer-item/layer-item.component.ts +++ b/packages/geo/src/lib/layer/layer-item/layer-item.component.ts @@ -60,13 +60,11 @@ export class LayerItemComponent implements OnInit, OnDestroy { this._selectAll = value; if (value === true) { this.layerCheck = true; - } else { - this.layerCheck = false; } } private _selectAll = false; - public layerCheck; + @Input() layerCheck; private resolution$$: Subscription; diff --git a/packages/geo/src/lib/layer/layer-list/layer-list.component.html b/packages/geo/src/lib/layer/layer-list/layer-list.component.html index 4c433eeebf..a92ea3e072 100644 --- a/packages/geo/src/lib/layer/layer-list/layer-list.component.html +++ b/packages/geo/src/lib/layer/layer-list/layer-list.component.html @@ -23,13 +23,14 @@ [toggleLegendOnVisibilityChange]="toggleLegendOnVisibilityChange" [selectionMode]="selection" [selectAll]="selectAllCheck" + [layerCheck]="layer.options.check" (action)="toggleLayerTool($event)" (checkbox)="layersCheck($event)"> - +
 event.layer.id === layer.id); for (const layer of this.layersChecked) { const mapIndex = this.layers.findIndex(lay => layer.id === lay.id); if (eventMapIndex < mapIndex) { this.layersChecked.splice(this.layersChecked.findIndex(lay => layer.id === lay.id), 0, event.layer); + + if (this.layersChecked.length === this.layers.filter(lay => lay.baseLayer !== true).length) { + this.selectAllCheck = true; + } else { + this.selectAllCheck = false; + } return; } } @@ -425,6 +432,12 @@ export class LayerListComponent implements OnInit, OnDestroy { const index = this.layersChecked.findIndex(layer => event.layer.id === layer.id); this.layersChecked.splice(index, 1); } + + if (this.layersChecked.length === this.layers.filter(layer => layer.baseLayer !== true).length) { + this.selectAllCheck = true; + } else { + this.selectAllCheck = false; + } } toggleSelectionMode(value: boolean) { @@ -450,12 +463,16 @@ export class LayerListComponent implements OnInit, OnDestroy { selectAll() { if (!this.selectAllCheck) { for (const layer of this.layers) { + layer.options.check = true; if (!layer.baseLayer) { this.layersChecked.push(layer); } } this.selectAllCheck$.next(true); } else { + for (const layer of this.layers) { + layer.options.check = false; + } this.layersChecked = []; this.selectAllCheck$.next(false); } diff --git a/packages/geo/src/lib/layer/shared/layers/layer.interface.ts b/packages/geo/src/lib/layer/shared/layers/layer.interface.ts index 88881d3f92..57ac599c94 100644 --- a/packages/geo/src/lib/layer/shared/layers/layer.interface.ts +++ b/packages/geo/src/lib/layer/shared/layers/layer.interface.ts @@ -24,6 +24,7 @@ export interface LayerOptions { tooltip?: TooltipContent; _internal?: { [key: string]: string }; active?: boolean; + check?: boolean; } export interface GroupLayers {