93 lines
3.2 KiB
Vue
Raw Normal View History

2025-03-24 17:32:57 +08:00
<template>
<div class="plant-gs-warp">
2025-03-27 16:04:07 +08:00
<div ref="viewwarp" class="plant-gs-content" :style="{ 'background-image': 'url(' + getAssetsFile('images/plant/bg1.png') + ')' }">
<vc-config-provider :cesium-path="vcConfig.cesiumPath" :access-token="vcConfig.accessToken">
<vc-viewer ref="viewerRef" @ready="onViewerReady">
<vc-layer-imagery :minimum-level="12" :maximum-level="18" :contrast="1.8" :saturation="1" :alpha="1">
<vc-imagery-provider-amap :key="'c843a50db7157faf295c6fa37c48719f'"></vc-imagery-provider-amap>
</vc-layer-imagery>
2025-03-27 17:18:12 +08:00
<vc-entity>
<!-- <vc-graphics-polygon
ref="polygon5"
:hierarchy="[99.402267, 23.538889, 99.402267, 23.538889, 5000.0, 99.402267, 23.538889, 0.0]"
:material="[0, 255, 255, 125]"
:per-position-height="true"
2025-03-27 16:04:07 +08:00
:outline="true"
outline-color="black"
2025-03-27 17:18:12 +08:00
></vc-graphics-polygon> -->
</vc-entity>
2025-03-27 16:04:07 +08:00
</vc-viewer>
</vc-config-provider>
</div>
2025-03-24 17:32:57 +08:00
</div>
</template>
<script setup>
import { isEmpty, getAssetsFile } from '@/utils';
2025-03-27 16:04:07 +08:00
import { ref, reactive, onMounted, computed, nextTick, getCurrentInstance } from 'vue';
2025-03-27 17:18:12 +08:00
import { VcViewer, VcConfigProvider, VcImageryProviderAmap, VcLayerImagery, VcGraphicsPlane, VcEntity, VcGraphicsPolygon } from 'vue-cesium';
2025-03-27 16:04:07 +08:00
import 'vue-cesium/dist/index.css';
const vcConfig = reactive({
cesiumPath: 'https://cdn.bootcdn.net/ajax/libs/cesium/1.80.0/Cesium.js',
accessToken:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiNjJjZTUxYi1lOTQ3LTQ3YjctOGI3ZS02ZGUzY2E4YWFkNDkiLCJpZCI6Mjg4MjAxLCJpYXQiOjE3NDMwNTY0MzN9.rjHQiqf7Y8bccaqsapqveULVAUH6M1QkeFp-AKG-frA',
});
const viewerRef = ref(null);
const viewwarp = ref(null);
let plane2 = ref(null);
onMounted(() => {
console.info('onMounted', viewerRef);
Promise.all([plane2.value.creatingPromise]).then((instances) => {
console.info('instances');
// instances[0].viewer.zoomTo(instances[0].viewer.entities);
});
});
const onViewerReady = (readyObj) => {
console.info('readyObj', readyObj.Cesium); // Cesium namespace object
console.log(readyObj.viewer); // instanceof Cesium.Viewer
// 在这里处理 Viewer 的初始化逻辑
const { Cesium, viewer } = readyObj;
// 示例:设置地球背景颜色
viewer.scene.globe.baseColor = Cesium.Color.DARKBLUE;
viewer.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(99.406653, 23.534142, 4000),
orientation: {
heading: Cesium.Math.toRadians(0), // 方向角
pitch: Cesium.Math.toRadians(-90), // 俯仰角
roll: 0, // 滚动角
},
});
};
2025-03-24 17:32:57 +08:00
</script>
<style lang="scss" scoped>
.plant-gs-warp {
height: 100%;
padding: 10px 0;
width: 100%;
box-sizing: border-box;
.plant-gs-content {
2025-03-25 17:32:34 +08:00
background-size: 100% 100%;
2025-03-24 17:32:57 +08:00
background-repeat: no-repeat;
width: 100%;
height: 100%;
2025-03-27 16:04:07 +08:00
overflow: hidden;
::v-deep() {
.vc-viewer {
height: calc(100% - 30px) !important;
width: calc(100% - 20px) !important;
margin: 20px 10px 10px 10px !important;
}
canvas {
border-radius: 10px !important;
}
.cesium-viewer-bottom {
display: none !important;
}
}
2025-03-24 17:32:57 +08:00
}
}
</style>