diff --git a/web/src/ferrostar-core.ts b/web/src/ferrostar-core.ts index 71d39cc6..a8d877fc 100644 --- a/web/src/ferrostar-core.ts +++ b/web/src/ferrostar-core.ts @@ -165,13 +165,13 @@ export class FerrostarCore extends LitElement { } // TODO: type - async startNavigation(route: any, config: any) { + startNavigation(route: any, config: any) { // Remove the search box when navigation starts if (this.useIntegratedSearchBox) this.map?.removeControl(this.searchBox!); // Initialize the navigation controller - this.locationProvider.updateCallback = this.onLocationUpdated.bind(this); this.navigationController = new NavigationController(route, config); + this.locationProvider.updateCallback = this.onLocationUpdated.bind(this); // Initialize the trip state const startingLocation = this.locationProvider.lastLocation @@ -228,7 +228,7 @@ export class FerrostarCore extends LitElement { this.locationProvider = new BrowserLocationProvider(); } - await this.locationProvider.start(); + this.locationProvider.start(); // TODO: Replace this with a promise or callback while (!this.locationProvider.lastLocation) { @@ -256,7 +256,7 @@ export class FerrostarCore extends LitElement { }; // Start the navigation - await this.startNavigation(route, config); + this.startNavigation(route, config); } async stopNavigation() { diff --git a/web/src/location.ts b/web/src/location.ts index 9d9ff694..c37172c2 100644 --- a/web/src/location.ts +++ b/web/src/location.ts @@ -15,7 +15,7 @@ export class SimulatedLocationProvider { } async start() { - while (true) { + while (this.simulationState !== null) { await new Promise((resolve) => setTimeout(resolve, (1 / this.warpFactor) * 1000)); const initialState = this.simulationState; const updatedState = advanceLocationSimulation(initialState); @@ -47,7 +47,7 @@ export class BrowserLocationProvider { updateCallback: () => void = () => {}; - async start() { + start() { if (navigator.geolocation && !this.geolocationWatchId) { const options = { enableHighAccuracy: true,