fixed calibrating
This commit is contained in:
parent
3b0d69b4c9
commit
432150f41b
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "map-alliance",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve --host 0.0.0.0",
|
||||
|
@ -8,7 +8,7 @@
|
||||
<button mat-icon-button (click)="draw()" [ngClass]="{'selected': drawListener.length}"><mat-icon>create</mat-icon></button>
|
||||
<button mat-icon-button><mat-icon>straighten</mat-icon></button>
|
||||
<button mat-icon-button (click)="remove = !remove" [ngClass]="{'selected': remove}"><mat-icon>delete</mat-icon></button>
|
||||
<button *ngIf="physicsService.calibrate.value != null" mat-icon-button (click)="calibrate()"><mat-icon>explore</mat-icon></button>
|
||||
<button *ngIf="!isNaN(position?.heading)" mat-icon-button (click)="calibrate()"><mat-icon>explore</mat-icon></button>
|
||||
<button mat-icon-button [matMenuTriggerFor]="styleMenu"><mat-icon>layers</mat-icon></button>
|
||||
<mat-menu #styleMenu="matMenu">
|
||||
<button mat-menu-item (click)="style = 'satellite'" [ngClass]="{'selected': style == 'satellite'}">Satellite</button>
|
||||
@ -32,8 +32,8 @@
|
||||
<span *ngIf="!position" class="text-danger">No GPS</span>
|
||||
<div *ngIf="position" class="text-white">
|
||||
Heading:
|
||||
<span *ngIf="!position.heading" class="text-danger">No Heading</span>
|
||||
<span *ngIf="position.heading">{{position.heading | number : '0.0-0'}}°</span>
|
||||
<span *ngIf="isNaN(position.heading)" class="text-danger">No Heading</span>
|
||||
<span *ngIf="!isNaN(position.heading)">{{position.heading | number : '0.0-0'}}°</span>
|
||||
<br>
|
||||
Latitude: {{position.latitude | number : '0.0-5'}}
|
||||
<br>
|
||||
|
@ -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;
|
||||
|
@ -10,7 +10,7 @@ export class PhysicsService {
|
||||
private motionTimestamp;
|
||||
|
||||
requireCalibration = new EventEmitter();
|
||||
calibrate = new BehaviorSubject(0);
|
||||
calibrate = new BehaviorSubject<number>(Infinity);
|
||||
|
||||
info = new BehaviorSubject(null);
|
||||
motion = new BehaviorSubject<DeviceMotionEvent>(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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user