Skip to content

Commit

Permalink
fix(map-legend) listen to layers modification (#636)
Browse files Browse the repository at this point in the history
* fix(map-legend) listen to layers modification

* ui(map tools) increase the delay before allow empty layers to be shown
  • Loading branch information
pelord authored May 7, 2020
1 parent 002ceef commit 171086c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class MapDetailsToolComponent implements OnInit {
setTimeout(() => {
this.delayedShowEmptyMapContent = true;
this.cdRef.detectChanges();
}, 100);
}, 250);
}

searchEmit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
ChangeDetectorRef,
ChangeDetectionStrategy
} from '@angular/core';
import { Observable, Subscription, BehaviorSubject, ReplaySubject } from 'rxjs';
import { map } from 'rxjs/operators';
import { Observable, Subscription, BehaviorSubject, ReplaySubject, combineLatest } from 'rxjs';
import { map, debounceTime } from 'rxjs/operators';

import { ToolComponent } from '@igo2/common';
import {
Expand Down Expand Up @@ -99,15 +99,20 @@ export class MapLegendToolComponent implements OnInit, OnDestroy {
) {}

ngOnInit(): void {
this.resolution$$ = this.map.viewController.resolution$.subscribe(r =>
this.layers$.next(
this.map.layers.filter(
layer =>
layer.showInLayerList !== false &&
(!this.excludeBaseLayers || !layer.baseLayer)
)
)
);
this.resolution$$ = combineLatest([
this.map.layers$,
this.map.viewController.resolution$
])
.pipe(debounceTime(10))
.subscribe((bunch: [Layer[], number]) => {
this.layers$.next(
bunch[0].filter(
layer =>
layer.showInLayerList !== false &&
(!this.excludeBaseLayers || !layer.baseLayer)
)
);
});

this.mapState.showAllLegendsValue =
this.mapState.showAllLegendsValue !== undefined
Expand All @@ -119,7 +124,7 @@ export class MapLegendToolComponent implements OnInit, OnDestroy {
setTimeout(() => {
this.delayedShowEmptyMapContent = true;
this.cdRef.detectChanges();
}, 100);
}, 250);
}

onShowAllLegends(event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class MapToolsComponent implements OnInit, OnDestroy {
this.showAllLegendsValue$.next(this.mapState.showAllLegendsValue);

// prevent message to be shown too quickly. Waiting for layers
setTimeout(() => (this.delayedShowEmptyMapContent = true), 100);
setTimeout(() => (this.delayedShowEmptyMapContent = true), 250);
}

ngOnDestroy(): void {
Expand Down

0 comments on commit 171086c

Please sign in to comment.