Measure segments while drawing polygon at same time

1579
1
05-17-2013 08:43 AM
DuncanNisbett
New Contributor
I've researched the samples, API, and general web to find any form of a solution to this but have come up dry. Is there a way to take the segments of a polygon as they are being drawn and display their measurement? I know that the measurement widget exists, however that's its own entity and separate from drawing a polygon. And so far I've been unable to find a method in which I can capture the current drawing object to run the geometry service against. Any suggestions or hints would be appreciated. If there was an event listener that could be attached which returned the current drawing object, I could then get the segment length from that, but I haven't seen anything of the sort.

Psuedocode:
Start Drawing
Show measurement window (a floating window)
Attach drawing object to variable
Move mouse to draw segments
Take drawing object variable and simplify using geometry service
Run a length check on the current segment to display length
Complete Drawing (onDrawEnd)
Measurement window disappears


Ideas?
0 Kudos
1 Reply
StephenLead
Regular Contributor III
Is there a way to take the segments of a polygon as they are being drawn and display their measurement? I know that the measurement widget exists, however that's its own entity and separate from drawing a polygon. And so far I've been unable to find a method in which I can capture the current drawing object to run the geometry service against. Any suggestions or hints would be appreciated. If there was an event listener that could be attached which returned the current drawing object, I could then get the segment length from that


I don't have a full answer, but to address some of the issues above you could try using the Draw toolbar rather than the measurement widget, as this may give more fine-grained control.

The draw toolbar fires an onDrawComplete event, which you may be able to use to calculate the segment lengths. You may need to do some trickery around creating a series of 2-point lines (so you can calculate their length) then aggregating these into a more complex feature. Another option may be to run a geoprocessing script on the completed feature to calculate the segment lengths.
0 Kudos