From e2349f951d00f7f1f0ec81741b77e6e3de7eb2af Mon Sep 17 00:00:00 2001 From: TianXuan Developer Date: Sat, 25 Jul 2026 15:13:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20canvas=E7=94=A8position:fixed+getBoundin?= =?UTF-8?q?gClientRect=E7=B2=BE=E5=87=86=E5=AE=9A=E4=BD=8Dmap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: canvas inside #saMap时Leaflet内部div覆盖遮挡 修复: canvas→document.body, position:fixed, 每帧getBoundingClientRect()计算left/top对准map 验证: map(256,396) canvas(256,396) 完美重合, 动画: win 0→1, t 0.59→0.89→0.19 Co-Authored-By: Claude --- .../templates/simple_analysis/simple_analysis.html | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/simple_analysis/templates/simple_analysis/simple_analysis.html b/simple_analysis/templates/simple_analysis/simple_analysis.html index 1db8f58..2d0d3f1 100644 --- a/simple_analysis/templates/simple_analysis/simple_analysis.html +++ b/simple_analysis/templates/simple_analysis/simple_analysis.html @@ -2594,22 +2594,18 @@ function toggleTrafficPanel() { function _ensureFlowCanvas() { if (!SA.map) return null; - const mapEl = SA.map.getContainer(); let c = document.getElementById(_trafficCanvasId); if (!c) { c = document.createElement('canvas'); c.id = _trafficCanvasId; - c.style.cssText = 'position:absolute;pointer-events:none;z-index:99999;'; - // Insert as sibling AFTER map container to stay on top - mapEl.parentNode.insertBefore(c, mapEl.nextSibling); + c.style.cssText = 'position:fixed;pointer-events:none;z-index:99999;'; + document.body.appendChild(c); } const s = SA.map.getSize(); - const mr = mapEl.getBoundingClientRect(); - const pr = mapEl.parentNode.getBoundingClientRect(); + const mr = SA.map.getContainer().getBoundingClientRect(); c.width = s.x; c.height = s.y; c.style.width = s.x + 'px'; c.style.height = s.y + 'px'; - c.style.left = (mr.left - pr.left) + 'px'; - c.style.top = (mr.top - pr.top) + 'px'; + c.style.left = mr.left + 'px'; c.style.top = mr.top + 'px'; return c; }