TS中声名:
private arr: Array<number> = new Array<number>();
//绘制漫游路径
public setRoaming_line(cartesian: any) {
let cartographic = Cartographic.fromCartesian(cartesian);
// 弧度转为角度(经纬度)
let lon = Math.toDegrees(cartographic.longitude);
let lat = Math.toDegrees(cartographic.latitude);
//模型高度let height = cartographic.height + 5;
this.arr.push(lon);
this.arr.push(lat);
console.log('数组:' + this.arr);
console.log('数组长度:' + this.arr.length);
this.drawPoint(Cartesian3.fromDegrees(lon, lat));
if (this.arr.length > 2) {
this.drawPolyline();
}
}
//绘制点
private drawPoint(position: Cartesian3) {
let viewer = this.viewerCesium;
return viewer.entities.add({
name: '点几何对象',
position: position,
point: {
color: Color.SKYBLUE,
pixelSize: 10,
outlineColor: Color.YELLOW,
outlineWidth: 3,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
heightReference: HeightReference.CLAMP_TO_GROUND
}
});
}
//绘制线路
private drawPolyline() {
let viewer = this.viewerCesium;
return viewer.entities.add({
name: '线几何对象',
polyline: {
positions: new CallbackProperty(() => {
return Cartesian3.fromDegreesArray(this.arr);
}, false),
width: 5.0,
material: new PolylineGlowMaterialProperty({
color: Color.GOLD
}),
depthFailMaterial: new PolylineGlowMaterialProperty({
color: Color.GOLD
}),
clampToGround: true
}
});
}

image.png
网友评论