feat:引入Echarts库,增加剖面分析折线图(静态)

devzpx
zhaipx 10 months ago
parent 32f4457012
commit 7e9096eab9

@ -0,0 +1,145 @@
<!--
文件描述地形剖面图组件
创建时间2024/4/23 9:55
创建人Zhaipeixiu
-->
<script setup lang="ts">
import {onMounted, ref} from 'vue'
import * as echarts from 'echarts'
const emit = defineEmits(['confirmDia'])
let showDia = ref<boolean>(false)
const openDia = (): void => {
showDia.value = true
}
const closeDia = (): void => {
showDia.value = false
}
const confirmDia = (): void => {
emit('confirmDia', '弹窗内容事件处理完毕,信息传给父组件。')
}
/**
* 绘制折线图
* @param xData x数组
* @param yData y数组以面积线绘制
* @param yData2 y数组以折线绘制
*/
const drawChart = (xData:number[],yData:number[],yData2:number[]) => {
let myChart = echarts.init(document.getElementById('profileChart'))
//
myChart.setOption({
legend:{
show: true,
type: 'plain',
top: '7%',
data:[
{
name: 'groundLine',
itemStyle: 'inherit',
lineStyle: 'inherit',
},
{
name: 'airLine',
itemStyle: 'inherit',
lineStyle: 'inherit',
}]
},
tooltip: {
show: true,
trigger: 'axis',
axisPointer: {
type: 'cross'
},
formatter:'地表高度: {c0}<br>航线高度: {c1}'
},
xAxis: {
data: xData,
name: '距离',
nameTextStyle: {
fontWeight:'bolder',
fontSize: 14
},
nameLocation: 'end',
axisLine:{
onZero: false,
show: true, // 线
symbol: ['none', 'arrow'],
symbolSize: [7, 10]
},
axisLabel: {
formatter: '{value} m',
margin: 5,
},
axisTick: {
show: true, //
inside: true, //
alignWithLabel: true,
lineStyle: {
color: '#000000', //线
type: 'solid', //线线solid线dashed线dotted
},
}
},
yAxis: {
type: 'value',
name: '高度',
nameTextStyle: {
fontWeight:'bolder',
fontSize: 14
},
nameLocation: 'end',
position: 'left',
axisLabel: {
formatter: '{value} m'
},
axisLine: {
show: true,
symbol: ['none', 'arrow'],
symbolSize: [7, 10]
}
},
series: [
{
name:'groundLine',
type: 'line',
data: yData,
areaStyle: {
color: '#37a5fb',
opacity: 0.5
}
},
{
name:'airLine',
type: 'line',
data: yData2,
}
]
});
}
// vue3使 <script setup>
// 访使 <script setup> 西 defineExpose
defineExpose({
openDia,
closeDia,
drawChart,
})
</script>
<template>
<div id="profileChart" v-show="showDia">
</div>
</template>
<style scoped>
#profileChart{
width: 700px;
height: 500px;
position: relative;
}
</style>

@ -7,11 +7,12 @@
--> -->
<template> <template>
<div id="cesium-viewer" ref="viewerDivRef"></div> <div id="cesium-viewer" ref="viewerDivRef"></div>
<ProfileAnalysis ref="profileChart"></ProfileAnalysis>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, ref } from 'vue' import {onMounted, ref, watch} from 'vue'
import { Viewer, Ion, Cartesian3, CustomDataSource, Color } from 'cesium' import {Viewer, Ion, CustomDataSource, Cartesian3} from 'cesium'
import 'cesium/Build/Cesium/Widgets/widgets.css' import 'cesium/Build/Cesium/Widgets/widgets.css'
import { import {
TDTLayerType, TDTLayerType,
@ -22,9 +23,8 @@ import {
import { initViewer, perfViewer, showNavigator } from '@/utils/map/sceneViewer' import { initViewer, perfViewer, showNavigator } from '@/utils/map/sceneViewer'
import { flyToChina } from '@/utils/map/camera' import { flyToChina } from '@/utils/map/camera'
import CreatePolyline from '@/utils/map/draw/drawPolyline' import CreatePolyline from '@/utils/map/draw/drawPolyline'
import { inputGeoJson } from '@/utils/DataIO.ts' import ProfileAnalysis from "@/components/ProfileAnalysis.vue";
// import DrawPoint from '@/utils/map/draw/drawPoint'
import { DrawPolygon } from '@/utils/map/draw/drawPolygon'
const viewerDivRef = ref<HTMLDivElement>() const viewerDivRef = ref<HTMLDivElement>()
let viewer: Viewer let viewer: Viewer
window.CESIUM_BASE_URL = 'node_modules/cesium/Build/Cesium/' window.CESIUM_BASE_URL = 'node_modules/cesium/Build/Cesium/'
@ -32,14 +32,10 @@ window.CESIUM_BASE_URL = 'node_modules/cesium/Build/Cesium/'
Ion.defaultAccessToken = Ion.defaultAccessToken =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3YjU4MjJlMS0wMWE4LTRhOWQtYjQ1OC04MTgzMzFhMzQ5ZjAiLCJpZCI6MTE1ODUxLCJpYXQiOjE2NjkyMDM1MzN9.8ajEuv3VKYg8wvFiQlUWWY6Ng6JfY4PuVgRyStL1B-E' 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3YjU4MjJlMS0wMWE4LTRhOWQtYjQ1OC04MTgzMzFhMzQ5ZjAiLCJpZCI6MTE1ODUxLCJpYXQiOjE2NjkyMDM1MzN9.8ajEuv3VKYg8wvFiQlUWWY6Ng6JfY4PuVgRyStL1B-E'
//
// window.Cesium.Camera.DEFAULT_VIEW_RECTANGLE = //
// window.Cesium.Rectangle.fromDegrees( let profileChart = ref<InstanceType<typeof ProfileAnalysis> | null>(null)
// 75.0, // 西 let linePoints = ref<number>(-1)
// 0.0, //
// 140.0, //
// 60.0, //
// )
onMounted(() => { onMounted(() => {
// //
@ -67,13 +63,22 @@ onMounted(() => {
// window // window
window.viewer = viewer window.viewer = viewer
inputGeoJson(viewer)
// //
const drawPolyline = new CreatePolyline(viewer,true,true,{}) const drawPolyline = new CreatePolyline(viewer,false,true,{})
linePoints.value = drawPolyline.positions.length
drawPolyline.start() drawPolyline.start()
// const drawPolygon = new DrawPolygon(viewer,true) profileChart.value?.openDia()
// drawPolygon.start() profileChart.value?.drawChart([0,1,2,3,4,5,6,7,8,9],
[-70,800,300,400,23,232,435,243,234,343],
[90,900,900,600,235,262,535,643,734,443])
}) })
watch(linePoints, (newValue, OldValue): void => {
console.log("数据变化了",linePoints.value, newValue, OldValue)
})
</script> </script>
<style scoped> <style scoped>

@ -102,9 +102,7 @@ export default class CreatePolyline {
} }
//左单击回调事件 //左单击回调事件
private leftClickCallBack = ( private leftClickCallBack = (event: ScreenSpaceEventHandler.PositionedEvent) => {
event: ScreenSpaceEventHandler.PositionedEvent,
) => {
//根据屏幕坐标判断是否为同一点 //根据屏幕坐标判断是否为同一点
if (this.isSamplePosition(event.position.clone())) return if (this.isSamplePosition(event.position.clone())) return
@ -195,9 +193,6 @@ export default class CreatePolyline {
console.log(profile) console.log(profile)
} }
this.clearEvent() this.clearEvent()
console.log('end:' + this.positions.length.toString())
console.log(this.positions)
console.log(this.polyline.controlPointsID.length)
//结束绘制进入编辑模式 //结束绘制进入编辑模式
this.polyline.removeControlPoints() this.polyline.removeControlPoints()
const editTool = new EditGeometry(this.viewer, this.polyline.geometry!) const editTool = new EditGeometry(this.viewer, this.polyline.geometry!)

Loading…
Cancel
Save