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>

展示:

相关推荐
云半S一34 分钟前
Agent 学习总结一
经验分享·笔记·学习·agent
跨知易知识产权40 分钟前
美国发明专利和外观专利的保护期限分别是多久,外观专利是否需要缴纳维持费?
笔记
八月的雨季 最後的冰吻1 小时前
C++ 面试要点笔记(续)
c++·笔记·面试
我命由我123452 小时前
准入类与水平类职业资格
笔记·学习·职场和发展·产品运营·求职招聘·职场发展·产品经理
He BianGu2 小时前
【笔记】在WPF中BitmapScalingMode的作用
笔记·wpf
小李不想当小白3 小时前
USART串口数据包(STM32标准库学习笔记)
经验分享·笔记·stm32·单片机·嵌入式硬件·学习
xier_ran3 小时前
【infra之路】AI 编译器学习笔记(八):向量化——把小块变成 SIMD 指令
人工智能·笔记·学习
梦073 小时前
openclaw升级踩坑笔记
笔记
凌晨1684 小时前
YOLO系列学习笔记:从YOLOv1到YOLOv3的演进之路
笔记·yolo·目标跟踪
启观川17 小时前
数据结构与算法-第 3 章 常用算法-贪心算法
数据结构·笔记·python·算法·贪心算法