Customizing measuring methods

Mobile application provides built-in measure tools for measuring distance, perimeter, and area on a MapPage. This is part of the functionality provided by the ViewMapTask.

The screen capture below shows the Measure menu item in ViewMapTask.

This is required

This is required

To remove existing measuring methods or when adding your own implementation of new measuring methods, listen to ViewMapTask.CreatingMeasureMethods event. This event will be fired when all measuring methods are being added to the Page. You can customize this page by removing existing measuring methods or adding new methods.

The following code demonstrates how to remove an existing measuring method and add a new measuring method using rangefinder.

    MobileApplication.Current.Project.ViewMapTask.CreatingMeasureMethods += new ActionItemEventHandler<ListViewActionItem>(CreatingMeasureMethods);
 
    void CreatingMeasureMethods(object sender, ActionItemEventArgs<ListViewActionItem> e)
    {
      e.ActionItems.RemoveAt(0);

      ExtendedListViewItem lvi = new ExtendedListViewItem("Use Rangefinder");
      lvi.SecondaryStrings.Add("Measure using rangefinder");
      ListViewActionItem ai = new ListViewActionItem("Measure with Rangefinder", lvi, RangeFinderMeasure);
 
      e.ActionItems.Add(ai);
    }
 
    private void RangeFinderMeasure()
    {
      // your implementation of new measuring method ...
    }

This is required


9/20/2011