记一下
Cesium常用操作
viewer.scene.morphTo2D(1);//二维
viewer.scene.morphTo3D(1);//三维
viewer.scene.morphToColumbusView(1);//哥伦布视图
viewer._cesiumWidget._creditContainer.style.display = "none"; //隐藏版本信息
viewer.scene.debugShowFramesPerSecond = true; //显示帧率
viewer.scene.skyBox.show = true; //是否显示星空
//viewer.scene.backgroundColor = Cesium.Color.BLUE;//地球背景颜色
viewer.scene.sun.show = true; //是否显示太阳
viewer.scene.moon.show = true; //是否显示有月亮
viewer.scene.skyAtmosphere.show = true; //是否隐藏大气圈
viewer.scene.globe.show = true; //是否显示地球
亮蓝色描边
entity.polyline.material = new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.5,
color: Cesium.Color.AQUA.withAlpha(0.7),
})
蓝色专题图
item.polygon.material.color = new Cesium.Color.fromCssColorString("rgba(0, " + 155 * x + "," + 255 * x + ")")
专题图与图例
this.num = []
// (viewer.dataSources._dataSources[0].entities.values)
let entities = viewer.dataSources.getByName('Africa_Newshp.json')[0].entities.values
let colorArr = []
entities.forEach(item => {
item.polygon.extrudedHeight = 0;
if (item.properties.area) {
let x = (1 - item.properties.area._value / 6400000)
item.polygon.material.color = new Cesium.Color.fromCssColorString("rgba(255, " + 255 * x + "," + 255 * x + ")")
colorArr.push({ area: item.properties.area._value, color: "rgba(255, " + 255 * x + "," + 255 * x + ")" })
} else {
(item.properties)
item.polygon.material.color = Cesium.Color.WHITE
}
})
colorArr = colorArr.sort(this.sort('area'))
this.num.push(colorArr[0].area, colorArr[Math.floor(colorArr.length / 4)].area, colorArr[Math.floor(colorArr.length / 2)].area, colorArr[Math.floor(colorArr.length * 3 / 4)].area, colorArr[colorArr.length - 1].area)
this.num[0] = Math.round(this.num[0] / 10) * 10
this.num[1] = Math.round(this.num[1] / 100) * 100
this.num[2] = Math.round(this.num[2] / 1000) * 1000
this.num[3] = Math.round(this.num[3] / 1000) * 1000
this.num[4] = Math.round(this.num[4] / 10000) * 10000
document.getElementsByClassName('pop')[0].style.backgroundImage = "linear-gradient(" + colorArr[0].color + "," + colorArr[colorArr.length - 1].color + ")"