http://help.arcgis.com/EN/webapi/javascript/arcgis/demos/toolbar/toolbar_draw.html

Is it possible for the user to change the size of the circle that will be drawn at all?

Thanks,

James

Is it possible for the user to change the size of the circle that will be drawn at all?

Thanks,

James

using esri.toolbars.Draw.POINT in conjunction with geometry services's buffer operation will do it

Why don't the do what they should do? For a circle, one should click on the mouse at the center and drag out to create a circle.

Here is the ID: NIM056901 [Include the capability to draw using circle within the ArcGIS API for JavaScript.]

Thanks,

SS

function addCircleToMap(geometry){ //the geometry that get�??s passed in contains the 2 points that define the line that was draw.

drawingToolbar.deactivate();

map.showZoomSlider();

var symbol; // the symbol is just the line (pen) that will be used to draw the shape

symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([239, 62, 66, .6]), 3), new dojo.Color([240, 223, 186, 0.25]));

var circleGeometry = new esri.geometry.Polygon(new esri.SpatialReference({wkid:102100}));

var points = new Array();

var degree;var i=0;var edgeX, edgeY,tmpPoint,path

//since mercator projection is expressed in meters, we can use some simple math to look at the 2 points in terms of a right triangle sitting on lat/lon lines

//then use the pythagorean theorem to get the hypotenuse (distance) between the 2 points

var dist = Math.sqrt(Math.pow((geometry.paths[0][0][0] - geometry.paths[0][1][0]),2) + Math.pow((geometry.paths[0][0][1] - geometry.paths[0][1][1]),2));

while(i<361){ //now, with our 2 points and the distance, we can loop 360 times and calculate 360 points around the circumference of our soon-to-be circle.

degree = i * (Math.PI / 180);

edgeX = geometry.paths[0][0][0] + Math.cos(degree) * dist;

edgeY = geometry.paths[0][0][1] + Math.sin(degree) * dist;

points.push([edgeX,edgeY]); //push the new point into the point array

i++;

}

//put the point array into the polygon object

circleGeometry.addRing(points);

//create a graphic object using our new polygon/point array

var graphic = new esri.Graphic(circleGeometry, symbol);

try {

bufferLayer.clear();

map.removeLayer(bufferLayer);

}

catch (err) { } //this layer won't always exist, so we'll need to check.

bufferLayer = new esri.layers.GraphicsLayer();

bufferLayer.add(graphic); // add the graphic to the graphics layer

map.addLayer(bufferLayer); //and add the new layer to the map

}

For the jsfiddle example, click once to set the circle center, click again to set the radius. You can drag both the center and point on the circle to change the size of the circle or move it.