From a69ebc8e6b3ebdba1da0a2c44c66f1cc567e8e17 Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Mon, 1 Jun 2026 09:12:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E4=B8=8A=E7=94=BB=E8=BD=A8?= =?UTF-8?q?=E8=BF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Map.jsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/Map.jsx b/src/components/Map.jsx index 2d509a4..07a85b4 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -175,7 +175,20 @@ export default function CesiumMap({ realtimePosition, pathPoints = [], devices = viewer.entities.remove(trackLineRef.current); } - if (!points || points.length === 0) return; + // 2. 传入的 points 本身为空 → 清空轨迹退出 + if (!points || points.length === 0) { + const viewer = viewerRef.current; + if (viewer) { + try { + if (trackLineRef.current) { + viewer.entities.remove(trackLineRef.current); + trackLineRef.current = null; + } + } catch (e) { } + viewer.scene.requestRender(); // 强制刷新! + } + return; + } const validPoints = points.filter(p => { const lon = Number(p.lon);