fix: canvas用position:fixed+getBoundingClientRect精准定位map
根因: 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user