detail + position modifiche
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
<button (click)="generateQRCode()">
|
||||
<button>
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="17.334" height="23.4863">
|
||||
<g>
|
||||
<rect height="23.4863" opacity="0" width="17.334" x="0" y="0"/>
|
||||
|
||||
@@ -38,6 +38,7 @@ export class DetailComponent implements OnInit {
|
||||
console.log(this.id);
|
||||
console.log(this.embed);
|
||||
this.cord = await this.positionService.getLocation();
|
||||
console.log(this.cord);
|
||||
this.checkDistanceTimer();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import{Cord} from "../interface/cord";
|
||||
export class positionService{
|
||||
cord: Cord = { lat: 0, lon: 0 };
|
||||
|
||||
getDistanceBetweenCoordinates(lat1: number | undefined, lon1: number | undefined, lat2: number, lon2: number) {
|
||||
/*getDistanceBetweenCoordinates(lat1: number | undefined, lon1: number | undefined, lat2: number, lon2: number) {
|
||||
if (lat1 === undefined || lon1 === undefined) {
|
||||
console.log('lat1 or lon1 is undefined')
|
||||
return 0;
|
||||
@@ -24,8 +24,21 @@ export class positionService{
|
||||
// Distance in km
|
||||
return earthRadius * c;
|
||||
}
|
||||
}*/
|
||||
|
||||
getDistanceBetweenCoordinates(lat1: number, lon1: number, lat2: number, lon2: number) {
|
||||
const earthRadius = 6371; // Raggio della Terra in km
|
||||
const dLat = this.deg2rad(lat2 - lat1);
|
||||
const dLon = this.deg2rad(lon2 - lon1);
|
||||
const a = 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);
|
||||
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
const distance = earthRadius * c; // Distanza in km
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
||||
deg2rad(deg: number) {
|
||||
return deg * (Math.PI / 180)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user