直接上代码
/**
* @Description: 极坐标 测量 角度
*/
class CesiumAngelUtil{
constructor() {
// super();
this.arrowEntities = [];
this.viewEntities = [];
this.positions = [];
}
/**
* 转换为经纬度
* @param viewer {Cesium.viewer}
* @param cartesian {Cesium.Cartesian3}
* @return [lng,lat]
*/
cartesianToLngLat (viewer,cartesian){
const latlng = viewer.scene.globe.ellipsoid.cartesianToCartographic(
cartesian
);
const lat = Cesium.Math.toDegrees(latlng.latitude);
const lng = Cesium.Math.toDegrees(latlng.longitude);
return [lng, lat];
}
//初始化绘制事件
initDraw(){
//数组记录数据
this.positions = [];
if(!this.handler) this.handler= new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
let arrowEntity = null;
//左键点击
this.handler.setInputAction((evt)=> {
//单机开始绘制
var cartesian;
c