vue+Cesium示例中缺少要素以至于运行不起来

示例:

网址:

https://cesium.com/learn/cesiumjs-learn/cesiumjs-creating-entities/

缺少:

正确的代码:

复制代码
<template>
  <div id="cesiumContainer" ref="cesiumContainer"></div>
</template>

<script setup>

import * as Cesium from 'cesium'
import '../Widgets/widgets.css' //这是src下面的widgets.css文件
import { onMounted } from 'vue'

Cesium.Ion.defaultAccessToken = "*****";
window.CESIUM_BASE_URL = '/'  //这是根目录下的四个文件夹

/* eslint-disable no-unused-vars */

onMounted(() => {

const viewer = new Cesium.Viewer("cesiumContainer");

viewer.entities.add({
  name: "Blue box",
  position: Cesium.Cartesian3.fromDegrees(-114.0, 40.0, 300000.0),
  box: {
    dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    material: Cesium.Color.BLUE,
  },
});

viewer.entities.add({
  name: "Red box with black outline",
  position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
  box: {
    dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    material: Cesium.Color.RED.withAlpha(0.5),
    outline: true,
    outlineColor: Cesium.Color.BLACK,
  },
});

 viewer.entities.add({
  name: "Yellow box outline",
  position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 300000.0),
  box: {
    dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    fill: false,
    outline: true,
    outlineColor: Cesium.Color.YELLOW,
  },
});

viewer.zoomTo(viewer.entities);

})


</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
* {
  margin: 0;
  padding: 0
}

#cesiumContainer {
  width: 100%;
  height: 100vh;
}
</style>

展示:

相关推荐
西岸行者1 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
starlaky1 天前
Django入门笔记
笔记·django
勇气要爆发1 天前
吴恩达《LangChain LLM 应用开发精读笔记》1-Introduction_介绍
笔记·langchain·吴恩达
悠哉悠哉愿意1 天前
【单片机学习笔记】串口、超声波、NE555的同时使用
笔记·单片机·学习
勇气要爆发1 天前
吴恩达《LangChain LLM 应用开发精读笔记》2-Models, Prompts and Parsers 模型、提示和解析器
android·笔记·langchain
qianshanxue111 天前
计算机操作的一些笔记标题
笔记
土拨鼠烧电路1 天前
笔记11:数据中台:不是数据仓库,是业务能力复用的引擎
数据仓库·笔记
土拨鼠烧电路1 天前
笔记14:集成与架构:连接孤岛,构建敏捷响应能力
笔记·架构
烟花落o1 天前
栈和队列的知识点及代码
开发语言·数据结构·笔记·栈和队列·编程学习