Select to view content in your preferred language

Draw tool with Measure action functionality

742
3
05-21-2012 11:26 AM
JaredWhite
Regular Contributor
THere is alot of references to adding measureaction to the draw tool, but there isn't a single example. When I try what I've written so far, it randomizes between full measure behavior or full draw behavior. Never both. How do I get these tools to work together?

                            <esri:Toolbar x:Name="MyToolbar" >
                                <esri:Toolbar.Items>
                                    <esri:ToolbarItemCollection>
                                        <esri:ToolbarItem Text="Add a Polygon">
                                            <esri:ToolbarItem.Content>
                                                <Rectangle Fill="Green" Height="40" Width="40" />
                                            </esri:ToolbarItem.Content>
                                        </esri:ToolbarItem>
                                    </esri:ToolbarItemCollection>
                                </esri:Toolbar.Items>
                            </esri:Toolbar>                                  


                case 1: // Polygon
                    MyDrawObject.DrawMode = DrawMode.Polygon;
                    _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol;
                    MyMeasureAction m = new MyMeasureAction();
           m.MeasureMode = MeasureAction.Mode.Polygon;
               m.AreaUnit = AreaUnit.Acres;
           m.DisplayTotals = true;
                                m.FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as FillSymbol;
           m.DistanceUnit = DistanceUnit.Feet;
                 m.Attach(TabletMap);
           m.Execute();
                    break;



Any help would be greatly appreciated.
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
               case 1: // Polygon
                    MyDrawObject.DrawMode = DrawMode.Polygon;
                    _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol;
                    MyMeasureAction m = new MyMeasureAction();


The measure action manages its own user feedback, so you should not have a draw object AND a measure action active at the same time.
Depending on the current action, you have to toggle the draw object on/off (using IsEnabled property), and to toggle reversely (off/on) the MeasureAction (by setting or resetting the map target).
0 Kudos
BrandonCales
Regular Contributor
Did you figure anything out....I posted my code here, but its still not the best.

There seems to be a lag between the end of the measuring (double-click) and when the static graphic shows on the map. Also i cannot figure out how to continue using the measure without having to click ont he button again.
0 Kudos
JaredWhite
Regular Contributor
Did you figure anything out....I posted my code here, but its still not the best.

There seems to be a lag between the end of the measuring (double-click) and when the static graphic shows on the map. Also i cannot figure out how to continue using the measure without having to click ont he button again.


I never got it working. My goal was to understand the measureaction better so I could eventually integrate its function into the teamplatepicker draw function. I would still love to get an answer on this myself.
0 Kudos