modif card resto

This commit is contained in:
Your Name 2022-02-16 14:14:07 +01:00
commit 0bb889bc40
19 changed files with 466 additions and 194 deletions

View file

@ -32,20 +32,35 @@
</div>
<div class="infos ps-1 pt-2" style="color:#545454">
<span class="categorie pe-4" style="font-style: italic;">Kebab</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-2 pb-2 "></div>
<div class="trait-rouge pt-3"></div>
<i class="fas fa-walking pt-3 ps-2 pe-2" style="color:#a8a8a8"></i><span class="categorie pe-3"
style="font-weight: bold;">550m</span>
<i class="fas fa-euro-sign pt-3 ps-2 pe-2" style="color:#a8a8a8"></i><span class="prix pe-3"
style="font-weight: bold;">5-10€</span>
<a href="{{restaurant.website}}" target="blank" class="description " style=" color:#000000"><i class="bi bi-globe2 pt-3 ps-2 pe-2" style="color:#a8a8a8"></i><span
class="description " style="font-style: italic; ">Site web</span>
</a>
<div class="trait-rouge pt-2 pb-2"></div>
<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;">
<div>
<p class="description pt-3 ps-1 pe-1 text-justify d-block" style="font-size:0.9em; color:#545454"> Pas de site Web </p>
</div>
</ng-template>
<!-- ------------------------------------ -->
<div class="trait-rouge pt-2 pb-0"></div>
<div class="critere ps-1 pt-3">
<span class="sur-place pe-3" style="color:#545454">Sur place :</span>
<app-icon

View file

@ -7,16 +7,30 @@ import { Component,EventEmitter, Input, Output, OnInit } from '@angular/core';
})
export class CardRestoComponent implements OnInit {
@Input() restaurant : any ;
@Input() restaurant : any ;
distance : number;
@Input() likeResto: any;
@Output() clickLike = new EventEmitter<boolean>();
isLiked : boolean = false;
constructor() { }
constructor() {
this.distance = 0 ;
}
ngOnInit(): void {
// console.log(this.restaurant);
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);
}
onClickLike() {
@ -25,6 +39,24 @@ export class CardRestoComponent implements OnInit {
this.clickLike.emit(this.isLiked);
}
getDistanceFromLatLonInKm(lat1 : number , lon1 : number, lat2 : number, lon2 : number) {
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)
;
let c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
let d = R * c * 1000; // Distance in meters
return d;
}
deg2rad(deg : number) {
return deg * (Math.PI/180)
}
}