aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/MapBox/AnimationUtility.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/MapBox/AnimationUtility.ts')
-rw-r--r--src/client/views/nodes/MapBox/AnimationUtility.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/client/views/nodes/MapBox/AnimationUtility.ts b/src/client/views/nodes/MapBox/AnimationUtility.ts
index a5cff4668..42dfa59b7 100644
--- a/src/client/views/nodes/MapBox/AnimationUtility.ts
+++ b/src/client/views/nodes/MapBox/AnimationUtility.ts
@@ -7,7 +7,7 @@ import * as turf from '@turf/turf';
import { Position } from '@turf/turf';
import { Feature, FeatureCollection, GeoJsonProperties, Geometry } from 'geojson';
import { observer } from 'mobx-react';
-import { action, computed, observable, runInAction } from 'mobx';
+import { action, computed, observable, runInAction, makeObservable } from 'mobx';
export enum AnimationStatus {
START = 'start',
@@ -26,16 +26,16 @@ export class AnimationUtility {
private ROUTE_COORDINATES: Position[] = [];
@observable
- private PATH: turf.helpers.Feature<turf.helpers.LineString, turf.helpers.Properties>;
+ private PATH?: turf.helpers.Feature<turf.helpers.LineString, turf.helpers.Properties> = undefined;
- private PATH_DISTANCE: number;
+ private PATH_DISTANCE: number = 0;
private FLY_IN_START_PITCH = 40;
- private FIRST_LNG_LAT: { lng: number; lat: number };
+ private FIRST_LNG_LAT: { lng: number; lat: number } = { lng: 0, lat: 0 };
private START_ALTITUDE = 3_000_000;
- private MAP_REF: MapRef | null;
+ private MAP_REF: MapRef | null = null;
- @observable private isStreetViewAnimation: boolean;
- @observable private animationSpeed: AnimationSpeed;
+ @observable private isStreetViewAnimation: boolean = false;
+ @observable private animationSpeed: AnimationSpeed = AnimationSpeed.MEDIUM;
@observable
private previousLngLat: { lng: number; lat: number };
@@ -174,6 +174,7 @@ export class AnimationUtility {
};
constructor(firstLngLat: { lng: number; lat: number }, routeCoordinates: Position[], isStreetViewAnimation: boolean, animationSpeed: AnimationSpeed, terrainDisplayed: boolean, mapRef: MapRef | null) {
+ makeObservable(this);
this.FIRST_LNG_LAT = firstLngLat;
this.previousLngLat = firstLngLat;
this.isStreetViewAnimation = isStreetViewAnimation;
@@ -232,6 +233,7 @@ export class AnimationUtility {
return;
}
+ if (!this.PATH) return;
// calculate the distance along the path based on the animationPhase
const alongPath = turf.along(this.PATH, this.PATH_DISTANCE * animationPhase).geometry.coordinates;