Select to view content in your preferred language

How to create a circle with a centerpoint and a radius

2192
2
Jump to solution
05-16-2017 10:50 AM
KkkkWww
Deactivated User

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)
}

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

I suggest you use either the buffer or the bufferGeodetic GeometryEngine functions.

GeometryEngine QML Type | ArcGIS for Developers 

GeometryEngine QML Type | ArcGIS for Developers 

View solution in original post

0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor

I suggest you use either the buffer or the bufferGeodetic GeometryEngine functions.

GeometryEngine QML Type | ArcGIS for Developers 

GeometryEngine QML Type | ArcGIS for Developers 

0 Kudos
KkkkWww
Deactivated User

Thank you 

0 Kudos