Skip to content

Commit

Permalink
fix(directions): auto zoom on new stop/route (#874)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre-Étienne Lord <[email protected]>
  • Loading branch information
pelord and Pierre-Étienne Lord authored Jun 4, 2021
1 parent f42f242 commit b9d3b1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@angular/core';

import { RouteService } from '@igo2/core';
import { delay } from 'rxjs/operators';
import { Directions } from '../shared/directions.interface';
import { DirectionsService } from '../shared/directions.service';

Expand Down Expand Up @@ -57,9 +58,11 @@ export class DirectionsFormBindingDirective implements AfterViewInit {
this.component.addStopOverlay(stopCoordinatesFromURL, cnt);
cnt++;
});
this.component.activeRoute$.subscribe((activeRoute) => {
this.getRoutes(activeRoute);
});
this.component.activeRoute$
.pipe(delay(250))
.subscribe((activeRoute) => {
this.getRoutes(activeRoute);
});
}
}
});
Expand Down Expand Up @@ -93,6 +96,7 @@ export class DirectionsFormBindingDirective implements AfterViewInit {
this.component.routesResults = route;
if (!activeRoute) {
this.component.activeRoute = route[0] as Directions;
this.component.showRouteGeometry(true);
return;
}
this.component.showRouteGeometry(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ export class DirectionsFormComponent implements OnInit, OnDestroy {
}

getRoutes(
moveToExtent: boolean = true,
moveToExtent: boolean = false,
directionsOptions: DirectionsOptions = {}
) {
this.deleteStoreFeatureByID(this.routeStore, 'vertex');
Expand Down

0 comments on commit b9d3b1f

Please sign in to comment.