本文主要是介绍cesium 绘制圆饼图升级版,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
上次画的是椭圆,业务要求正圆
let list = [0,45,90,135,180,225,270,315];let colorList = ['#2D8CF0','#2F6CF0','#333666','#1F8CD0','#5e6C00','#112255','#999000','#452341','#999000'];let radiusList = [1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000];list.map((x,k)=>{drawCircle(x,x+45,colorList[k],radiusList[k],[120.61794,31.867144])})const drawCircle= (startAngle,endAngle,_color,_radius,_center) => {let radius = _radius;let color = new Cesium.Color.fromCssColorString(_color).withAlpha(0.5);let centerLon = _center[0];let centerLat = _center[1];let positions= [];for (let i = Number(startAngle); i < Number(endAngle); i += 0.01) {let clon = _radius * Math.sin((i * Math.PI) / 180);let clat = _radius * Math.cos((i * Math.PI) / 180);let ec = 6356725 + (10 * (90 - centerLat)) / 90;let ed = ec * Math.cos((centerLat * Math.PI) / 180);let slon = ((clon / ed + (centerLon * Math.PI) / 180) * 180) / Math.PI;let slat = ((clat / ec + (centerLat * Math.PI) / 180) * 180) / Math.PI;positions.push(slon, slat);}positions.push(centerLon, centerLat);viewer.entities.add({polygon: {show: true,hierarchy: Cesium.Cartesian3.fromDegreesArray(positions),material: color,outline: true,outlineWidth: 1,outlineColor: color,//extrudedHeight:500,高度}});
};
这篇关于cesium 绘制圆饼图升级版的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!