File size: 1,989 Bytes
4dc76bd a0f098c 34cc09a a0f098c 34cc09a b91bf2f b41f5ed 3b4890c 34cc09a 3b4890c 34cc09a 4dc76bd 34cc09a 4dc76bd 34cc09a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
const map = L.map('map').setView([20, 0], 2);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
// Custom robot marker icon
const robotIcon = L.icon({
iconUrl: 'https://cdn.shopify.com/s/files/1/0767/2040/6877/files/LeRobot.png?v=1745423992',
iconSize: [35, 35],
iconAnchor: [20, 40],
popupAnchor: [0, -35]
});
// Custom HQ marker icon
const hqIcon = L.icon({
iconUrl: 'https://cdn.shopify.com/s/files/1/0767/2040/6877/files/HF_Logo.png?v=1745427981',
iconSize: [35, 35],
iconAnchor: [20, 40],
popupAnchor: [0, -35]
});
// Function to add markers from a dataset
function addMarkers(data, icon) {
data.forEach(entry => {
const lat = parseFloat(entry.latitude || entry.latitude);
const lng = parseFloat(entry.longitude || entry.longitude);
const name = entry.name || entry.name || 'Unknown';
const address = entry.address || entry.Address || 'N/A';
const nbPeople = entry.nb_of_people || entry.Nb_of_people || 'N/A';
const discordUsername = entry.discord_username || entry.Discord_username || 'N/A';
if (!isNaN(lat) && !isNaN(lng)) {
L.marker([lat, lng], { icon: icon })
.addTo(map)
.bindPopup(`
<strong>${name}</strong><br>
${desc}<br>
<strong>Address:</strong> ${address}<br>
<strong>Nb of People:</strong> ${nbPeople}<br>
<strong>Discord Username:</strong> ${discordUsername}
`);
}
});
}
// Fetch and process the first dataset
fetch('data.json')
.then(response => response.json())
.then(data => {
addMarkers(data, robotIcon);
})
.catch(error => {
console.error('Error fetching data.json:', error);
});
// Fetch and process the second dataset
fetch('data_HQ_HF.json')
.then(response => response.json())
.then(data => {
addMarkers(data, hqIcon);
})
.catch(error => {
console.error('Error fetching data_HQ_HF.json:', error);
});
|