Cesium绘制点
Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(90, -20, 110, 90);
var viewer = new Cesium.Viewer("csiumContain", {
homeButton: true,
animation: false,
timeline: false,
fullscreenButton: false,
baseLayerPicker: false,
sceneModePicker: true,
navigationHelpButton: false,
geocoder: false,
sceneModePicker: false,
});
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(120.9677706, 30.7985748,300),
point: {
color: Cesium.Color.RED,
pixelSize: 10
},
label: {
text: '测试点',
font: '14pt Source Han Sans CN',
fillColor: Cesium.Color.BLACK,
backgroundColor: Cesium.Color.AQUA,
showBackground: true,
style: Cesium.LabelStyle.FILL,
outlineWidth: 2,
verticalOrigin: Cesium.VerticalOrigin.CENTER,
horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
pixelOffset: new Cesium.Cartesian2(10, 0)
}
});
viewer.zoomTo(entity);
效果图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a2a4f0123eb594296c7a79e6be5ac1f1.png)
Cesium绘制线
Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(90, -20, 110, 90);
var viewer = new Cesium.Viewer("csiumContain", {
homeButton: true,
animation: false,
timeline: false,
fullscreenButton: false,
baseLayerPicker: false,
sceneModePicker: true,
navigationHelpButton: false,
geocoder: false,
sceneModePicker: false,
});
initShowLine();
function initShowLine(){
var objId = "line_one";
var positions =
[
{x: -2027365.029498278, y: 5643501.100524499, z: 2165534.2688970272},
{x: -2031395.0770982248, y: 5642066.230989595, z: 2165515.129923677}
];
initShowPolyline(objId, positions);
objId = "line_two";
positions =
[
{x: -2027365.029498278, y: 5643501.100524499, z: 2165534.2688970272},
{x: -2028892.7635749679, y: 5642759.580495446, z: 2166045.548750987},
{x: -2030175.7696807438, y: 5642306.50626273, z: 2166023.2324521956},
{x: -2031395.0770982248, y: 5642066.230989595, z: 2165515.129923677}
];
initShowPolyline(objId, positions);
objId = "line_three";
positions =
[
{x: -2027365.029498278, y: 5643501.100524499, z: 2165534.2688970272},
{x: -2027883.9406702125, y: 5643590.070223619, z: 2164821.443483807},
{x: -2030807.9534780958, y: 5642564.539566782, z: 2164780.8840529644},
{x: -2031395.0770982248, y: 5642066.230989595, z: 2165515.129923677}
];
initShowPolyline(objId, positions);
}
function initShowPolyline(objId, positions) {
var lineColor = '#00f';
if(objId == "1"){
lineColor = "#E90808";
}else if(objId == "2"){
lineColor = "#22E908";
}else if(objId == "3"){
lineColor = "#0815E9";
}
var material = new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.25,
color: Cesium.Color.fromCssColorString(lineColor).withAlpha(0.9)
});
var bData = {
layerId: "layerId",
objId: objId,
shapeType: "Polyline",
polyline: {
positions: positions,
clampToGround: true,
width: 8,
material: material
}
};
var entity = viewer.entities.add(bData);
viewer.zoomTo(entity);
}
效果图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/3e8462c55d863161b5af667fc1e30371.png)
Cesium绘制面
Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(90, -20, 110, 90);
var viewer = new Cesium.Viewer("csiumContain", {
homeButton: true,
animation: false,
timeline: false,
fullscreenButton: false,
baseLayerPicker: false,
sceneModePicker: true,
navigationHelpButton: false,
geocoder: false,
sceneModePicker: false,
});
var entity = viewer.entities.add({
polygon: {
hierarchy: {
positions: Cesium.Cartesian3.fromDegreesArray([
120.9677706, 30.7985748,
110.20, 34.55,
120.20, 50.55
]),
holes: [{
positions: Cesium.Cartesian3.fromDegreesArray([
119, 32,
115, 34,
119, 40
])
}]
},
outline: true,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 2,
material: Cesium.Color.GREEN.withAlpha(0.5),
fill: true,
height: 5000,
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
show: true,
zIndex: 10
}
});
viewer.zoomTo(entity);
效果图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/9c53845797eaa6c14e09ed949854cf6a.png)