Skip to content

Commit

Permalink
fix(routing): Disable queryLayers on routing and reactivate on destroy (
Browse files Browse the repository at this point in the history
#217)

* refactor(query) moving queryLayers from directive to service

* fix(routing) Disable queryLayers on routing and reactivate on destroy

* refactor(*) ling and cleaning
  • Loading branch information
pelord authored and mbarbeau committed Nov 1, 2018
1 parent 9a2abf9 commit f7f3989
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions projects/geo/src/lib/query/shared/query.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { QueryService } from './query.service';
selector: '[igoQuery]'
})
export class QueryDirective implements AfterViewInit, OnDestroy {
private queryLayers: Layer[];
private queryLayers$$: Subscription;
private queries$$: Subscription[] = [];

Expand Down Expand Up @@ -91,7 +90,7 @@ export class QueryDirective implements AfterViewInit, OnDestroy {
}
});

this.queryLayers = queryLayers;
this.queryService.queryLayers = queryLayers;
}

private manageFeatureByClick(
Expand Down Expand Up @@ -174,7 +173,7 @@ export class QueryDirective implements AfterViewInit, OnDestroy {
delete element.properties['clickedTitle'];
});
const view = this.map.ol.getView();
const queries$ = this.queryService.query(this.queryLayers, {
const queries$ = this.queryService.query(this.queryService.queryLayers, {
coordinates: event.coordinate,
projection: this.map.projection,
resolution: view.getResolution()
Expand Down
1 change: 1 addition & 0 deletions projects/geo/src/lib/query/shared/query.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { QueryOptions, QueryableDataSource } from './query.interface';
providedIn: 'root'
})
export class QueryService {
public queryLayers: Layer[];
constructor(
private http: HttpClient,
private featureService: FeatureService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { Routing } from '../shared/routing.interface';
import { RoutingService } from '../shared/routing.service';
import { RoutingFormService } from './routing-form.service';

import { QueryService } from '../../query/shared/query.service';

@Component({
selector: 'igo-routing-form',
templateUrl: './routing-form.component.html',
Expand Down Expand Up @@ -59,6 +61,8 @@ export class RoutingFormComponent implements OnInit, AfterViewInit, OnDestroy {
public initialStopsCoords;
private browserLanguage;

private queryLayersOnInit;

// https://stackoverflow.com/questions/46364852/create-input-fields-dynamically-in-angular-2

@Input()
Expand Down Expand Up @@ -104,6 +108,7 @@ export class RoutingFormComponent implements OnInit, AfterViewInit, OnDestroy {
private languageService: LanguageService,
private messageService: MessageService,
private searchService: SearchService,
private queryService: QueryService,
private routingFormService: RoutingFormService,
@Optional() private route: RouteService
) {}
Expand All @@ -113,6 +118,7 @@ export class RoutingFormComponent implements OnInit, AfterViewInit, OnDestroy {
}

ngOnDestroy(): void {
this.queryService.queryLayers = this.queryLayersOnInit;
const stopCoordinates = [];

this.stops.value.forEach(stop => {
Expand Down Expand Up @@ -141,6 +147,8 @@ export class RoutingFormComponent implements OnInit, AfterViewInit, OnDestroy {
}

ngAfterViewInit(): void {
this.queryLayersOnInit = this.queryService.queryLayers;
this.queryService.queryLayers = [];
this.focusOnStop = false;
const stopsLayer = new VectorLayer({
title: 'routingStopOverlay',
Expand Down

0 comments on commit f7f3989

Please sign in to comment.