diff --git a/src/app/list/list.component.html b/src/app/list/list.component.html
index 30825f7..8c35dcb 100644
--- a/src/app/list/list.component.html
+++ b/src/app/list/list.component.html
@@ -14,7 +14,6 @@
{{location.location}}
- {{location.waypoints[0].name}}
{{waypoinst.name}}
diff --git a/src/app/list/list.component.ts b/src/app/list/list.component.ts
index a9486f5..c69c564 100644
--- a/src/app/list/list.component.ts
+++ b/src/app/list/list.component.ts
@@ -42,7 +42,7 @@ export class ListComponent implements OnInit, OnChanges {
});
}
});
-
+ this.getPosition();
}
ngOnChanges(changes: SimpleChanges) {
@@ -69,31 +69,33 @@ export class ListComponent implements OnInit, OnChanges {
}
private setDistance(): void {
-
- const intervalId = setInterval(() => {
- if (this.location) {
- if (this.location?.waypoints) {
- console.log("setDistance"+this.location);
- for (let i = 0; i < this.location.waypoints.length; i++) {
- console.log("for")
- this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.location.waypoints[i].lat, this.location?.lon, this.positionCord.lat, this.positionCord.lon));
- }
- clearInterval(intervalId);
+ if (this.locations && this.location){
+ if (this.isNear){
+ console.log("location lenght " + this.locations.length);
+ for (let i = 0; i < this.locations.length; i++) {
+ console.log("for"+i);
+ console.log("lat" + this.locations[i].lat);
+ this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.locations[i].lat, this.locations[i].lon, this.positionCord.lat, this.positionCord.lon));
}
+ } else{
+ if (this.location?.waypoints) {
+ console.log("waypoints lenght " + this.location.waypoints.length);
+ for (let i = 0; i < this.location.waypoints.length; i++) {
+ console.log("for"+i);
+ console.log("lat" + this.location.waypoints[i].lat);
+ this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.location.waypoints[i].lat, this.location.waypoints[i].lon, this.positionCord.lat, this.positionCord.lon));
+ }
+ }
+ }
+ }
console.log("ciao" + this.distance[0])
- }}, 1000);
- //da aggiungere il cambiamento in tutti i punti, forse fatto ma sono stanco
}
- getDistance(latLocation: number | undefined, lonLocation: number | undefined): any {
+ getPosition(): any {
setInterval(async () => {
this.positionCord = await this.positionService.getLocation();
- if (this.location) {
- return this.positionService.getDistanceBetweenCoordinates(latLocation, lonLocation, this.positionCord.lat, this.positionCord.lon);
- } else {
- return 0;
- }
- }, 1000);
+ this.setDistance();
+ }, 2000);
}
diff --git a/src/assets/data.json b/src/assets/data.json
index 3b8cc15..c998e47 100644
--- a/src/assets/data.json
+++ b/src/assets/data.json
@@ -2,22 +2,22 @@
{
"location": "Biasca",
"region": "ticino",
- "lat": 46.123,
- "lon": 8.123,
+ "lat": 46.361184,
+ "lon": 8.970937,
"waypoints": [
{
"id": 1,
- "name": "Punto 1",
- "lat": 46.123,
- "lon": 8.123,
- "description": "Descrizione del punto 1",
+ "name": "Cascata Santa Petronilla",
+ "lat": 46.35328215446709,
+ "lon": 8.97758397155138,
+ "description": "",
"img": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
},
{
"id": 2,
- "name": "Punto 2",
- "lat": 46.123,
- "lon": 8.123,
+ "name": "Casa Küng",
+ "lat": 46.363570208549994,
+ "lon": 8.963464722308554,
"description": "Descrizione del punto 2",
"img": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
},
@@ -34,8 +34,8 @@
{
"location": "Lugano",
"region": "TI",
- "lat": 46.123,
- "lon": 8.123,
+ "lat": 46.0036778,
+ "lon": 8.951052,
"waypoints": [
{
"id": 4,