Select to view content in your preferred language

MapTool Sketch Type Circle Bug?

137
1
03-11-2025 06:52 PM
neil_perol
Occasional Contributor

Hi,

I have an issue which seems to be a bug, but correct me if I'm wrong.

Whenever I use 'SketchGeometryType.Circle' as the 'SketchType' on any MapTool, I get this sort of bug(?) wherein the tool runs properly until I try to choose 'Circle' or 'Three Point Circle' in the editing toolbar. If I click on 'Circle', the custom tool is deactivated and the standard 'Circle' tool is activated. If I click on 'Three Point Circle', I get the default 'Line' or 'Polygon' tool. This only happens when SketchType is set to 'SketchGeometryType.Circle' for some reason.

Anyone got any thoughts on this?

neil_perol_0-1741744272177.png

ArcGIS Pro: Version 3.4

1 Reply
NarelleChedzey
Esri Contributor

Hi Neil, 

In a MapTool when you are sketching, there are two properties that typically affect the sketch.  SketchType and SketchMode.  The combination of these two properties control the sketch feedback that is displayed on the map. 

In the case of sketching a line (SketchType = SketchGeometryType.Line), there is a wide range of SketchModes that can be used to construct the line.  The default SketchMode is SketchMode.Line but this can be changed via code or the UI.  These sketchModes are what you see on the editing toolbar when the sketch/construction tool is activated.  When a button on the editing toolbar is clicked (such as RightAngle, Arc, Bezier etc), then the SketchMode of the tool is being altered - allowing different types of line segments to be constructed. 

The editing toolbar works a little differently with the SketchGeometryType.Circle, since the SketchMode property does not apply.   In this case, the toolbar contains 2 different tools for constructing circles.  The Circle Tool   (damlID esri_editing_SketchCircleLineTool) and the Three Point Circle Tool (damlID esri_editing_SketchLineThreePointCircleTool).   

This toolbar is defined in the Editing.daml file as follows

        <miniToolbar id="esri_editing_LineCircleToolbar">
          <row>
            <button refID="esri_editing_AddDeviceLocationCommand"/>
            <button refID="esri_editing_SketchCircleLine" separator="true"/>
            <button refID="esri_editing_SketchLineThreePointCircle"/>
            <button refID="esri_editing_FinishSketch" separator="true" />
            <button refID="esri_editing_ClearSketch" />
          </row>
        </miniToolbar>

 

When any of the items on the editing toolbar is clicked, then that tool will be activated (and your tool deactivated). 

To avoid this scenario you can have your tool show a different editing toolbar.  Just define a miniToolbar within your add-in in the daml file.   And then within your sketch tool set the ContextToolbarID property to the damlID of the miniToolbar. 

Here's an example

(daml file)

<controls>
 <!-- your construction tool -->
  <tool id="sketchTypeCircle_ConstructionTool_circle" categoryRefID="esri_editing_construction_polyline" caption="ConstructionTool _circle" className="ConstructionTool_circle" loadOnClick="true" smallImage="GenericButtonRed16" largeImage="GenericButtonRed32">
    <!--note: use esri_editing_construction_polyline,  esri_editing_construction_polygon for categoryRefID as needed-->
    <tooltip heading="My circle tool"><disabledText /></tooltip>
    <content guid="9d63cec0-062c-4ac0-9a0d-69a02e1e2b4a" />
  </tool>
</controls>
<miniToolbars>
    <!-- your toolbar 
       references your custom tool, then the standard 3 point circle tool
        followed by finish sketch, clear sketch
    -->
    <miniToolbar id="MyCircleToolbar">
    <row>
      <button refID="sketchTypeCircle_ConstructionTool_circle" />
      <button refID="esri_editing_SketchLineThreePointCircle"/>
      <button refID="esri_editing_FinishSketch" separator="true" />
      <button refID="esri_editing_ClearSketch" />
    </row>
  </miniToolbar>
</miniToolbars>

(cs file)

internal class ConstructionTool_circle : MapTool
{
  public ConstructionTool_circle()
  {
    IsSketchTool = true;
    UseSnapping = true;
    SketchType = SketchGeometryType.Circle;
    //Gets or sets whether the sketch is for creating a feature and should use the CurrentTemplate.
    UsesCurrentTemplate = true;
    //Gets or sets whether the tool supports firing sketch events when the map sketch changes. 
    //Default value is false.
    FireSketchEvents = true;

    // set the toolbar 
    ContextToolbarID = "MyCircleToolbar";
  }

 

Let me know if you have any questions. 

Narelle

0 Kudos