diff --git a/src/app/card-resto/card-resto.component.ts b/src/app/card-resto/card-resto.component.ts index b6691d6..106a240 100644 --- a/src/app/card-resto/card-resto.component.ts +++ b/src/app/card-resto/card-resto.component.ts @@ -32,16 +32,16 @@ export class CardRestoComponent implements OnInit { } getDistanceFromLatLonInKm(lat1 : number , lon1 : number, lat2 : number, lon2 : number) { - var R = 6371; // Radius of the earth in km - var dLat = this.deg2rad(lat2-lat1); // deg2rad below - var dLon = this.deg2rad(lon2-lon1); - var a = + let R = 6371; // Radius of the earth in km + let dLat = this.deg2rad(lat2-lat1); // deg2rad below + let dLon = this.deg2rad(lon2-lon1); + let 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) ; - var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); - var d = R * c * 1000; // Distance in meters + let c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); + let d = R * c * 1000; // Distance in meters return d; }