The company I work for created a customized solution to this exact issue, I cannot copy the code but I can give you a guideline:
- Create a variable that indicates 'inDrawing' state
- Create a variable for 'currentPoints'
- Create a graphicLayer for measurements
- Create a listener on "mouse-move"/"mouse-drag" event on the map
- If "inDrawing":
- send the mouse position (x,y)
- Add the new point to the array
var movingPoint = new Point(x, y, spatialReference);
currentPoints.push(movingPoint);
- If the shape is a polygon add the first point to the end of the points array [please note you should clear the array before the action/splice the last point etc.]
- Iterate on the currentPoint array and:
-- calculate distance between points pair
-- calculate the angle of the line
-- create a graphic text symbol with the distance and the angle
-- add the new graphic to the measurements graphicsLayer
- If the shape is a line and there are more than 3 vertices - add a graphic with total length
- If the shape is a polygon - add a graphic with the shape area
I've skipped some details like clearing layers and variables, I hope the guideline can be helpful nevertheless.