废话不多说
直接代码
<template>
<div id="cesiumContainer" style="height: 100vh;"></div>
<div id="toolbar" style="position: fixed;top:20px;left:220px;">
<el-breadcrumb>
<el-breadcrumb-item>地形示例</el-breadcrumb-item>
<el-breadcrumb-item>arcgis地形</el-breadcrumb-item>
</el-breadcrumb>
</div>
</template>
<script setup>
import {onMounted} from "vue";
import * as Cesium from "cesium";
import InitCesium from "../js/InitCesium.js";
onMounted(async () => {
let initCesium = new InitCesium('cesiumContainer')
let viewer = initCesium.initViewer({
infoBox: false
});
viewer.scene.terrainProvider = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl('https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer')
})
</script>
<style scoped>
#cesiumContainer {
overflow: hidden;
}
</style>
<style>
.el-breadcrumb__inner {
color: #ffffff !important;
}
</style>
InitCesium.js
import * as Cesium from "cesium";
class InitCesium {
constructor(cesiumContainer, options) {
this.cesiumContainer = cesiumContainer;
}
initViewer(options) {
Cesium.Ion.defaultAccessToken = 'token';
return new Cesium.Viewer(this.cesiumContainer, options);
}
}
export default InitCesium