Packagecom.esri.ags.tools
Classpublic class DrawTool
InheritanceDrawTool Inheritance com.esri.ags.tools.BaseTool

Tool that supports functionality to create new geometries by drawing them: points (MAPPOINT or MULTIPOINT), lines (LINE, POLYLINE, or FREEHAND_POLYLINE), polygons (FREEHAND_POLYGON or POLYGON), rectangles (EXTENT) and circles (CIRCLE). To edit geometries of existing graphics, use the EditTool.

The property map has to be set for the activate method to complete.

Mouse behavior when drawing features

Snapping (as of version 2.3)

Note: as of version 1.2 all symbols are supported. At version 1.1 and earlier only Simple* symbols were supported.

Note: If you specify a graphicsLayer, the features will automatically be added to that graphicsLayer:

 <esri:DrawTool id="myDrawTool" map="{myMap}" graphicsLayer="{myGraphicsLayer}"
     markerSymbol="{sms}" lineSymbol="{sls}" fillSymbol="{sfs}" />
 
If you don't explicitly specify a graphicsLayer, you will need to add the graphic yourself (if you want it to show after you've drawn it):
 <esri:DrawTool id="myDrawTool" map="{myMap}"
     markerSymbol="{sms}" lineSymbol="{sls}" fillSymbol="{sfs}" />
 

See also

EditTool
Live sample - using DrawTool.
Live sample - using DrawTool and EditTool.


Public Properties
 PropertyDefined By
  defaultDrawSize : Number
The default draw size.
DrawTool
  fillSymbol : Symbol
The symbol for drawing polygons.
DrawTool
  graphicsLayer : GraphicsLayer
The graphics layer to draw the features in.
DrawTool
  lineSymbol : Symbol
The symbol for drawing lines.
DrawTool
  map : Map
[override] The Map that the DrawTool is associated with.
DrawTool
  markerSymbol : Symbol
The symbol for drawing points.
DrawTool
  minFreehandPointInterval : Number
The minimum point interval (in pixels) for freehand polyline and polygon.
DrawTool
  respectDrawingVertexOrder : Boolean
When set to false, the geometry is modified to be topologically correct.
DrawTool
  showDrawTips : Boolean
When set to true, the drawing tooltips would show.
DrawTool
  snapDistance : Number
The distance in pixels for snapping.
DrawTool
  snapMode : String
Specifies whether snapping is off, always on or enabled by pressing the Ctrl key.
DrawTool
  snapOption : String
Specifies whether snapping to edge, vertex or both.
DrawTool
  toolTipMultipointEnd : String
Tooltip shown when drawing multipoints.
DrawTool
  toolTipMultipointStart : String
Tooltip shown when starting to draw multipoints.
DrawTool
  toolTipPoint : String
Tooltip shown when drawing points.
DrawTool
  toolTipPolyContinue : String
Tooltip shown when drawing polygons after the first click and before the second click.
DrawTool
  toolTipPolyEnd : String
Tooltip shown when drawing polylines and polygons.
DrawTool
  toolTipPolyStart : String
Tooltip shown when starting to draw polylines and polygons.
DrawTool
  toolTipStartAndLetGo : String
Tooltip shown when drawing simple lines, freehand polylines, freehand polygons, extents, circles and ellipses.
DrawTool
Public Methods
 MethodDefined By
  
DrawTool(map:Map = null)
Creates a new DrawTool object.
DrawTool
  
activate(drawType:String, enableGraphicsLayerMouseEvents:Boolean = false):void
Activates the tool for drawing geometries.
DrawTool
  
deactivate():void
Deactivates the tool and reactivates map navigation.
DrawTool
Events
 Event Summary Defined By
  The drawEnd event is dispatched when the drawing is complete.DrawTool
  The drawStart event is dispatched when the drawing starts.DrawTool
  The drawUpdate event is dispatched while drawing.DrawTool
Public Constants
 ConstantDefined By
  CIRCLE : String = circle
[static] Draws a circle.
DrawTool
  ELLIPSE : String = ellipse
[static] Draws an ellipse.
DrawTool
  EXTENT : String = extent
[static] Draws an extent.
DrawTool
  FREEHAND_POLYGON : String = freehandpolygon
[static] Draws a freehand polygon.
DrawTool
  FREEHAND_POLYLINE : String = freehandpolyline
[static] Draws a freehand polyline.
DrawTool
  LINE : String = line
[static] Draws a line.
DrawTool
  MAPPOINT : String = mappoint
[static] Draws a point.
DrawTool
  MULTIPOINT : String = multipoint
[static] Draws a multipoint.
DrawTool
  POLYGON : String = polygon
[static] Draws a polygon.
DrawTool
  POLYLINE : String = polyline
[static] Draws a polyline.
DrawTool
  SNAP_MODE_ALWAYS_ON : String = alwaysOn
[static] Snapping is always on.
DrawTool
  SNAP_MODE_OFF : String = off
[static] Snapping is off.
DrawTool
  SNAP_MODE_ON_DEMAND : String = onDemand
[static] Enable snapping by pressing the Ctrl key.
DrawTool
  SNAP_OPTION_EDGE : String = edge
[static] Snap to edge only.
DrawTool
  SNAP_OPTION_EDGE_AND_VERTEX : String = edgeAndVertex
[static] Snap to edge and vertex.
DrawTool
  SNAP_OPTION_VERTEX : String = vertex
[static] Snap to vertex only.
DrawTool
Property Detail
defaultDrawSizeproperty
defaultDrawSize:Number

Since : ArcGIS API for Flex 2.3

The default draw size. Used for circle and ellipse.

The default value is 100.

This property can be used as the source for data binding.


Implementation
    public function get defaultDrawSize():Number
    public function set defaultDrawSize(value:Number):void
fillSymbolproperty 
fillSymbol:Symbol

The symbol for drawing polygons.

This property can be used as the source for data binding.


Implementation
    public function get fillSymbol():Symbol
    public function set fillSymbol(value:Symbol):void
graphicsLayerproperty 
graphicsLayer:GraphicsLayer

The graphics layer to draw the features in. If not specified, add the graphic result from drawEnd event to a graphics layer.


Implementation
    public function get graphicsLayer():GraphicsLayer
    public function set graphicsLayer(value:GraphicsLayer):void
lineSymbolproperty 
lineSymbol:Symbol

The symbol for drawing lines.

This property can be used as the source for data binding.


Implementation
    public function get lineSymbol():Symbol
    public function set lineSymbol(value:Symbol):void
mapproperty 
map:Map[override]

The Map that the DrawTool is associated with.


Implementation
    public function get map():Map
    public function set map(value:Map):void
markerSymbolproperty 
markerSymbol:Symbol

The symbol for drawing points.

This property can be used as the source for data binding.


Implementation
    public function get markerSymbol():Symbol
    public function set markerSymbol(value:Symbol):void
minFreehandPointIntervalproperty 
minFreehandPointInterval:Number

Since : ArcGIS API 3.0 for Flex

The minimum point interval (in pixels) for freehand polyline and polygon.

The default value is 10.

This property can be used as the source for data binding.


Implementation
    public function get minFreehandPointInterval():Number
    public function set minFreehandPointInterval(value:Number):void
respectDrawingVertexOrderproperty 
respectDrawingVertexOrder:Boolean

When set to false, the geometry is modified to be topologically correct. When set to true, the input geometry is not modified.

The default value is false.

This property can be used as the source for data binding.


Implementation
    public function get respectDrawingVertexOrder():Boolean
    public function set respectDrawingVertexOrder(value:Boolean):void
showDrawTipsproperty 
showDrawTips:Boolean

Since : ArcGIS API for Flex 2.0

When set to true, the drawing tooltips would show.

The default value is true.

This property can be used as the source for data binding.


Implementation
    public function get showDrawTips():Boolean
    public function set showDrawTips(value:Boolean):void

See also

snapDistanceproperty 
snapDistance:Number

Since : ArcGIS API for Flex 2.3

The distance in pixels for snapping. To disable snapping, set this value to 0.

The default value is 15.

This property can be used as the source for data binding.


Implementation
    public function get snapDistance():Number
    public function set snapDistance(value:Number):void
snapModeproperty 
snapMode:String

Since : ArcGIS API for Flex 2.5

Specifies whether snapping is off, always on or enabled by pressing the Ctrl key.

The default value is SNAP_MODE_ON_DEMAND.

This property can be used as the source for data binding.


Implementation
    public function get snapMode():String
    public function set snapMode(value:String):void
snapOptionproperty 
snapOption:String

Since : ArcGIS API 3.0 for Flex

Specifies whether snapping to edge, vertex or both.

The default value is SNAP_OPTION_EDGE_AND_VERTEX.

This property can be used as the source for data binding.


Implementation
    public function get snapOption():String
    public function set snapOption(value:String):void
toolTipMultipointEndproperty 
toolTipMultipointEnd:String

Since : ArcGIS API 3.6 for Flex

Tooltip shown when drawing multipoints. Defaults to the "drawTooltipMultipointFinish" string in the resource file for the current locale.

This property can be used as the source for data binding.


Implementation
    public function get toolTipMultipointEnd():String
    public function set toolTipMultipointEnd(value:String):void

See also

toolTipMultipointStartproperty 
toolTipMultipointStart:String

Since : ArcGIS API 3.6 for Flex

Tooltip shown when starting to draw multipoints. Defaults to the "drawTooltipMultipointStart" string in the resource file for the current locale.

This property can be used as the source for data binding.


Implementation
    public function get toolTipMultipointStart():String
    public function set toolTipMultipointStart(value:String):void

See also

toolTipPointproperty 
toolTipPoint:String

Since : ArcGIS API 3.6 for Flex

Tooltip shown when drawing points. Defaults to the "drawTooltipMappoint" string in the resource file for the current locale.

This property can be used as the source for data binding.


Implementation
    public function get toolTipPoint():String
    public function set toolTipPoint(value:String):void

See also

toolTipPolyContinueproperty 
toolTipPolyContinue:String

Since : ArcGIS API 3.6 for Flex

Tooltip shown when drawing polygons after the first click and before the second click. Defaults to the "drawTooltipPolygonContinueDrawing" string in the resource file for the current locale.

This property can be used as the source for data binding.


Implementation
    public function get toolTipPolyContinue():String
    public function set toolTipPolyContinue(value:String):void

See also

toolTipPolyEndproperty 
toolTipPolyEnd:String

Since : ArcGIS API 3.6 for Flex

Tooltip shown when drawing polylines and polygons. Defaults to the "drawTooltipPolylinePolygonComplete" string in the resource file for the current locale.

This property can be used as the source for data binding.


Implementation
    public function get toolTipPolyEnd():String
    public function set toolTipPolyEnd(value:String):void

See also

toolTipPolyStartproperty 
toolTipPolyStart:String

Since : ArcGIS API 3.6 for Flex

Tooltip shown when starting to draw polylines and polygons. Defaults to the "drawTooltipPolylinePolygonStart" string in the resource file for the current locale.

This property can be used as the source for data binding.


Implementation
    public function get toolTipPolyStart():String
    public function set toolTipPolyStart(value:String):void

See also

toolTipStartAndLetGoproperty 
toolTipStartAndLetGo:String

Since : ArcGIS API 3.6 for Flex

Tooltip shown when drawing simple lines, freehand polylines, freehand polygons, extents, circles and ellipses. Defaults to the "drawTooltipOther" string in the resource file for the current locale.

This property can be used as the source for data binding.


Implementation
    public function get toolTipStartAndLetGo():String
    public function set toolTipStartAndLetGo(value:String):void

See also

Constructor Detail
DrawTool()Constructor
public function DrawTool(map:Map = null)

Creates a new DrawTool object.

Parameters
map:Map (default = null) — The Map that the tool should be associated with.
Method Detail
activate()method
public function activate(drawType:String, enableGraphicsLayerMouseEvents:Boolean = false):void

Activates the tool for drawing geometries. Activating the tool disables map navigation.

Parameters

drawType:String — The draw type. One of either MAPPOINT, MULTIPOINT, EXTENT, LINE, POLYLINE, POLYGON, FREEHAND_POLYLINE or FREEHAND_POLYGON.
 
enableGraphicsLayerMouseEvents:Boolean (default = false) — If true, allows GraphicsLayer to listen for MouseEvents while tool is active.

deactivate()method 
public function deactivate():void

Deactivates the tool and reactivates map navigation.

Event Detail
drawEnd Event
Event Object Type: com.esri.ags.events.DrawEvent
DrawEvent.type property = com.esri.ags.events.DrawEvent.DRAW_END

The drawEnd event is dispatched when the drawing is complete.

Defines the value of the type property of a drawEnd event object.
drawStart Event  
Event Object Type: com.esri.ags.events.DrawEvent
DrawEvent.type property = com.esri.ags.events.DrawEvent.DRAW_START

The drawStart event is dispatched when the drawing starts.

Defines the value of the type property of a drawStart event object.
drawUpdate Event  
Event Object Type: com.esri.ags.events.DrawEvent
DrawEvent.type property = com.esri.ags.events.DrawEvent.DRAW_UPDATE

Since : ArcGIS API 3.1 for Flex

The drawUpdate event is dispatched while drawing.

Defines the value of the type property of a drawUpdate event object.
Constant Detail
CIRCLEConstant
public static const CIRCLE:String = circle

Draws a circle.

ELLIPSEConstant 
public static const ELLIPSE:String = ellipse

Draws an ellipse.

EXTENTConstant 
public static const EXTENT:String = extent

Draws an extent.

FREEHAND_POLYGONConstant 
public static const FREEHAND_POLYGON:String = freehandpolygon

Draws a freehand polygon.

FREEHAND_POLYLINEConstant 
public static const FREEHAND_POLYLINE:String = freehandpolyline

Draws a freehand polyline.

LINEConstant 
public static const LINE:String = line

Draws a line.

MAPPOINTConstant 
public static const MAPPOINT:String = mappoint

Draws a point.

MULTIPOINTConstant 
public static const MULTIPOINT:String = multipoint

Draws a multipoint.

POLYGONConstant 
public static const POLYGON:String = polygon

Draws a polygon.

POLYLINEConstant 
public static const POLYLINE:String = polyline

Draws a polyline.

SNAP_MODE_ALWAYS_ONConstant 
public static const SNAP_MODE_ALWAYS_ON:String = alwaysOn

Snapping is always on.

SNAP_MODE_OFFConstant 
public static const SNAP_MODE_OFF:String = off

Snapping is off.

SNAP_MODE_ON_DEMANDConstant 
public static const SNAP_MODE_ON_DEMAND:String = onDemand

Enable snapping by pressing the Ctrl key.

SNAP_OPTION_EDGEConstant 
public static const SNAP_OPTION_EDGE:String = edge

Snap to edge only.

SNAP_OPTION_EDGE_AND_VERTEXConstant 
public static const SNAP_OPTION_EDGE_AND_VERTEX:String = edgeAndVertex

Snap to edge and vertex.

SNAP_OPTION_VERTEXConstant 
public static const SNAP_OPTION_VERTEX:String = vertex

Snap to vertex only.