Select to view content in your preferred language

Display diameter of a circle as the user draws it

1807
3
02-14-2012 12:31 PM
TylerRothermund
Emerging Contributor
How can I display the diameter of a circle as the user draws it ?   I want the diameter to only be displayed while the user is drawing. 


I'm using the code from this example to draw the circle.
I looked at using the MeasureAction but it seems like there must be a better way than watching the collection changed of the layers so i can create a new graphic that is the correct size, since there is no MeasureComplete event.
0 Kudos
3 Replies
TylerRothermund
Emerging Contributor
Any suggestions?
0 Kudos
OrlandoCarvajal
Deactivated User
I would try using the Draw.DrawBegin, Map.MouseLeftButtonDown and Map.MouseMove events in something like this:
1. In Map.MouseLeftButtonDown save the current cursor position.
2. In DrawBegin detect when the shape is a circle and start tracking the cursor's movement by attaching to the MouseMove event.
3. In the MouseMove, obtain the current position and convert it (along with the center's location) to map's coordinates. Then calculate the distance.
4. Add or move a text graphic in a Graphics layer showing the diameter (distance*2).
5. In DrawComplete detach from the MouseMove event.

Not sure if you in the DrawBegin event you can access the current Cursor's location; if so you could save step 1.

Good luck
0 Kudos
JenniferNery
Esri Regular Contributor
We don't support this out-of-the-box so would require you to write your own code. Orlando's suggestion sound like a good solution. DrawBegin will not give you the current location but after this is raised, you can use VertexAdded event and get the start point from there.
0 Kudos