From ad57696cef86a678512e93207bc5538d30bc40ee Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 03 Aug 2026 10:39:46 +0800
Subject: [PATCH] feat: 播放按钮居中
---
applications/drone-command/src/utils/cesium/mapUtil.js | 73 ------------------------------------
1 files changed, 0 insertions(+), 73 deletions(-)
diff --git a/applications/drone-command/src/utils/cesium/mapUtil.js b/applications/drone-command/src/utils/cesium/mapUtil.js
index 89bf787..3a3f398 100644
--- a/applications/drone-command/src/utils/cesium/mapUtil.js
+++ b/applications/drone-command/src/utils/cesium/mapUtil.js
@@ -2,7 +2,6 @@
import * as turf from '@turf/turf'
import store from '@/store'
-const { VITE_APP_BASE, VITE_APP_ENV, VITE_APP_REGION_URL } = import.meta.env
export const getLngLatDistance = (lat1, lng1, lat2, lng2) => {
const radLat1 = (lat1 * Math.PI) / 180.0
const radLat2 = (lat2 * Math.PI) / 180.0
@@ -449,67 +448,6 @@
}
}
-/**
- * 飞到中心点并且所有点在可视范围
- * @param positionsData 二维数组,每项为 [lon, lat] 或 三维数组 [lon, lat, height]
- * @param viewer Cesium.Viewer 实例
- * @param multiple 缩放倍数-默认为4
- * @param pitch 俯仰角-默认为-90
- */
-export function flyVisual({ positionsData, viewer, multiple = 4, pitch = -90 }) {
- if (!Array.isArray(positionsData) || positionsData.length === 0) return
-
- // 如果是一个点,加两个点方便后续生成外包围盒
- if (positionsData.length === 1) {
- const [lon, lat, height = 0] = positionsData[0]
- positionsData = [
- [lon + 0.001, lat + 0.001, height],
- [lon - 0.001, lat - 0.001, height],
- [lon, lat, height],
- ]
- }
- const positions = positionsData.map(([lon, lat, height = 0]) =>
- Cesium.Cartesian3.fromDegrees(Number(lon), Number(lat), Number(height || 0))
- )
-
- // 计算最高高度和中心点经纬度
- let maxHeight = -Infinity
- let sumLon = 0,
- sumLat = 0
- for (const [lon, lat, height] of positionsData) {
- sumLon += Number(lon)
- sumLat += Number(lat)
- maxHeight = Math.max(maxHeight, Number(height || 0))
- }
- const centerLon = sumLon / positionsData.length
- const centerLat = sumLat / positionsData.length
- const boundingSphere = Cesium.BoundingSphere.fromPoints(positions)
- // 暂时飞向 BoundingSphere
- viewer.camera.flyToBoundingSphere(Cesium.BoundingSphere.fromPoints(positions), {
- duration: 0,
- offset: {
- heading: Cesium.Math.toRadians(0),
- pitch: Cesium.Math.toRadians(pitch),
- range: boundingSphere.radius * multiple,
- },
- complete: () => {
- // 飞行完成后检查相机高度是否小于最高点
- const cameraHeight = Cesium.Cartographic.fromCartesian(viewer.camera.position).height
- if (cameraHeight < maxHeight) {
- viewer.camera.flyTo({
- destination: Cesium.Cartesian3.fromDegrees(centerLon, centerLat, maxHeight + 100), // 加100米缓冲
- duration: 1.5,
- orientation: {
- heading: viewer.camera.heading,
- pitch: viewer.camera.pitch,
- roll: viewer.camera.roll,
- },
- })
- }
- },
- })
-}
-
// 获取视口地图中心点
export function getMapCenterPoint(viewer) {
const centerResult = viewer.camera.pickEllipsoid(
@@ -568,17 +506,6 @@
return [provinceCode, cityCode]
}
return [provinceCode, cityCode, codeStr]
-}
-
-// 根据区域code获取轮廓
-export const getContourByCode = async areaCode => {
- const defaultDir = `${VITE_APP_REGION_URL}/100000/`
- const hierarchy = areaCodeToArr(areaCode.slice(0, 6))
- const jsonPathPre = hierarchy.slice(0, hierarchy.length - 1).join('/')
- const res = await fetch(`${defaultDir}${jsonPathPre}/index.json`)
- const parentGJson = await res.json()
- let features = parentGJson.features.find(item => item.properties.adcode === Number(hierarchy[hierarchy.length - 1]))
- return { type: 'FeatureCollection', features: [features] }
}
// 辅助函数:创建旋转文字的画布
--
Gitblit v1.9.3