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>

展示:

相关推荐
IT古董1 天前
【MES学习笔记系列】MES 推荐书籍与资源
笔记·学习
一米阳光86611 天前
软考(中级)软件设计师核心笔记(9)算法——时间复杂度与空间复杂度、查找算法、排序算法
笔记·算法·职场发展·软考·软件设计师·中级职称
米饭不加菜1 天前
常用基本求导公式与法则(超详细推导版——上)
经验分享·笔记
青山是哪个青山1 天前
LangChain 学习笔记(四):Message 与提示词模板
笔记·学习·langchain
Shell运维手记1 天前
Linux 常用基础命令学习笔记
linux·运维·笔记·学习·算法·github
FakeOccupational2 天前
【电路笔记 STM32】Cortex-M7 内核上的数据缓存(D-Cache)结构+MPU+DMA&Cache+STM32CubeMX配置
笔记·stm32·缓存
动词ing2 天前
【学习笔记】C语言(数组指针与指针数组+字符数组+函数+参数传递+字符串作为形参+递归函数+指针函数+回调函数+结构体嵌套+内存动态分配函数)
c语言·笔记·学习
z落落2 天前
C# Modbus-ASCII 超详细完整笔记(协议原理+LRC算法+读写源码全拆解)
笔记
hanlin032 天前
刷题笔记:力扣第189题-轮转数组
笔记·算法·leetcode
xqqxqxxq2 天前
Redis 五大常用数据类型 + 通用命令笔记
数据库·redis·笔记