AnsweredAssumed Answered

# How to create a circle with a centerpoint and a radius

Question asked by Quaicai on May 16, 2017
Latest reply on May 20, 2017 by Quaicai

Hello,

I am new to Qt/QML and ArcGis (Qt 100) and I want to draw a circle on a map. I have the center coordinate and the radius.  I could not find a function or an qml element to render a circle with a center point and an radius. So i wrote a javascript function which uses the circular formula to calculate the circle. The result looks more like an egg than a circle.

function createCircle()
{
var radius, circle, ring, pts, angle, middlePoint, graphic;

//middlePoint = ArcGISRuntimeEnvironment.createObject("Point", { x: 7.69,y: 51.38,spatialReference: SpatialReference.createWgs84()})
circle = ArcGISRuntimeEnvironment.createObject("PolygonBuilder", {spatialReference: SpatialReference.createWgs84() })
ring = []
pts = 100
angle = 360
radius = 0.01

for (var i = 0; i <= 360; i++) {
var radian = i * (Math.PI / 180.0);
var x1= radius * Math.cos(radian);
var y1= radius * Math.sin(radian);

circle.addPointXY(7.69+x1, (51.38+y1))
}
graphic = ArcGISRuntimeEnvironment.createObject("Graphic")
graphic.geometry = circle.geometry
polygonGraphicsOverlay.graphics.append(graphic)
}