distance+Site Web in cardResto

This commit is contained in:
Thomas Cardon 2022-02-15 14:54:17 +01:00
parent bdeb6fd265
commit 993be2e1b0
2 changed files with 55 additions and 11 deletions

View File

@ -27,18 +27,30 @@
<span class="ps-3 mt-3 " style="font-size: 1.1em; color:#545454">5/5</span>
</div>
<div class="infos ps-1 pt-2" style="color:#545454">
<span class="categorie pe-4" style="font-style: italic;">Kebab</span>
<i class="fas fa-walking ps-2 pe-1" style="color:#a8a8a8"></i><span class="categorie pe-4"
style="font-weight: bold;">550m</span>
<i class="fas fa-euro-sign ps-2 pe-1" style="color:#a8a8a8"></i><span class="prix"
style="font-weight: bold;">5-10€</span>
<div>
<span class="categorie pe-4" style="font-style: italic;" *ngFor="let categorie of restaurant.typerestaus">{{ categorie.libelle }}</span>
</div>
<div>
<i class="fas fa-walking ps-2 pe-1" style="color:#a8a8a8"></i>
<span class="categorie pe-4" style="font-weight: bold;">{{distance}} mètres</span>
</div>
<div>
<i class="fas fa-euro-sign ps-2 pe-1" style="color:#a8a8a8"></i>
<span class="prix" style="font-weight: bold;">5-10€</span>
</div>
</div>
<div class="trait-rouge pt-3"></div>
<p class="description pt-3 ps-1 pe-1 text-justify d-block" style="font-size:0.9em; color:#545454"><span
class="description pe-1" style="font-style: italic;font-weight: bold;">Descriptif :</span> cest le faux
texte standard de l'imprimerie depuis
les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour
réaliser un livre spécimen de polices de texte.</p>
<div *ngIf="restaurant.website; else noWebsite">
<p class="description pt-3 ps-1 pe-1 text-justify d-block" style="font-size:0.9em; color:#545454">
<a href="{{restaurant.website}}" class="description pe-1" style="font-style: italic;font-weight: bold;">Site Web</a>
</p>
</div>
<!-- le else de notre *ngIf plus haut-->
<ng-template #noWebsite class="description pe-1" style="font-style: italic;font-weight: bold;">Pas de site Web</ng-template>
<!-- ------------------------------------ -->
<div class="trait-rouge pt-2 pb-0"></div>
<div class="critere ps-1 pt-3">
<span class="sur-place pe-1" style="color:#545454">Sur place :</span>

View File

@ -8,15 +8,47 @@ import { Component, Input, OnInit } from '@angular/core';
export class CardRestoComponent implements OnInit {
@Input() restaurant : any ;
distance : number;
constructor() { }
constructor() {
this.distance = 0 ;
}
ngOnInit(): void {
console.log(this.restaurant);
this.distance = Math.round(
this.getDistanceFromLatLonInKm(
48.86201110271593 , //latitude Simplon
2.4361804827725417, //longitude Simplon
this.restaurant.latitude,
this.restaurant.longitude)
);
console.log(this.distance);
}
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 =
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
return d;
}
deg2rad(deg : number) {
return deg * (Math.PI/180)
}
}