上次画的是椭圆,业务要求正圆
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,高度
}
});
};