Select to view content in your preferred language

Measure Tool at run time

952
2
07-03-2011 04:08 AM
AgatinoLa_Rosa
Emerging Contributor
Is there a way to set up the code of a measure tool from the cs? The Web sample sets the tool in the xaml, which is not my case.

This is what I have and I am not getting it right. My map is inside a ScrollView Object, not sure if this could be an issue.

In my xaml:

   <esri:ToolbarItemCollection>
               <esri:ToolbarItem Text="Measure" >
                       <esri:ToolbarItem.Content>
                              <Image Source="Measure.png" Stretch="UniformToFill" Margin="10"/>
                       </esri:ToolbarItem.Content>
               </esri:ToolbarItem>
               ....[other tools]


In my cs:
private void myToolbar_ToolbarItemClicked(object sender, SelectedToolbarItemArgs e)
case 0:
   StartMeasures();
   break;


and then

  private void StartMeasures()
        {
            
            MeasureAction m = new MeasureAction();
            m.MeasureMode = MeasureAction.Mode.Polyline;
            m.DisplayTotals = true;
            m.LineSymbol = (LineSymbol)this.LayoutRoot.Resources["MLineSymbol"];
            m.DistanceUnit = DistanceUnit.Kilometers;
            m.Attach(this.myMap);
           

        }
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
'Attach' is not supposed to execute the action, so your StartMeasures don't execute the measure action.

Look at this thread http://forums.arcgis.com/threads/3696-Measure-Action-in-Code for infos on how to execute action by code.
0 Kudos
AgatinoLa_Rosa
Emerging Contributor
Thanks Dominique

in the mean time I used the old-fashioned DrawSurface and MouseMove/TextBlock and I am quite happy with the results. Thanks again.
0 Kudos