From 54849757852f6ab40eb17afbd03d1d839b60a38d Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 13 Nov 2023 17:09:15 +0800
Subject: [PATCH] 重复定时和连续执行
---
src/pages/page-web/projects/wayline.vue | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/pages/page-web/projects/wayline.vue b/src/pages/page-web/projects/wayline.vue
index b511be1..e532830 100644
--- a/src/pages/page-web/projects/wayline.vue
+++ b/src/pages/page-web/projects/wayline.vue
@@ -96,6 +96,7 @@
import { load } from '@amap/amap-jsapi-loader'
import { getRoot } from '/@/root'
import * as Cesium from 'cesium'
+import { cesiumOperation } from '/@/hooks/use-cesium-tsa'
const loading = ref(false)
const { appContext } = getCurrentInstance()
@@ -107,7 +108,7 @@
total: -1,
page_size: 10
}
-
+const kmlEntity = ref<any>([])
const waylinesData = reactive({
data: [] as WaylineFile[]
})
@@ -119,6 +120,7 @@
const canRefresh = ref(true)
const importVisible = ref<boolean>(root.$router.currentRoute.value.name === ERouterName.WAYLINE)
const height = ref()
+const { removeById, } = cesiumOperation()
onMounted(() => {
const parent = document.getElementsByClassName('scrollbar').item(0)?.parentNode as HTMLDivElement
@@ -135,6 +137,12 @@
getWaylines()
}, 1000)
console.log(workspaceId.value)
+})
+onUnmounted(() => {
+ if (kmlDataSource) {
+ global.$viewer.dataSources.remove(kmlDataSource)
+ }
+ removeById('kmzLine')
})
function getWaylines () {
@@ -166,7 +174,7 @@
function deleteWayline () {
deleteWaylineFile(workspaceId.value, deleteWaylineId.value).then(res => {
if (res.code === 0) {
- message.success('航线删除成功')
+ message.success('文件删除成功')
}
deleteWaylineId.value = ''
deleteTip.value = false
@@ -204,10 +212,14 @@
* @param file
*/
function initKmlFile (file:string) {
+ removeById('kmzLine')
const options = {
camera: global.$viewer.scene.camera,
canvas: global.$viewer.scene.canvas,
screenOverlayContainer: global.$viewer.container,
+ }
+ if (kmlDataSource) {
+ global.$viewer.dataSources.remove(kmlDataSource)
}
global.$viewer.dataSources.add(
Cesium.KmlDataSource.load(
@@ -215,10 +227,8 @@
options
)).then((res: any) => {
kmlDataSource = res
+ kmlEntity.value = kmlDataSource.entities.values
kmlDataSource.show = true
-
- console.log('Entits数组', kmlDataSource.entities.values)
-
const kmlEntityArr = kmlDataSource.entities.values[0]._children
const cartesianArr = []
for (let i = 0; i < kmlEntityArr.length; i++) {
@@ -229,14 +239,13 @@
outlineColor: Cesium.Color.WHITE,
})
entity.billboard = null
-
cartesianArr.push(entity.position._value)
}
- console.log(cartesianArr, 'cartesianArr')
const lineEntity = global.$viewer.entities.add({
name: 'entityLine',
+ id: 'kmzLine',
polyline: {
- positions: Cesium.Cartesian3.fromDegreesArray(cartesianArr),
+ positions: cartesianArr,
width: 10,
material: new Cesium.PolylineArrowMaterialProperty(Cesium.Color.CYAN),
clampToGround: false, // 关闭贴地效果,保留高度
@@ -244,7 +253,7 @@
})
global.$viewer.flyTo(lineEntity, {
- offset: new Cesium.HeadingPitchRange(0, -90, 1000)
+ offset: new Cesium.HeadingPitchRange(0, -90, 8000)
})
})
}
--
Gitblit v1.9.3