changes list component
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
<h1>
|
<h1>
|
||||||
{{location.location}}
|
{{location.location}}
|
||||||
</h1>
|
</h1>
|
||||||
{{location.waypoints[0].name}}
|
|
||||||
<div *ngFor="let waypoinst of location.waypoints, let i = index">
|
<div *ngFor="let waypoinst of location.waypoints, let i = index">
|
||||||
<h3>
|
<h3>
|
||||||
<a class="link link-primary" href="location/{{location.location}}/{{waypoinst.id}}"> {{waypoinst.name}}</a>
|
<a class="link link-primary" href="location/{{location.location}}/{{waypoinst.id}}"> {{waypoinst.name}}</a>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export class ListComponent implements OnInit, OnChanges {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
@@ -69,31 +69,33 @@ export class ListComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setDistance(): void {
|
private setDistance(): void {
|
||||||
|
if (this.locations && this.location){
|
||||||
const intervalId = setInterval(() => {
|
if (this.isNear){
|
||||||
if (this.location) {
|
console.log("location lenght " + this.locations.length);
|
||||||
if (this.location?.waypoints) {
|
for (let i = 0; i < this.locations.length; i++) {
|
||||||
console.log("setDistance"+this.location);
|
console.log("for"+i);
|
||||||
for (let i = 0; i < this.location.waypoints.length; i++) {
|
console.log("lat" + this.locations[i].lat);
|
||||||
console.log("for")
|
this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.locations[i].lat, this.locations[i].lon, this.positionCord.lat, this.positionCord.lon));
|
||||||
this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.location.waypoints[i].lat, this.location?.lon, this.positionCord.lat, this.positionCord.lon));
|
|
||||||
}
|
|
||||||
clearInterval(intervalId);
|
|
||||||
}
|
}
|
||||||
|
} 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])
|
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 () => {
|
setInterval(async () => {
|
||||||
this.positionCord = await this.positionService.getLocation();
|
this.positionCord = await this.positionService.getLocation();
|
||||||
if (this.location) {
|
this.setDistance();
|
||||||
return this.positionService.getDistanceBetweenCoordinates(latLocation, lonLocation, this.positionCord.lat, this.positionCord.lon);
|
}, 2000);
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user