| | |
| | | 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), |
| | | }) |
| | | } |