Name |
Type |
Description |
viewer |
Viewer
|
视图对象 |
Example:
var drawElement = new Cesium.DrawElement();
// 修改绘制类型,支持,贴地,贴模型等参数设置
Methods
销毁对象
修改自定义绘图时Primitive是否贴合地面或者贴合模型的属性
Name |
Type |
Default |
Description |
groundPrimitiveType |
String
|
'NONE'
|
optional
{NONE, TERRAIN, MODEL, BOTH},NONE不贴地也不贴模型,TERRAIN仅贴地,MODEL仅贴模型,BOTH都贴 |
Example:
drawElement.setGroundPrimitiveType('TERRAIN');
绘制圆
Name |
Type |
Description |
options |
Object
|
Name |
Type |
Description |
callback |
function
|
回调函数,用于返回绘制的圆的中心点和半径 |
|
Example:
var drawElement = new Cesium.DrawElement(viewer);
drawElement.startDrawingCircle({
color: new Cesium.Color(0.2, 0.4, 0.3, 1.0),
callback: function (result) {
var circle = new Cesium.DrawElement.CirclePrimitive({
center: result.center,
radius: result.radius,
height: result.height,
asynchronous: false,
material: Cesium.Material.fromType('Color', {
color: new Cesium.Color(1.0, 0.0, 0.0, 1.0)
})
});
scene.primitives.add(circle);
circle.setEditable();
primitivesList.push(circle);
}
});
绘制矩形区功能
Name |
Type |
Description |
options |
Object
|
Name |
Type |
Description |
callback |
function
|
回调函数,用于返回绘制的矩形的点 |
|
Example:
var drawElement = new Cesium.DrawElement(viewer);
drawElement.startDrawingExtent({
color: new Cesium.Color(0.3, 0.8, 0.7),
callback: function (result) {
var redRectangle = new Cesium.DrawElement.ExtentPrimitive({
extent: result.extent,
height: result.height,
material: Cesium.Material.fromType('Color', {
color: new Cesium.Color(1.0, 0.0, 0.0, 1.0)
})
});
scene.primitives.add(redRectangle);
redRectangle.setEditable();
primitivesList.push(redRectangle);
}
});
绘制圆
Name |
Type |
Description |
options |
Object
|
Name |
Type |
Description |
callback |
function
|
回调函数,用于返回绘制的圆的中心点和半径 |
|
Example:
var drawElement = new Cesium.DrawElement(viewer);
drawElement.startDrawingMarker({
addDefaultMark: true,
color: new Cesium.Color(0.5, 0.2, 0.8, 1.0),
callback: function (result) {}
});
drawElement.startDrawingMarker({
addDefaultMark: false,
color: new Cesium.Color(0.5, 0.2, 0.8, 1.0),
callback: function (result) {
var pointGeometry = viewer.entities.add({
position: result.position,
point: {
color: Cesium.Color.SKYBLUE,
pixelSize: 10,
outlineColor: Cesium.Color.YELLOW,
outlineWidth: 3,
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
});
}
});
绘制多边形区功能
Name |
Type |
Description |
options |
Object
|
Name |
Type |
Description |
callback |
function
|
回调函数,用于返回绘制多边形的点 |
|
Example:
var drawElement = new Cesium.DrawElement(viewer);
drawElement.startDrawingPolygon({
color: new Cesium.Color(0.5, 0.8, 0.3),
callback: function (result) {
//alert(position);
var polygon = new Cesium.DrawElement.PolygonPrimitive({
positions: result.positions,
//material: Cesium.Material.fromType('Checkerboard') //materialEnd
material: Cesium.Material.fromType('Color', {
color: new Cesium.Color(1.0, 0.0, 0.0, 1.0)
})
});
scene.primitives.add(polygon);
polygon.setEditable();
primitivesList.push(polygon);
}
});
绘制线功能
Name |
Type |
Description |
options |
Object
|
Name |
Type |
Description |
callback |
function
|
回调函数,用于返回绘制的线的点 |
|
Example:
var drawElement = new Cesium.DrawElement(viewer);
drawElement.startDrawingPolyline({
color: new Cesium.Color(0.3, 0.7, 0.8, 1.0),
callback: function (result) {
var polyline = new Cesium.DrawElement.PolylinePrimitive({
positions: result.positions,
width: 1,
geodesic: true
});
scene.primitives.add(polyline);
polyline.setEditable();
primitivesList.push(polyline);
}
});
停止绘制
Example:
var drawElement = new Cesium.DrawElement(viewer);
drawElement.stopDrawing();