mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-03-04 23:27:46 +01:00
fix location of node in node.html
This commit is contained in:
@@ -895,13 +895,21 @@ function addMarker(id, lat, lon, color = "red", node = null) {
|
||||
async function drawNeighbors(src, nids) {
|
||||
if (!map) return;
|
||||
|
||||
// Ensure source node position exists
|
||||
const srcNode = await fetchNodeFromApi(src);
|
||||
if (!srcNode || !srcNode.last_lat || !srcNode.last_long) return;
|
||||
// Prefer the currently displayed source position (e.g. latest track point),
|
||||
// then fall back to the node API location.
|
||||
let srcLat;
|
||||
let srcLon;
|
||||
let srcNode = currentNode || nodeCache[src] || null;
|
||||
|
||||
const srcLat = srcNode.last_lat / 1e7;
|
||||
const srcLon = srcNode.last_long / 1e7;
|
||||
if (nodePositions[src]) {
|
||||
[srcLat, srcLon] = nodePositions[src];
|
||||
} else {
|
||||
srcNode = srcNode || await fetchNodeFromApi(src);
|
||||
if (!srcNode || !srcNode.last_lat || !srcNode.last_long) return;
|
||||
srcLat = srcNode.last_lat / 1e7;
|
||||
srcLon = srcNode.last_long / 1e7;
|
||||
nodePositions[src] = [srcLat, srcLon];
|
||||
}
|
||||
|
||||
for (const nid of nids) {
|
||||
const neighbor = await fetchNodeFromApi(nid);
|
||||
@@ -1619,15 +1627,16 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
// ✅ MAP MUST EXIST FIRST
|
||||
if (!map) initMap();
|
||||
|
||||
// Load the track first so neighbor links anchor to the same
|
||||
// visible current-node position shown on this page.
|
||||
await loadTrack();
|
||||
|
||||
// ✅ DRAW LATEST NEIGHBORS ONCE
|
||||
const neighborIds = await loadLatestNeighborIds();
|
||||
if (neighborIds.length) {
|
||||
await drawNeighbors(fromNodeId, neighborIds);
|
||||
}
|
||||
|
||||
// ⚠️ Track may add to map, but must not hide it
|
||||
await loadTrack();
|
||||
|
||||
await loadPackets();
|
||||
initPacketPortFilter();
|
||||
await loadTelemetryCharts();
|
||||
|
||||
Reference in New Issue
Block a user