mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-06-11 01:34:52 +02: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) {
|
async function drawNeighbors(src, nids) {
|
||||||
if (!map) return;
|
if (!map) return;
|
||||||
|
|
||||||
// Ensure source node position exists
|
// Prefer the currently displayed source position (e.g. latest track point),
|
||||||
const srcNode = await fetchNodeFromApi(src);
|
// then fall back to the node API location.
|
||||||
if (!srcNode || !srcNode.last_lat || !srcNode.last_long) return;
|
let srcLat;
|
||||||
|
let srcLon;
|
||||||
|
let srcNode = currentNode || nodeCache[src] || null;
|
||||||
|
|
||||||
const srcLat = srcNode.last_lat / 1e7;
|
if (nodePositions[src]) {
|
||||||
const srcLon = srcNode.last_long / 1e7;
|
[srcLat, srcLon] = nodePositions[src];
|
||||||
nodePositions[src] = [srcLat, srcLon];
|
} 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) {
|
for (const nid of nids) {
|
||||||
const neighbor = await fetchNodeFromApi(nid);
|
const neighbor = await fetchNodeFromApi(nid);
|
||||||
@@ -1619,15 +1627,16 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
// ✅ MAP MUST EXIST FIRST
|
// ✅ MAP MUST EXIST FIRST
|
||||||
if (!map) initMap();
|
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
|
// ✅ DRAW LATEST NEIGHBORS ONCE
|
||||||
const neighborIds = await loadLatestNeighborIds();
|
const neighborIds = await loadLatestNeighborIds();
|
||||||
if (neighborIds.length) {
|
if (neighborIds.length) {
|
||||||
await drawNeighbors(fromNodeId, neighborIds);
|
await drawNeighbors(fromNodeId, neighborIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ⚠️ Track may add to map, but must not hide it
|
|
||||||
await loadTrack();
|
|
||||||
|
|
||||||
await loadPackets();
|
await loadPackets();
|
||||||
initPacketPortFilter();
|
initPacketPortFilter();
|
||||||
await loadTelemetryCharts();
|
await loadTelemetryCharts();
|
||||||
|
|||||||
Reference in New Issue
Block a user