From aec00ecc093be803860c8675cbe1c4c776a7cb4e Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Tue, 19 Mar 2024 17:49:21 +0800
Subject: [PATCH] update: 新建航线、事件编辑、kmz文件问题修改
---
src/pages/page-web/projects/components/route-edit/index.vue | 73 ++++++++++++++++++++++++------------
1 files changed, 49 insertions(+), 24 deletions(-)
diff --git a/src/pages/page-web/projects/components/route-edit/index.vue b/src/pages/page-web/projects/components/route-edit/index.vue
index ba5110c..b9955d6 100644
--- a/src/pages/page-web/projects/components/route-edit/index.vue
+++ b/src/pages/page-web/projects/components/route-edit/index.vue
@@ -57,34 +57,34 @@
<div class="right">{{ index + 1 }}</div>
</div>
</a-tooltip>
- <div class="graph-right">
- <div v-for="(event, index) in item.eventList" :key="index" class="s-event-icon">
- <a-tooltip placement="top">
- <template #title>
- {{ event.name }}
- </template>
- <img :src="event.icon" alt="icon" />
- </a-tooltip>
+ <contextMenu :menu="[{ title: '删除航点', value: { index, item } }]">
+ <div class="graph-right">
+ <div v-for="(event, index) in item.eventList" :key="index" class="s-event-icon">
+ <a-tooltip placement="top">
+ <template #title>
+ {{ event.name }}
+ </template>
+ <img :src="event.icon" alt="icon" />
+ </a-tooltip>
+ </div>
</div>
- </div>
+ </contextMenu>
</li>
</ul>
</div>
</template>
<script setup lang="ts">
-import _, { template } from 'lodash'
+import _ from 'lodash'
import * as Cesium from 'cesium'
import setting from './components/setting.vue'
import useKmzTsa, { kmlStr, template as xmlTemplate } from '/@/utils/cesium/use-kmz-tsa'
-import { ref, reactive, defineEmits, defineProps, watch, onMounted } from 'vue'
+import { ref, defineEmits, defineProps, watch, onMounted } from 'vue'
import { ArrowLeftOutlined, CaretDownOutlined, SaveOutlined } from '@ant-design/icons-vue'
import { cesiumOperation } from '/@/hooks/use-cesium-tsa'
import { useMyStore } from '/@/store'
-import ImageTrailMaterial from '/@/utils/cesium/ImageTrailMaterial'
import useMapDraw, { kmlEntities as globalEntities, selectPointIndex as pointIdx } from '/@/utils/cesium/use-map-draw'
-import { getKmlParams } from '/@/utils/cesium/kmz'
-import { getHaeHeight } from '/@/utils/cesium/mapUtils'
+import contextMenu from './components/content-menu.vue'
const store = useMyStore()
const { appContext }: any = getCurrentInstance()
const global = appContext.config.globalProperties
@@ -139,6 +139,7 @@
const loadCompleted = ref<boolean>(false)
+// 编辑时初始化
const initDrawRoute = () => {
const options = {
camera: global.$viewer.scene.camera,
@@ -165,6 +166,16 @@
})
waylineDetails.value = details
tragetPointArr.value = waylinePointsEvent.value
+ watch(
+ () => waylinePointsEvent.value,
+ (val) => {
+ tragetPointArr.value = val
+ },
+ {
+ deep: true,
+ },
+ )
+
kmlEntities.value = entities.value
if (!mouseRightClickEvent) {
// 添加右键事件
@@ -172,8 +183,12 @@
}
})
}
-
-// const createPointOrPolyline = () => {}
+// 新建航线初始化
+const initCreateRoute = () => {
+ mapDraw = useMapDraw('', [], '', global)
+ const xml = kmzUtils.generateXML(xmlTemplate.value)
+ mapDraw.drawWayline([], xml)
+}
// 创建广告牌
const createBillboard = (title: string | number, color: string) => {
@@ -244,9 +259,17 @@
kmlEntities.value.forEach((entity: Cesium.Entity | any, i: number) => {
if (i === index) {
entity.billboard.image = createBillboard(index + 1, '#f3be4f')
+ const dashLineEntity: Cesium.Entity | any = getEntityById(`dashLine${i}`)
+ dashLineEntity.polyline.material = new Cesium.PolylineDashMaterialProperty({
+ color: Cesium.Color.fromBytes(235, 192, 99),
+ })
entity.label.show = true
} else {
entity.billboard.image = createBillboard(i + 1, '#61d396')
+ const dashLineEntity: Cesium.Entity | any = getEntityById(`dashLine${i}`)
+ dashLineEntity.polyline.material = new Cesium.PolylineDashMaterialProperty({
+ color: Cesium.Color.WHITE,
+ })
entity.label.show = false
}
})
@@ -351,12 +374,11 @@
// 加入到解析的JSON对象中
const setting = {
Point: {
- coordinates: { '#text': `${longitude.toFixed(6)},${latitude.toFixed(6)}` },
+ coordinates: { '#text': `${longitude},${latitude}` },
},
index: { '#text': points.length },
- height: { '#text': height },
ellipsoidHeight: { '#text': height - posterHeight },
- isRisky: { '#text': 0 },
+ height: { '#text': height },
useGlobalHeadingParam: { '#text': 1 },
useGlobalHeight: { '#text': 1 },
useGlobalSpeed: { '#text': 1 },
@@ -374,9 +396,8 @@
waypointTurnDampingDist: { '#text': 0.2 },
waypointTurnMode: { '#text': 'toPointAndStopWithDiscontinuityCurvature' },
},
+ isRisky: { '#text': 0 },
}
- removeAllDataSource()
- removeAllPoint()
if (className === 'finally-point') {
globalEntities.value.push(entity)
xmlTemplate.value.Folder.Placemark.push(setting)
@@ -409,7 +430,6 @@
xmlTemplate.value.Folder.Placemark.forEach((placemark: { index: { [x: string]: number } }, index: number) => {
placemark.index['#text'] = index
})
-
const xmlStr = kmzUtils.generateXML(xmlTemplate.value)
mapDraw.drawWayline(globalEntities.value, xmlStr)
})
@@ -478,7 +498,12 @@
onMounted(() => {
// 清空画布
clearCesiumMap()
- initDrawRoute()
+ console.log(!!filePath.value)
+ if (filePath.value) {
+ initDrawRoute()
+ } else {
+ initCreateRoute()
+ }
})
onUnmounted(() => {
@@ -623,7 +648,7 @@
}
.graph-right {
- width: calc(100% - 40px);
+ width: 100%;
height: 30px;
border-bottom: 1px solid #4f4f4f;
display: flex;
--
Gitblit v1.9.3