From 8c9619f54ea7ef5d64e377a3f0bad5859d6237c9 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 17 Apr 2025 15:46:43 +0800
Subject: [PATCH] feat:事件详情标注图标更新
---
src/utils/cesium/mapUtil.js | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/utils/cesium/mapUtil.js b/src/utils/cesium/mapUtil.js
index 176ecca..73b9fbf 100644
--- a/src/utils/cesium/mapUtil.js
+++ b/src/utils/cesium/mapUtil.js
@@ -347,3 +347,22 @@
return true
}
}
+
+/**
+ * 飞到中心点并且所有点在可视范围
+ * @param lngLatArr
+ * @param viewer
+ * @param rangeMultiple 范围倍数越大飞的越高默认2
+ */
+export function flyVisual(lngLatArr,viewer,rangeMultiple = 2) {
+ if (!Array.isArray(lngLatArr) || lngLatArr.length === 0) return
+ const positions = lngLatArr.map(([lon, lat]) =>
+ Cesium.Cartesian3.fromDegrees(Number(lon), Number(lat))
+ )
+ // 计算包围盒 BoundingSphere(所有点的外接球)
+ const boundingSphere = Cesium.BoundingSphere.fromPoints(positions)
+ viewer.camera.flyToBoundingSphere(boundingSphere, {
+ duration: 0,
+ offset: new Cesium.HeadingPitchRange(0, 0, boundingSphere.radius * rangeMultiple),
+ })
+}
--
Gitblit v1.9.3