forked from drone/command-center-dashboard

shuishen
2025-04-16 a7e6761ba0cfccdf33ed552eb2d3b783c8e4ab4a
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),
   })
}