Some more updates
This commit is contained in:
parent
110c841d9d
commit
37a6ae92ae
@ -16,6 +16,7 @@ import {AngularFireModule} from "@angular/fire";
|
|||||||
import {AngularFirestoreModule} from "@angular/fire/firestore";
|
import {AngularFirestoreModule} from "@angular/fire/firestore";
|
||||||
import {ToolbarComponent} from "./components/toolbar/toolbar.component";
|
import {ToolbarComponent} from "./components/toolbar/toolbar.component";
|
||||||
import {PaletteComponent} from "./components/palette/palette.component";
|
import {PaletteComponent} from "./components/palette/palette.component";
|
||||||
|
import {MarkerComponent} from "./components/marker/marker.component";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -23,6 +24,7 @@ import {PaletteComponent} from "./components/palette/palette.component";
|
|||||||
CalibrateComponent,
|
CalibrateComponent,
|
||||||
HomeComponent,
|
HomeComponent,
|
||||||
MapComponent,
|
MapComponent,
|
||||||
|
MarkerComponent,
|
||||||
PaletteComponent,
|
PaletteComponent,
|
||||||
PermissionsComponent,
|
PermissionsComponent,
|
||||||
ToolbarComponent
|
ToolbarComponent
|
||||||
@ -39,7 +41,7 @@ import {PaletteComponent} from "./components/palette/palette.component";
|
|||||||
MatInputModule,
|
MatInputModule,
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
entryComponents: [CalibrateComponent, PermissionsComponent],
|
entryComponents: [CalibrateComponent, MarkerComponent, PermissionsComponent],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule {
|
||||||
|
@ -19,7 +19,7 @@ export enum WeatherLayers {
|
|||||||
TEMP_NEW
|
TEMP_NEW
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ARROW = L.icon({iconUrl: '/assets/images/arrow.png', iconSize: [50, 55], iconAnchor: [25, 28]});
|
export const ARROW = L.icon({iconUrl: '/assets/images/arrow.png', iconSize: [40, 45], iconAnchor: [20, 23]});
|
||||||
export const MARKER = L.icon({iconUrl: '/assets/images/marker.png', iconSize: [40, 55], iconAnchor: [20, 55]});
|
export const MARKER = L.icon({iconUrl: '/assets/images/marker.png', iconSize: [40, 55], iconAnchor: [20, 55]});
|
||||||
|
|
||||||
export class MapService {
|
export class MapService {
|
||||||
|
@ -15,7 +15,6 @@ export class PhysicsService {
|
|||||||
motion = new BehaviorSubject<DeviceMotionEvent>(null);
|
motion = new BehaviorSubject<DeviceMotionEvent>(null);
|
||||||
orientation = new BehaviorSubject<DeviceOrientationEvent>(null);
|
orientation = new BehaviorSubject<DeviceOrientationEvent>(null);
|
||||||
position = new BehaviorSubject<Position>(null);
|
position = new BehaviorSubject<Position>(null);
|
||||||
speed = new BehaviorSubject(null);
|
|
||||||
|
|
||||||
constructor(permissionsService: PermissionsService) {
|
constructor(permissionsService: PermissionsService) {
|
||||||
permissionsService.requestPermission('geolocation', 'gps_fixed', 'Can we use your location?').then(granted => {
|
permissionsService.requestPermission('geolocation', 'gps_fixed', 'Can we use your location?').then(granted => {
|
||||||
@ -24,23 +23,11 @@ export class PhysicsService {
|
|||||||
window.addEventListener('deviceorientation', orientation => this.orientation.next(orientation));
|
window.addEventListener('deviceorientation', orientation => this.orientation.next(orientation));
|
||||||
window.addEventListener('devicemotion', motion => this.motion.next(motion));
|
window.addEventListener('devicemotion', motion => this.motion.next(motion));
|
||||||
navigator.geolocation.watchPosition(position => this.position.next(position));
|
navigator.geolocation.watchPosition(position => this.position.next(position));
|
||||||
|
navigator.geolocation.getCurrentPosition(e => console.log(e));
|
||||||
// Calculate speed from motion events
|
this.position.subscribe(e => console.log(e));
|
||||||
this.motion.subscribe(event => {
|
|
||||||
if (!this.motionTimestamp) return this.motionTimestamp = new Date().getTime();
|
|
||||||
|
|
||||||
let currentTime = new Date().getTime();
|
|
||||||
let {speedX, speedY, speedZ} = this.speed.value || {speedX: 0, speedY: 0, speedZ: 0};
|
|
||||||
this.speed.next({
|
|
||||||
speedX: speedX + event.acceleration.x / 1000 * ((currentTime - this.motionTimestamp) / 1000) / 3600,
|
|
||||||
speedY: speedY + event.acceleration.y / 1000 * ((currentTime - this.motionTimestamp) / 1000) / 3600,
|
|
||||||
speedZ: speedZ + event.acceleration.z / 1000 * ((currentTime - this.motionTimestamp) / 1000) / 3600
|
|
||||||
});
|
|
||||||
this.motionTimestamp = currentTime;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Combine data into one nice package
|
// Combine data into one nice package
|
||||||
combineLatest(this.position, this.orientation, this.calibrate, this.speed).subscribe(data => {
|
combineLatest(this.position, this.orientation, this.calibrate).subscribe(data => {
|
||||||
if(!data[0]) return;
|
if(!data[0]) return;
|
||||||
|
|
||||||
let info = {
|
let info = {
|
||||||
@ -63,7 +50,6 @@ export class PhysicsService {
|
|||||||
if(info.heading < 0) info.heading += 360;
|
if(info.heading < 0) info.heading += 360;
|
||||||
if(info.heading >= 360) info.heading -= 360;
|
if(info.heading >= 360) info.heading -= 360;
|
||||||
}
|
}
|
||||||
if(info.speed == null && !!data[3]) info.speed = Math.sqrt(data[3].x**2 + data[3].y**2 + data[3].z**2);
|
|
||||||
|
|
||||||
this.info.next(info);
|
this.info.next(info);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user