矩形
const addMatrix = () => {
if (state.isAddLayer == "isClose") {
console.log(state.isAddLayer);
state.isAddLayer = "isOpen"
proxy.wyoming = proxy.viewer.entities.add({ //添加一个实体,仅需要传递一个简单JSON对象,返回值是一个Entity对象
name: 'Wyoming',
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray([//一组地理坐标
-109.080842, 45.002073,
-105.91517, 45.002073,
-104.058488, 44.996596,
-104.053011, 43.002989,
-104.053011, 41.003906,
-105.728954, 40.998429,
-107.919731, 41.003906,
-109.04798, 40.998429,
-111.047063, 40.998429,
-111.047063, 42.000709,
-111.047063, 44.476286,
-111.05254, 45.002073]),
material: Cesium.Color.RED.withAlpha(0.5), //材质
outline: true, //是否显示轮廓
outlineColor: Cesium.Color.BLACK //轮廓的颜色
}
});
proxy.viewer.zoomTo(proxy.wyoming);//缩放、平移视图使实体可见
} else {
console.log(state.isAddLayer);
state.isAddLayer = "isClose";
proxy.viewer.entities.remove(proxy.wyoming);
}