@@ -32,8 +32,8 @@
No GPS
Heading:
- No Heading
- {{position.heading | number : '0.0-0'}}°
+ No Heading
+ {{position.heading | number : '0.0-0'}}°
Latitude: {{position.latitude | number : '0.0-5'}}
diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts
index 93d2f8f..62de25c 100644
--- a/src/app/map/map.component.ts
+++ b/src/app/map/map.component.ts
@@ -24,9 +24,12 @@ export class MapComponent {
style: 'satellite' | 'terrain' | 'roadmap' | 'hybrid' = 'terrain';
version = version;
+ isNaN = isNaN;
+
constructor(private bpObserver: BreakpointObserver, public physicsService: PhysicsService, private snackBar: MatSnackBar, private bottomSheet: MatBottomSheet) {
bpObserver.observe([Breakpoints.Handset]).subscribe(results => this.mobile = results.matches);
physicsService.info.pipe(filter(coord => !!coord), debounceTime(50)).subscribe(pos => {
+ console.log('fire');
if(this.mapApi) {
if(!this.position) this.center(pos);
this.position = pos;
diff --git a/src/app/physics/physics.service.ts b/src/app/physics/physics.service.ts
index d799b44..f4f637c 100644
--- a/src/app/physics/physics.service.ts
+++ b/src/app/physics/physics.service.ts
@@ -10,7 +10,7 @@ export class PhysicsService {
private motionTimestamp;
requireCalibration = new EventEmitter();
- calibrate = new BehaviorSubject(0);
+ calibrate = new BehaviorSubject(Infinity);
info = new BehaviorSubject(null);
motion = new BehaviorSubject(null);
@@ -54,13 +54,14 @@ export class PhysicsService {
speed: data[0].coords.speed
};
- if(info.heading == null && !!data[1] && data[1].alpha) {
- if(!data[1].absolute && this.calibrate.value == null) {
- this.requireCalibration.emit();
+ // TODO-debug
+ if(info.heading == null && data[1]) {
+ if(!data[1].absolute && data[2] == Infinity) {
this.calibrate.next(0);
+ this.requireCalibration.emit();
}
- info.heading = data[1].alpha + this.calibrate.value;
+ info.heading = data[1].alpha + (data[2] == Infinity ? 0 : data[2]);
if(info.heading > 360) info.heading -= 360;
if(info.heading < 0) info.heading += 360;
}