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() {
|
function _ensureFlowCanvas() {
|
||||||
if (!SA.map) return null;
|
if (!SA.map) return null;
|
||||||
const mapEl = SA.map.getContainer();
|
|
||||||
let c = document.getElementById(_trafficCanvasId);
|
let c = document.getElementById(_trafficCanvasId);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
c = document.createElement('canvas');
|
c = document.createElement('canvas');
|
||||||
c.id = _trafficCanvasId;
|
c.id = _trafficCanvasId;
|
||||||
c.style.cssText = 'position:absolute;pointer-events:none;z-index:99999;';
|
c.style.cssText = 'position:fixed;pointer-events:none;z-index:99999;';
|
||||||
// Insert as sibling AFTER map container to stay on top
|
document.body.appendChild(c);
|
||||||
mapEl.parentNode.insertBefore(c, mapEl.nextSibling);
|
|
||||||
}
|
}
|
||||||
const s = SA.map.getSize();
|
const s = SA.map.getSize();
|
||||||
const mr = mapEl.getBoundingClientRect();
|
const mr = SA.map.getContainer().getBoundingClientRect();
|
||||||
const pr = mapEl.parentNode.getBoundingClientRect();
|
|
||||||
c.width = s.x; c.height = s.y;
|
c.width = s.x; c.height = s.y;
|
||||||
c.style.width = s.x + 'px'; c.style.height = s.y + 'px';
|
c.style.width = s.x + 'px'; c.style.height = s.y + 'px';
|
||||||
c.style.left = (mr.left - pr.left) + 'px';
|
c.style.left = mr.left + 'px'; c.style.top = mr.top + 'px';
|
||||||
c.style.top = (mr.top - pr.top) + 'px';
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user