From f0243ff33282c4183d66678cbb9e8e3a89e76d45 Mon Sep 17 00:00:00 2001 From: you Date: Sun, 22 Mar 2026 23:01:18 +0000 Subject: [PATCH] Fix: delay popup open after setView, add debug logging Leaflet needs map to settle after setView before popup can open. Added 500ms delay + console.warn if target marker not found. --- public/index.html | 2 +- public/map.js | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index 58f49a04..8a42c131 100644 --- a/public/index.html +++ b/public/index.html @@ -86,7 +86,7 @@ - + diff --git a/public/map.js b/public/map.js index f6729e01..1d1d7661 100644 --- a/public/map.js +++ b/public/map.js @@ -384,11 +384,18 @@ const targetNode = nodes.find(n => n.public_key === targetNodeKey); if (targetNode && targetNode.lat && targetNode.lon) { map.setView([targetNode.lat, targetNode.lon], 14); - markerLayer.eachLayer(m => { - if (m._nodeKey === targetNodeKey && m.openPopup) { - m.openPopup(); - } - }); + // Delay popup open slightly — Leaflet needs the map to settle after setView + setTimeout(() => { + let found = false; + markerLayer.eachLayer(m => { + if (found) return; + if (m._nodeKey === targetNodeKey && m.openPopup) { + m.openPopup(); + found = true; + } + }); + if (!found) console.warn('[map] Target node marker not found:', targetNodeKey); + }, 500); } }