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,高度
    }
  });
};

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值