diff --git a/src/app/app.component.html b/src/app/app.component.html index 47b6c9b..0680b43 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,2 +1 @@ - diff --git a/src/app/detail/detail.component.ts b/src/app/detail/detail.component.ts index da03b0a..cef9c04 100755 --- a/src/app/detail/detail.component.ts +++ b/src/app/detail/detail.component.ts @@ -1,31 +1,32 @@ -import { Component, OnInit } from '@angular/core'; -import {interval} from "rxjs"; +import {Component, OnInit} from '@angular/core'; @Component({ selector: 'app-detail', templateUrl: './detail.component.html', styleUrls: ['./detail.component.css'] }) -export class DetailComponent implements OnInit{ +export class DetailComponent implements OnInit { ngOnInit(): void { this.getLocation(); } - test = { + + test = { name: 'SPAI', cordinates: "46.165262,8.791225", - description: "Lorem ipsum" - } + description: "Lorem ipsum" + } - cord = { + cord = { lat: 0, lng: 0 - } + } - showNav = true; + showNav = true; distance = 0; - getLocation() { - console.log("get location"); + + getLocation() { + console.log("get location"); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition((position) => { this.cord.lat = position.coords.latitude; @@ -33,29 +34,29 @@ export class DetailComponent implements OnInit{ console.log(this.cord); this.checkDistanceTimer(); }) - }else { + } else { alert("Geolocation is not supported by this browser."); } } checkDistanceTimer() { - //set interval + //set interval let lat1 = this.cord.lat; let lon1 = this.cord.lng; let lat2 = this.test.cordinates.split(",")[0]; let lon2 = this.test.cordinates.split(",")[1]; let intervalID = setInterval(() => { - if(this.showNav){ + if (this.showNav) { this.distance = this.getDistanceBetweenCoordinates(lat1, lon1, +lat2, +lon2); console.log(this.distance); - if(this.distance < 0.05){ + if (this.distance < 0.05) { this.showNav = false; clearInterval(intervalID); } - }else{ + } else { clearInterval(intervalID); } - } , 1000); + }, 1000); } getDistanceBetweenCoordinates(lat1: number, lon1: number, lat2: number, lon2: number) { @@ -63,17 +64,18 @@ export class DetailComponent implements OnInit{ const dLat = this.deg2rad(lat2 - lat1); // deg2rad below const dLon = this.deg2rad(lon2 - lon1); const a = - Math.sin(dLat/2) * Math.sin(dLat/2) + + Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(this.deg2rad(lat1)) * Math.cos(this.deg2rad(lat2)) * - Math.sin(dLon/2) * Math.sin(dLon/2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) ; - const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); - const distance = earthRadius * c; // Distance in km - return distance; + const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + // Distance in km + return earthRadius * c; } deg2rad(deg: number) { - return deg * (Math.PI/180) + return deg * (Math.PI / 180) } + /// } diff --git a/src/app/service/translate.service.ts b/src/app/service/translate.service.ts index 274d26a..14e9f2a 100644 --- a/src/app/service/translate.service.ts +++ b/src/app/service/translate.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Translate } from '@google-cloud/translate/build/src/v2'; +//import { Translate } from '@google-cloud/translate/build/src/v2'; @Injectable({ @@ -7,15 +7,15 @@ import { Translate } from '@google-cloud/translate/build/src/v2'; }) export class TranslateService { - private translate: Translate; + //private translate: Translate; - constructor() { - this.translate = new Translate({projectId: 'Modulo-152'}); - } + // constructor() { + // this.translate = new Translate({projectId: 'Modulo-152'}); + //} - async translateText(text: string, target: string): Promise { - const [translation] = await this.translate.translate(text, target); - return translation; - } + //async translateText(text: string, target: string): Promise { + //const [translation] = await this.translate.translate(text, target); + //return translation; + //} }