Using 3.x API, how I can get center point and radius from circle made by Draw module?

623
2
06-11-2020 01:00 AM
MilawK_
New Contributor

Using the code below:
JS

initDrawRadiusCircle: function() {
radius = new Draw(this.map);
radius.on("draw-complete", this.addToMap);
},

drawRadiusCircle: function() {
this.map.graphics.remove(radiusGraphic);
radius.activate(Draw.CIRCLE);
},

addToMap: function(evt) {
radius.deactivate();
var symbol = new SimpleFillSymbol(); //.setColor(null).outline.setColor("blue");
radiusGraphic = new Graphic(evt.geometry, symbol);
this.map.graphics.add(radiusGraphic);
},


HTML 

<button
data-dojo-type="dijit/form/Button"
data-dojo-attach-event="onClick: drawRadiusCircle">Draw</button>
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Milaw,

//Require "esri/geometry/Polyline", "esri/geometry/geometryEngine",
addToMap: function(evt) {
  radius.deactivate();
  var symbol = new SimpleFillSymbol();
  radiusGraphic = new Graphic(evt.geometry, symbol);

  var cent = evt.geometry.getCentroid();
  var pnt = evt.geometry.getPoint(0, 0);
  var line = new Polyline([[pnt.x,pnt.y],[cent.x,cent.y]]);
  var rad = geometryEngine.geodesicLength(line, "meters");
  this.map.graphics.add(radiusGraphic);
},‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
MilawK_
New Contributor

Thank you for your help.

I will try your solution

Regards

Milaw.

0 Kudos