问题:航飞数据裁剪成8个区域能分别控制显示影藏,甲方要求能知道各个区域的范围,查阅网上后找到两种,记录一下。
方法一:czml来创建。出处:原文链接
效果图:
代码:
var czml = [
{
"id": "document",
"name": "CZML Geometries: Polyline",
"version": "1.0"
},
{
"id": "blueCorridor",
"name": "Blue extruded corridor with beveled corners and outline",
"corridor": {
"positions": {
"cartographicDegrees": [
101.69701109436772, 29.500967938399, 360,
101.7530459644831, 29.85447402167785, 360,
101.7487572996887, 29.675398665302172, 360,
101.6994457009879, 29.67913849119346, 360,
101.69701109436772, 29.500967938399, 360,
]
},
// "height": 30,
"extrudedHeight": 540.0,
"width": 0.2,
"cornerType": "BEVELED",
"material": {
"solidColor": {
"color": {
"rgba": [0, 205, 0, 180]
}
}
},
"outline": true,
"outlineColor": {
"rgba": [255, 255, 255, 0]
}
}
}
];
var dataSourcePromise = Cesium.CzmlDataSource.load(czml);
viewer.dataSources.add(dataSourcePromise);
viewer.zoomTo(dataSourcePromise);
方案二:特点可以闪烁的效果.。出处:原文出处
效果:
用的照片:
代码:这里增加了 获取和移除实体
let_this = this;
var alp = 1;
var num = 0;
//绘制墙
let positions = Cesium.Cartesian3.fromDegreesArrayHeights([
10*******9436772, 2*.***938399, 600,
10******644831, 2*.**02167785, 800,
10******996887, 2*.**65302172, 900,
10*.*******879, 2*.**9119346, 500,
101*.***09436772, 2*.*7938399, 600
]);
let wall = viewer.entities.add({
id: "mywall",
wall: {
show: true,
positions: positions,
material: new Cesium.ImageMaterialProperty({
image: "../src/images/greenWall.png",
transparent: true,
color: new Cesium.CallbackProperty(function () {
if ((num % 2) === 0) {
alp -= 0.02;
} else {
alp += 0.02;
}
if (alp <= 0.3) {
num++;
} else if (alp >= 1) {
num++;
}
return Cesium.Color.BLUE.withAlpha(alp)
}, false)
})
}
});
viewer.zoomTo(wall).then(function () {
let getByIdBox = _this.viewer.entities.getById('d111');
// _this.viewer.entities.remove(getByIdBox)//可以移除这个实体
});
应用两个文章不能选转载。著名出处