update(map): public club map
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 5m26s

This commit is contained in:
Thibaut Valentin 2025-01-20 15:32:13 +01:00
parent 476f2b5233
commit 8ecb9d714f
2 changed files with 8 additions and 33 deletions

View File

@ -15,8 +15,6 @@
<body>
<div id="map" style="width: 100%; height: 95vh"></div>
<div id="club_map_data" style="width: 100%; min-height: 0; background-color: #00000011; padding: 0.5em"></div>
<script src="club-maps.js"></script>
</body>
</html>

View File

@ -1,7 +1,4 @@
const div_map = document.getElementById('map');
//const div_info = document.getElementById('club_map_data');
const api_url = "http://localhost:5173";
const api_url = "https://intra.ffsaf.fr";
let map = L.map('map').setView([46.631196, 2.456000], 6);
@ -27,8 +24,6 @@ const sortHoraire = (a, b) => {
return a.day - b.day;
}
//let last_info_show = null;
async function getData() {
const response = await fetch(`${api_url}/api/club/get_map_data`);
if (!response.ok) {
@ -37,20 +32,16 @@ async function getData() {
const data = await response.json();
for (const d of data) {
console.log(d);
if (d.training_location.length === 0)
continue;
let icon = null;
if (d.uuid !== null) {
console.log("logo");
const img = await getMeta(`http://localhost:5173/api/club/${d.uuid}/logo`);
const img = await getMeta(`${api_url}/api/club/${d.uuid}/logo`);
let ratio = img.naturalHeight / img.naturalWidth;
icon = L.icon({
iconUrl: `http://localhost:5173/api/club/${d.uuid}/logo`,
iconUrl: `${api_url}/api/club/${d.uuid}/logo`,
iconSize: [50, 50 * ratio], // size of the icon
//shadowSize: [50, 64], // size of the shadow
@ -61,7 +52,6 @@ async function getData() {
}
for (const m of d.training_location) {
console.log(m);
let marker;
if (icon === null)
marker = L.marker([m.lat, m.lng]);
@ -89,7 +79,6 @@ async function getData() {
div_info.appendChild(document.createElement("br"));
} else {
for (const m of JSON.parse(d.training_day_time).sort(sortHoraire)) {
console.log(m);
let days = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"];
div_info.appendChild(document.createTextNode(`${days[m.day]}: ${timeNumberToSting(m.time_start)} - ${timeNumberToSting(m.time_end)}`));
@ -111,24 +100,12 @@ async function getData() {
}
marker.bindPopup(div_info.innerHTML);
//marker.on('click', e => {
//console.log("click");
//if (div_map.style.height !== "95vh" && last_info_show === d.name) {
//div_map.style.height = "95vh";
//div_info.style.minHeight = "0";
//div_info.replaceChildren();
//} else {
//div_map.style.height = "80vh";
//div_info.style.minHeight = "15vh";
//div_info.replaceChildren();
//last_info_show = d.name;
//}
//})
if (icon !== null){
marker.valueOf()._icon.style.backgroundColor = '#FFFFFF';
marker.valueOf()._icon.style.borderRadius = '10px';
}
}
}
}
getData().then(() => console.log("end loading"));
console.log("test");
getData().then(() => console.log("end loading"));