From 37a6ae92ae817e0f9e4503a179be9838d966d978 Mon Sep 17 00:00:00 2001 From: ztimson Date: Fri, 23 Aug 2019 17:56:52 -0400 Subject: [PATCH] Some more updates --- src/app/app.module.ts | 4 +++- src/app/services/map.service.ts | 2 +- src/app/services/physics.service.ts | 20 +++----------------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index acae5dc..14bd11e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -16,6 +16,7 @@ import {AngularFireModule} from "@angular/fire"; import {AngularFirestoreModule} from "@angular/fire/firestore"; import {ToolbarComponent} from "./components/toolbar/toolbar.component"; import {PaletteComponent} from "./components/palette/palette.component"; +import {MarkerComponent} from "./components/marker/marker.component"; @NgModule({ declarations: [ @@ -23,6 +24,7 @@ import {PaletteComponent} from "./components/palette/palette.component"; CalibrateComponent, HomeComponent, MapComponent, + MarkerComponent, PaletteComponent, PermissionsComponent, ToolbarComponent @@ -39,7 +41,7 @@ import {PaletteComponent} from "./components/palette/palette.component"; MatInputModule, ], providers: [], - entryComponents: [CalibrateComponent, PermissionsComponent], + entryComponents: [CalibrateComponent, MarkerComponent, PermissionsComponent], bootstrap: [AppComponent] }) export class AppModule { diff --git a/src/app/services/map.service.ts b/src/app/services/map.service.ts index 34fd1ed..9ca7d51 100644 --- a/src/app/services/map.service.ts +++ b/src/app/services/map.service.ts @@ -19,7 +19,7 @@ export enum WeatherLayers { 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 class MapService { diff --git a/src/app/services/physics.service.ts b/src/app/services/physics.service.ts index 08b9cae..d2f526a 100644 --- a/src/app/services/physics.service.ts +++ b/src/app/services/physics.service.ts @@ -15,7 +15,6 @@ export class PhysicsService { motion = new BehaviorSubject(null); orientation = new BehaviorSubject(null); position = new BehaviorSubject(null); - speed = new BehaviorSubject(null); constructor(permissionsService: PermissionsService) { 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('devicemotion', motion => this.motion.next(motion)); navigator.geolocation.watchPosition(position => this.position.next(position)); - - // Calculate speed from motion events - 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; - }); + navigator.geolocation.getCurrentPosition(e => console.log(e)); + this.position.subscribe(e => console.log(e)); // 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; let info = { @@ -63,7 +50,6 @@ export class PhysicsService { if(info.heading < 0) 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); })