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
- For POINT, click to add a point.
- For MULTI_POINT, click to add points, double-click to add the last point of the multi-point.
- For POLYLINE and POLYGON, click to add vertices, double-click to add the last vertex.
- For FREEHAND_POLYLINE and FREEHAND_POLYGON, press mouse down where to start, draw the feature, then let go when finished drawing.
- For LINE, EXTENT, press mouse down where to start and let go where to end the feature.
Samples
Search for
samples that use this class.
Class hierarchy
esri.toolbars.Draw
Constructor
Properties
Constants
| 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
Events
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
Symbol to be used when drawing a
Polyline.
<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);
Deactivates the toolbar and reactivates map navigation.
Return value: 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. (As of v2.0)
Return value: none
Code snippets:
drawToolbar.finishDrawing();
setFillSymbol(fillSymbol)
Sets the fill symbol.
Return value: none
Input Parameters:
setLineSymbol(lineSymbol)
Sets the line symbol.
Return value: none
Input Parameters:
setMarkerSymbol(markerSymbol)
Sets the marker symbol.
Return value: none
Input Parameters:
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
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);
}