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 ViewMapTask.

The following screen capture shows the Measure menu item in ViewMapTask:

Measure menu

Measuring methods

To remove existing measuring methods, or when adding your own implementation of new measuring methods, listen to the ViewMapTask.CreatingMeasureMethods event. This event is 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 ...
    }

Measure using rangefinder

1/7/2015