| | |
| | | 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() |
| | |
| | | total: -1, |
| | | page_size: 10 |
| | | } |
| | | |
| | | const kmlEntity = ref<any>([]) |
| | | const waylinesData = reactive({ |
| | | data: [] as WaylineFile[] |
| | | }) |
| | |
| | | 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 |
| | |
| | | * @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( |
| | |
| | | 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++) { |
| | |
| | | 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: cartesianArr, |
| | | width: 10, |
| | |
| | | }) |
| | | |
| | | global.$viewer.flyTo(lineEntity, { |
| | | offset: new Cesium.HeadingPitchRange(0, -90, 1000) |
| | | offset: new Cesium.HeadingPitchRange(0, -90, 10000) |
| | | }) |
| | | }) |
| | | } |