<template>
|
<div id="deviceJobDetailsMap" />
|
</template>
|
<script setup>
|
import { Terrain, Viewer } from 'cesium'
|
import * as Cesium from 'cesium'
|
import AmapMercatorTilingScheme from '@/utils/cesium/AmapMercatorTilingScheme'
|
import { analyzeKmzFile, XMLToJSON } from '@/utils/cesium/kmz'
|
|
const props = defineProps(['detailsData'])
|
|
|
const imageryProvider_ammapSL = new Cesium.UrlTemplateImageryProvider({
|
url: 'https://webrd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}',
|
layer: 'tdtVecBasicLayer',
|
style: 'default',
|
format: 'image/png',
|
tileMatrixSetID: 'GoogleMapsCompatible',
|
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
|
maximumLevel: 18,
|
tilingScheme: new AmapMercatorTilingScheme(),
|
credit: 'amap_SL',
|
})
|
|
const init = () => {
|
const viewer = new Viewer('deviceJobDetailsMap', {
|
terrain: Terrain.fromWorldTerrain(),
|
infoBox: false, // 禁用沙箱,解决控制台报错
|
animation: false, // 左下角的动画仪表盘
|
baseLayerPicker: false, // 右上角的图层选择按钮
|
geocoder: false, // 搜索框
|
homeButton: false, // home按钮
|
sceneModePicker: false, // 模式切换按钮
|
timeline: false, // 底部的时间轴
|
navigationHelpButton: false, // 右上角的帮助按钮,
|
selectionIndicator: false, // 是否显示选择指示器
|
baseLayer: false,
|
fullscreenButton: false,
|
sceneMode: Cesium.SceneMode.COLUMBUS_VIEW,
|
})
|
viewer.imageryLayers.addImageryProvider(imageryProvider_ammapSL)
|
// viewer.scene.morphTo2D(0)
|
}
|
|
const drawLine = () => {
|
props.detailsData.way_lines.forEach(item => {
|
analyzeKmzFile(`${item.url}?_t=${new Date().getTime()}`).then(async res => {
|
const templateXML = await res.fileInfoObj['wpmz/template.kml']
|
const templateXMLJSON = XMLToJSON(templateXML)?.['Document']
|
console.log(templateXMLJSON,66969969)
|
})
|
})
|
}
|
|
watch(() => props.detailsData, (newValue, oldValue) => {
|
if(newValue){
|
drawLine()
|
}
|
})
|
|
onMounted(() => {
|
nextTick(() => {
|
init()
|
})
|
})
|
</script>
|
<style scoped lang="scss">
|
#deviceJobDetailsMap {
|
height: 100%;
|
|
:deep() {
|
.cesium-viewer {
|
height: 100%;
|
overflow: hidden;
|
|
.cesium-viewer-cesiumWidgetContainer {
|
width: 100%;
|
height: 100%;
|
|
.cesium-widget {
|
width: 100%;
|
height: 100%;
|
|
canvas {
|
width: 100%;
|
height: 100%;
|
}
|
}
|
}
|
}
|
|
.cesium-viewer-bottom {
|
display: none;
|
}
|
}
|
}
|
</style>
|