AnsweredAssumed Answered

Showing radius line and measurement while drawing a circle on map

Question asked by rhyck.m on Feb 26, 2016
Latest reply on Feb 27, 2016 by tsellste

is anybody ever done this?

 

circle radius and measurements.JPG

 

I haven't tried the following logic:

var centerPt=null; 
//description:get distance between ptB and centerPt //return: number 
function getDistance(ptB)
{  
  if(centerPt==null||centerPt.mapPoint==null)
  {      
  console.log("unexpected para,function getDistance()");      
  return "";    
  }     
  var ptA=centerPt.mapPoint;    
  return Math.sqrt(Math.pow(ptA.x-ptB.x,2)+Math.pow(ptA.y-ptB.y,2));     
} 


// get the center point


map.on("click", function(evt){
  centerPt = evt.mapPoint;
})

//onDragStart, record the centerPt 
map.on("mouse-drag-start",function(evt)
{               
  console.log("dragStart triggered");        
  centerPt=evt;         
  });      
   
//onDrag, calculate distance between currentPoint and centerPt 
map.on("mouse-drag",
  function(evt){    
  var radius=getDistance(evt.mapPoint);    
  console.log("radius is:"+radius);   
  })  

Outcomes