QQ exchange group: 607330463 The strongest exchange group of GIS development technology. Reprinting is prohibited without permission. You can refer to
1. As shown
2. Code reference
<template>
<div id="cesiumContainer"></div>
</template>
<script>
import "cesium/Build/Cesium/Widgets/widgets.css";
import * as Cesium from "cesium";
export default {
name: "Map",
mounted() {
this.init();
},
methods: {
init() {
var viewer = new Cesium.Viewer("cesiumContainer");
//方法一,构造时赋材质,并用新建一个entity实现指向viewer.entities
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(-103.0, 40.0),
ellipse: {
semiMinorAxis: 250000.0,//短半轴
semiMajorAxis: 400000.0,//长半轴
material: Cesium.Color.RED.withAlpha(0.5), //可设置不同的MaterialProperty
},
});
//方法二,构造后再赋材质颜色
var ellipse = entity.ellipse;
ellipse.material = Cesium.Color.BLUE;
},
},
};
</script>
<style lang="scss" scoped>
#cesiumContainer {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>