类名 DrawElement

# new DrawElement(viewer)

几何绘制类

参数:

名称 类型 描述
viewer Viewer

视图对象

示例
// ES5引入方式
const { DrawElement } = zondy.cesium
// ES6引入方式
import { DrawElement } from "@mapgis/webclient-cesium-plugin"

var drawElement = new DrawElement();
// 修改绘制类型,支持,贴地,贴模型等参数设置

方法

# destroy()

销毁对象

# setGroundPrimitiveType(groundPrimitiveTypeopt)

修改自定义绘图时Primitive是否贴合地面或者贴合模型的属性

参数:

名称 类型 默认值 描述
groundPrimitiveType String 'NONE'

{NONE, TERRAIN, MODEL, BOTH},NONE不贴地也不贴模型,TERRAIN仅贴地,MODEL仅贴模型,BOTH都贴

示例
drawElement.setGroundPrimitiveType('TERRAIN');

# startDrawingCircle(options)

绘制圆

参数:

名称 类型 描述
options Object
callback function

回调函数,用于返回绘制的圆的中心点和半径

示例
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);
    }
});

# startDrawingExtent(options)

绘制矩形区功能

参数:

名称 类型 描述
options Object
callback function

回调函数,用于返回绘制的矩形的点

示例
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);
    }
});

# startDrawingMarker(options)

绘制圆

参数:

名称 类型 描述
options Object
callback function

回调函数,用于返回绘制的圆的中心点和半径

示例
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
        }
    });
}
});

# startDrawingPolygon(options)

绘制多边形区功能

参数:

名称 类型 描述
options Object
callback function

回调函数,用于返回绘制多边形的点

示例
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);
    }
});

# startDrawingPolyline(options)

绘制线功能

参数:

名称 类型 描述
options Object
callback function

回调函数,用于返回绘制的线的点

示例
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);
    }
});

# stopDrawing()

停止绘制

示例
var drawElement = new Cesium.DrawElement(viewer);
drawElement.stopDrawing();
构造函数
成员变量
方法
事件