lint GeocodageComponent

This commit is contained in:
Noah Lancien 2023-04-20 09:10:54 +00:00
parent 521371029d
commit 9fcc8538db

View file

@ -66,7 +66,6 @@
}
if(data.signsLabels) {
this.labels = data.signsLabels;
console.log(this.labels)
}
if(data.formId) {
this.formAddress = document.getElementById(data.formId) as HTMLFormElement;
@ -86,19 +85,16 @@
},
methods: {
searchAddress(event?: Event) {
console.log(event);
event?.preventDefault();
const formInput = this.formAddress.firstElementChild as HTMLInputElement;
if (formInput.value) {
this.address = formInput.value.split(" ").join("+");
console.log(this.address)
}
fetch("https://api-adresse.data.gouv.fr/search/?q=" + this.address)
.then((response) => {
return response.json().then((data) => {
this.userPos = {};
this.searchedAddress = data.features[0];
console.log(this.searchedAddress);
this.calcPosition();
return data;
}).catch((err) => {
@ -145,7 +141,6 @@
displayMarkers(userLat: number, userLon: number) {
let map = this.map;
map.eachLayer(function (layer: L.Layer) {
// console.log(layer);
map.removeLayer(layer);
});
L.tileLayer("https://{s}.tile.jawg.io/jawg-sunny/{z}/{x}/{y}{r}.png?access-token={accessToken}", {
@ -184,12 +179,12 @@
},
displayShopsList() {
const list = document.getElementById('shops-list') as HTMLElement;
const baseItem = document.getElementById('shop-list-item')as Node;
const baseItem = document.getElementById('shop-list-item') as HTMLElement;
list.replaceChildren(baseItem);
let i = 1;
for(let shop of this.shops) {
let shopListElement = baseItem?.cloneNode(true);
let shopListElement = baseItem?.cloneNode(true) as HTMLElement;
// Set the shop sign logo
const imgTag = shopListElement.childNodes[1].childNodes[1] as HTMLElement
imgTag.setAttribute('src', this.stickers[shop.signs]);
@ -205,8 +200,9 @@
}
shopListElement.childNodes[1].childNodes[3].childNodes[5].textContent = shop.distance?.toString() + unit;
// Link to get the journey on Google Maps
shopListElement.childNodes[3].setAttribute('href', 'https://www.google.com/maps/dir/?api=1&origin=' + this.searchedAddress.geometry.coordinates[1] + ',' + this.searchedAddress.geometry.coordinates[0] + '&destination=' + shop.latitude + ',' + shop.longitude);
shopListElement.childNodes[3].setAttribute('target', '_blank');
let aTag = shopListElement.childNodes[3] as HTMLElement;
aTag.setAttribute('href', 'https://www.google.com/maps/dir/?api=1&origin=' + this.searchedAddress.geometry.coordinates[1] + ',' + this.searchedAddress.geometry.coordinates[0] + '&destination=' + shop.latitude + ',' + shop.longitude);
aTag.setAttribute('target', '_blank');
shopListElement.classList.remove('d-none');
shopListElement.setAttribute('id', 'shop-list-item-' + i);
@ -220,7 +216,6 @@
},
watch: {
addressInput() {
console.log("ok");
let addressInputField = document.getElementById("address") as HTMLInputElement;
this.addressInput = addressInputField.value;
this.fullAddress = this.addressInput.split(",");