map UI changes
All checks were successful
Meshtastic Map - See local Meshtastic Nodes / deploy (push) Successful in 1s

This commit is contained in:
david 2025-04-23 13:05:48 -07:00
parent 28d09862c1
commit 8641463324

View File

@ -15,22 +15,33 @@
var map = L.map('map').setView([0, 0], 2);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
let myCoords = null;
const today = new Date();
const daysSince = (test) => {
if (test) {
const diffTime = Math.abs(test.getTime() - today.getTime());
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
return diffDays;
}
return "N/A"
}
const getNodeDesc = (node) => {
const deviceMetrics = node?.deviceMetrics
const hopsAway = node?.hopsAway ?? 'N/A';
const lastHeard = node?.lastHeard;
const lastHeard = node?.lastHeard ? new Date(node?.lastHeard * 1000) : null
const num = node?.num;
const position = node?.position;
const snr = node?.snr ?? 'N/A';
const user = node?.user;
const lat = position?.latitude
const lon = position?.longitude
return `
Id: ${user.id}<br/>
Hops Away: ${hopsAway}<br/>
${user.id}<br/>
${user.shortName}<br/>
${hopsAway} hop<br/>
S/N: ${snr} dbM<br/>
Loc: ${lat}, ${lon}
Last Heard: ${daysSince(lastHeard)} days
`
}