# DrawElement

DrawElement 几何绘制类

#### new Cesium.DrawElement(viewer)
MapGIS/DrawElement.js 83

Name | Type | Description
--- | --- | ---
`viewer` | Viewer | 视图对象

##### Example:

    var drawElement = new Cesium.DrawElement();

### Methods

#### destroy()
MapGIS/DrawElement.js 2123

销毁对象

#### startDrawingCircle(options)
MapGIS/DrawElement.js 1321

绘制圆

Name | Type | Description
--- | --- | ---

`options`

Object

Name | Type | Description
--- | --- | ---
`callback` | function | 回调函数，用于返回绘制的圆的中心点和半径

##### Example:

    var drawElement = new Cesium.DrawElement(viewer);
    drawElement.startDrawingCircle({
                      callback: function (center, radius) {
                          // alert(center.toString() + ' ' + radius.toString());
                      }
                  });

#### startDrawingExtent(options)
MapGIS/DrawElement.js 1200

绘制矩形区功能

Name | Type | Description
--- | --- | ---

`options`

Object

Name | Type | Description
--- | --- | ---
`callback` | function | 回调函数，用于返回绘制的矩形的点

##### Example:

    var drawElement = new Cesium.DrawElement(viewer);
    drawElement.startDrawingExtent({
                      callback: function (positions) {
                          var redRectangle = viewer.entities.add({
                              name: 'Red translucent rectangle',
                              rectangle: {
                                  coordinates: positions,
                                  material: Cesium.Color.RED.withAlpha(0.5)
                              }
                          });
                      }
                  });

#### startDrawingPolygon(options)
MapGIS/DrawElement.js 984

绘制多边形区功能

Name | Type | Description
--- | --- | ---

`options`

Object

Name | Type | Description
--- | --- | ---
`callback` | function | 回调函数，用于返回绘制多边形的点

##### Example:

    var drawElement = new Cesium.DrawElement(viewer);
    drawElement.startDrawingPolygon({
                     callback: function (positions) {
                         var polygon = new Cesium.DrawElement.PolygonPrimitive({
                             positions: positions,
                             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)
MapGIS/DrawElement.js 1008

绘制线功能

Name | Type | Description
--- | --- | ---

`options`

Object

Name | Type | Description
--- | --- | ---
`callback` | function | 回调函数，用于返回绘制的线的点

##### Example:

    var drawElement = new Cesium.DrawElement(viewer);
    drawElement.startDrawingPolyline({
                      callback: function (positions) {
                          var polyline = new Cesium.DrawElement.PolylinePrimitive({
                              positions: positions,
                              width: 1,
                              geodesic: true
                        });
                          viewer.scene.primitives.add(polyline);
                          polyline.setEditable();
                      }
                  });

#### stopDrawing()
MapGIS/DrawElement.js 204

停止绘制

##### Example:

    var drawElement = new Cesium.DrawElement(viewer);
    drawElement.stopDrawing();