new DrawElement(viewer)
engineExtensions/tools/DrawElement.js, line 315
几何绘制类
| Name | Type | Description |
|---|---|---|
viewer |
Viewer |
视图对象 |
Example
// ES5引入方式
const { DrawElement } = zondy.cesium
// ES6引入方式
import { DrawElement } from "@mapgis/webclient-cesium-plugin"
var drawElement = new DrawElement();
// 修改绘制类型,支持,贴地,贴模型等参数设置
Methods
-
destroy()
engineExtensions/tools/DrawElement.js, line 1869 -
销毁对象
-
setGroundPrimitiveType(groundPrimitiveType)
engineExtensions/tools/DrawElement.js, line 505 -
修改自定义绘图时Primitive是否贴合地面或者贴合模型的属性
Name Type Default Description groundPrimitiveTypeString 'NONE' 可选 {NONE, TERRAIN, MODEL, BOTH},NONE不贴地也不贴模型,TERRAIN仅贴地,MODEL仅贴模型,BOTH都贴
Example
drawElement.setGroundPrimitiveType('TERRAIN'); -
startDrawingCircle(options)
engineExtensions/tools/DrawElement.js, line 1069 -
绘制圆
Name Type Description optionsObject Name Type Description callbackfunction 回调函数,用于返回绘制的圆的中心点和半径
Example
var drawElement = new zondy.esium.DrawElement(viewer); drawElement.startDrawingCircle({ color: new Cesium.Color(0.2, 0.4, 0.3, 1.0), callback: function (result) { var circle = new zondy.esium.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)
engineExtensions/tools/DrawElement.js, line 908 -
绘制矩形区功能
Name Type Description optionsObject Name Type Description callbackfunction 回调函数,用于返回绘制的矩形的点
Example
var drawElement = new zondy.esium.DrawElement(viewer); drawElement.startDrawingExtent({ color: new Cesium.Color(0.3, 0.8, 0.7), callback: function (result) { var redRectangle = new zondy.esium.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)
engineExtensions/tools/DrawElement.js, line 574 -
绘制圆
Name Type Description optionsObject Name Type Description callbackfunction 回调函数,用于返回绘制的圆的中心点和半径
Example
var drawElement = new zondy.esium.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)
engineExtensions/tools/DrawElement.js, line 664 -
绘制多边形区功能
Name Type Description optionsObject Name Type Description callbackfunction 回调函数,用于返回绘制多边形的点
Example
var drawElement = new zondy.esium.DrawElement(viewer); drawElement.startDrawingPolygon({ color: new Cesium.Color(0.5, 0.8, 0.3), callback: function (result) { //alert(position); var polygon = new zondy.esium.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)
engineExtensions/tools/DrawElement.js, line 693 -
绘制线功能
Name Type Description optionsObject Name Type Description callbackfunction 回调函数,用于返回绘制的线的点
Example
var drawElement = new zondy.esium.DrawElement(viewer); drawElement.startDrawingPolyline({ color: new Cesium.Color(0.3, 0.7, 0.8, 1.0), callback: function (result) { var polyline = new zondy.esium.DrawElement.PolylinePrimitive({ positions: result.positions, width: 1, geodesic: true }); scene.primitives.add(polyline); polyline.setEditable(); primitivesList.push(polyline); } }); -
stopDrawing()
engineExtensions/tools/DrawElement.js, line 462 -
停止绘制
Example
var drawElement = new zondy.esium.DrawElement(viewer); drawElement.stopDrawing();