# Drawing circle of 3 km radius in ArcGIS API for JavaScript?

I am able to draw the circle but I want a circle of radius 3 kms

I have checked all the previous posts.

I want to know what is the units of radius in the below code.

``````var radius, circle, ring, pts, angle;
var currentPoint = new esri.geometry.Point(longitude, latitude, this.parent.esriMap.spatialReference);

currentPoint = esri.geometry.geographicToWebMercator(currentPoint);
circle = new esri.geometry.Polygon(this.parent.esriMap.spatialReference);

ring = []; // point that make up the circle
pts = 40; // number of points on the circle
angle = 360 / pts; // used to compute points on the circle

for (var i = 0; i <= 360; i = i + 10) {
var radian = i * (Math.PI / 180.0);
var circlePoint = new esri.geometry.Point(x1, y1, this.parent.esriMap.spatialReference);
circlePoint = esri.geometry.geographicToWebMercator(circlePoint);

points[i] = new esri.geometry.Point(
parseFloat(circlePoint.x) + parseFloat(currentPoint.x), parseFloat(circlePoint.y) + parseFloat(currentPoint.y),
this.parent.esriMap.spatialReference);
ring.push(points[i]);
}
//rest code to add the layers to map
``````

Creating a 3km radius circle is quite easy in ArcGIS Desktop:

1. Create a point featureclass marking the center of your area of interest.
2. Use the Buffer (Analysis) tool to create the 3km radius buffer around the point featureclass.

When solving it programmatically I would start with this Snippet from ESRI:

Create Graphic Buffers around Selected Features Snippet:

``````///<summary>Draws graphic buffers around the selected features in the map using distance units specified.</summary>
///
///<param name="activeView">An IActiveView interface.</param>
///<param name="distance">A System.Double that is the distance in map units around the select features to draw a graphic buffer. Example: 10</param>
///
///<remarks></remarks>
public void CreateGraphicBuffersAroundSelectedFeatures(ESRI.ArcGIS.Carto.IActiveView activeView, System.Double distance)
{
//parameter check
if (activeView == null || distance < 0)
{
return;
}
ESRI.ArcGIS.Carto.IMap map = activeView.FocusMap;
// Clear any previous buffers from the screen
ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)map; // Explicit Cast
graphicsContainer.DeleteAllElements();

// Verify there is a feature(s) selected
if (map.SelectionCount == 0)
{
return;
}

// Reset to the first selected feature
ESRI.ArcGIS.Geodatabase.IEnumFeature enumFeature = (ESRI.ArcGIS.Geodatabase.IEnumFeature)map.FeatureSelection; // Explicit Cast
enumFeature.Reset();
ESRI.ArcGIS.Geodatabase.IFeature feature = enumFeature.Next();

// Buffer all the selected features by the buffer distance and create a new polygon element from each result
ESRI.ArcGIS.Geometry.ITopologicalOperator topologicalOperator;
ESRI.ArcGIS.Carto.IElement element;
while (!(feature == null))
{
topologicalOperator = (ESRI.ArcGIS.Geometry.ITopologicalOperator)feature.Shape; // Explicit Cast
element = new ESRI.ArcGIS.Carto.PolygonElementClass();
element.Geometry = topologicalOperator.Buffer(distance);