遇到一个需求,需要在三维地图上动态添加一个柱状图。
function echartsPlay() {
dlEllipse = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(116.388481, 39.924949, 0),
name: '电力',
ellipse: {
semiMinorAxis: 1.0,
semiMajorAxis: 1.0,
extrudedHeight: 1.0,
rotation: Cesium.Math.toRadians(45),
material: Cesium.Color.RED.withAlpha(1),
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
extrudedHeightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
}
})
time1 = setInterval(addHeight, 1000)
}
function addHeight() {
if (dlEllipse.ellipse.extrudedHeight < 15) {
dlEllipse.ellipse.extrudedHeight += 1.5
}
}
这样只就可以添加一个动态增高的柱状图了,但是在动态添加时会一闪一闪的,我们只需要在第一个方法里加上:
viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(116.388481, 39.924949, 0),
name: '电力',
ellipse: {
semiMinorAxis: 1.0,
semiMajorAxis: 1.0,
extrudedHeight: 1.0,
rotation: Cesium.Math.toRadians(45),
material: Cesium.Color.RED.withAlpha(1),
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
extrudedHeightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
},
show: false
})
这样就解决了一闪一闪的问题,同样,淹没分析也可以用这种方法实现。