Class: Draw

Description

 dojo.require("esri.toolbars.draw");

Toolbar that supports functionality to create new geometries by drawing them: points (POINT or MULTI_POINT), lines (LINE, POLYLINE, or FREEHAND_POLYLINE), polygons (FREEHAND_POLYGON or POLYGON), or rectangles (EXTENT). To edit geometries of existing graphics, use the Edit Toolbar.

Mouse behavior when drawing features

Samples

Search for samples that use this class.  

Class hierarchy

esri.toolbars.Draw

Constructor

Constructor Description
esri.toolbars.Draw(map, options) Creates a new Draw object. A map is a required parameter.

Properties

Property Type Description
fillSymbol SimpleFillSymbol Symbol to be used when drawing a Polygon or Extent.
lineSymbol SimpleLineSymbol Symbol to be used when drawing a Polyline.
markerSymbol SimpleMarkerSymbol Symbol to be used when drawing a Point or Multipoint.
respectDrawingVertexOrder Boolean When set to false, the geometry is modified to be topologically correct. When set to true, the input geometry is not modified.

Constants

Constant Description
ARROW Draws an arrow.
CIRCLE Draws a circle.
ELLIPSE Draws an ellipse.
EXTENT Draws an extent box.
FREEHAND_POLYGON Draws a freehand polygon.
FREEHAND_POLYLINE Draws a freehand polyline.
LINE Draws a line.
MULTI_POINT Draws a Multipoint.
POINT Draws a point.
POLYGON Draws a polygon.
POLYLINE Draws a polyline.
RECTANGLE Draws a rectangle.
TRIANGLE Draws a triangle.

Methods

Method Return Value Description
activate(geometryType, options?) none Activates the toolbar for drawing geometries. Activating the toolbar disables map navigation.
deactivate() none Deactivates the toolbar and reactivates map navigation.
finishDrawing() none Finishes drawing the geometry and fires the onDrawEnd event. Use this method to finish drawing a polyline, polygon or multipoint when working with the copmact build on a touch supported device like the iPhone.
setFillSymbol(fillSymbol) none Sets the fill symbol.
setLineSymbol(lineSymbol) none Sets the line symbol.
setMarkerSymbol(markerSymbol) none Sets the marker symbol.
setRespectDrawingVertexOrder(set) none Sets whether the polygon geometry should be modified to be topologically correct.

Events

Event Description
onDrawEnd(geometry) Fires when drawing is complete.
Constructor Detail

esri.toolbars.Draw(map, options)

Creates a new Draw object. A map is a required parameter.
Parameters:
<Map> map Required Map the toolbar is associated with.
<Object> options Required Parameters that define the functionality of the draw toolbar. See the options for a list of valid values.
Options:
<Number> drawTime Determines how much time to wait before adding a new point when using a freehand tool. The default value is 75.
<Boolean> showTooltips If true, tooltips are displayed when creating new graphics with the draw toolbar. The default value is true.
  toolbar = new esri.toolbars.Draw(map, {
    showTooltips: false
  });
<Number> tolerance Determines how far the mouse moves before adding a new point when using one of the freehand tools. The default value is 8.
<Number> tooltipOffset Determines how farm to offset the tool tip from the mouse pointer. The default value is 15.
Code snippets:
  toolbar = new esri.toolbars.Draw(map, {
    tooltipOffset:20,
    drawTime:90
  });
Properties Detail

<SimpleFillSymbol> fillSymbol

Symbol to be used when drawing a Polygon or Extent.
See also:
setFillSymbol  

<SimpleLineSymbol> lineSymbol

Symbol to be used when drawing a Polyline.
See also:
setLineSymbol  

<SimpleMarkerSymbol> markerSymbol

Symbol to be used when drawing a Point or Multipoint.
See also:
setMarkerSymbol  

<Boolean> respectDrawingVertexOrder

When set to false, the geometry is modified to be topologically correct. When set to true, the input geometry is not modified.
Known values: true | false
Default value: false
Methods Detail

activate(geometryType, options?)

Activates the toolbar for drawing geometries. Activating the toolbar disables map navigation.
Return value: none
Input Parameters:
<String> geometryType Required The type of geometry drawn. See the Constants table for valid values.
<Object> options Optional Options that define the functionality of the draw toolbar.
<Number> drawTime Determines how much time to wait before adding a new point when using a freehand tool. The default value is 75.
<Boolean> showTooltips If true, tooltips are displayed when creating new graphics with the draw toolbar. The default value is true.
<Number> tolerance Determines how far the mouse moves before adding a new point when using one of the freehand tools. The default value is 8.
<Number> tooltipOffset Determines how farm to offset the tool tip from the mouse pointer. The default value is 15.
Code snippets:
toolbar.activate(esri.toolbars.Draw.POINT);

See also:
deactivate  

deactivate()

Deactivates the toolbar and reactivates map navigation.
Return value: none
See also:
activate  

finishDrawing()

Finishes drawing the geometry and fires the onDrawEnd event. Use this method to finish drawing a polyline, polygon or multipoint when working with the copmact build on a touch supported device like the iPhone. (As of v2.0)
Return value: none
Code snippets:
drawToolbar.finishDrawing();

See also:
onDrawEnd  

setFillSymbol(fillSymbol)

Sets the fill symbol.
Return value: none
Input Parameters:
<FillSymbol> fillSymbol Required The fill symbol.
See also:
fillSymbol  

setLineSymbol(lineSymbol)

Sets the line symbol.
Return value: none
Input Parameters:
<LineSymbol> lineSymbol Required The line symbol.
See also:
lineSymbol  

setMarkerSymbol(markerSymbol)

Sets the marker symbol.
Return value: none
Input Parameters:
<MarkerSymbol> markerSymbol Required The marker symbol.
See also:
markerSymbol  

setRespectDrawingVertexOrder(set)

Sets whether the polygon geometry should be modified to be topologically correct.
Return value: none
Input Parameters:
<Boolean> set Required When set to false, the geometry is modified to be topologically correct. When set to true, the input geometry is not modified.

Events Detail

onDrawEnd(geometry)

Fires when drawing is complete.
Arguments:
<Geometry> geometry Geometry drawn on the client.
Code snippets:
function createToolbar(map) {
  toolbar = new esri.toolbars.Draw(map);
  dojo.connect(toolbar, "onDrawEnd", addToMap);
}
function addToMap(geometry) {
  var graphic = new esri.Graphic(geometry, symbol);
  map.graphics.add(graphic);
}
See also:
finishDrawing