ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapTool Class
Members Example

In This Topic
    MapTool Class
    In This Topic
    Represents a tool command used to perform interactive operations on a MapView.
    Object Model
    MapTool ClassMapView ClassEditingTemplate ClassEmbeddableControl ClassSegmentSymbolOptions ClassVertexSymbolOptions ClassEmbeddableControl ClassCIMSymbolReference ClassCIMSymbolReference ClassEmbeddableControl Class
    Syntax
    Remarks

    This base class can be used to create tools to interactively identify and select features in the view or to create custom construction and editing tools. It provides virtual methods that can be overridden to perform actions when keyboard and mouse events occur in the map view, such as OnToolMouseDown and OnToolKeyDown. When overriding mouse and keyboard virtual methods if you need to execute any asynchronous code first set the handled property on the event arguments to true, override the corresponding "Handle...Async" method, and add your asynchronous code.

    By setting the IsSketchTool property to true, the tool will create a sketch in the map view with a left mouse click. Use the SketchType property to set the geometry type of the sketch and use the SketchOutputMode property to specify whether the sketch geometry is in screen or map coordinates. Override OnSketchCompleteAsync to add behavior to the tool when the sketch is finished.

    Example
    Custom construction tool that fires sketch events
    internal class ConstructionTool1 : MapTool
    {
      public ConstructionTool1()
      {
        IsSketchTool = true;
        UseSnapping = true;
        // Select the type of construction tool you wish to implement.  
        // Make sure that the tool is correctly registered with the correct component category type in the daml 
        SketchType = SketchGeometryType.Line;
        //Gets or sets whether the sketch is for creating a feature and should use the CurrentTemplate.
        UsesCurrentTemplate = true;
    
        // set FireSketchEvents property to true
        FireSketchEvents = true;
      }
    
      //  ...
    }
    
    Inheritance Hierarchy
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also