ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ISymbolFactory Interface / ConstructMarker Method / ConstructMarker(CIMColor,Double,SimpleMarkerStyle) Method
ArcGIS.Core.CIM.CIMColor
The size of the marker to construct.
SimpleMarkerStyle
Example

In This Topic
    ConstructMarker(CIMColor,Double,SimpleMarkerStyle) Method
    In This Topic
    Constructs a marker of specific color, size and style. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Overloads Function ConstructMarker( _
       ByVal color As CIMColor, _
       ByVal size As Double, _
       ByVal markerStyle As SimpleMarkerStyle _
    ) As CIMMarker

    Parameters

    color
    ArcGIS.Core.CIM.CIMColor
    size
    The size of the marker to construct.
    markerStyle
    SimpleMarkerStyle

    Return Value

    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run
    Example
    How to construct a point symbol from a marker
    {
      CIMMarker marker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.GreenRGB, 8.0, SimpleMarkerStyle.Pushpin);
      CIMPointSymbol pointSymbolFromMarker = SymbolFactory.Instance.ConstructPointSymbol(marker);
    }
    How to construct a multilayer line symbol with circle markers on the line ends
    {
      await QueuedTask.Run(() =>
      {
        var lineStrokeRed = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 4.0);
        var markerCircle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Circle);
        markerCircle.MarkerPlacement = new CIMMarkerPlacementOnVertices()
        {
          AngleToLine = true,
          PlaceOnEndPoints = true,
          Offset = 0
        };
        var lineSymbolWithCircles = new CIMLineSymbol()
        {
          SymbolLayers = new CIMSymbolLayer[2] { markerCircle, lineStrokeRed }
        };
      });
    }
    How to construct a multilayer line symbol with an arrow head on the end
    {
      var markerTriangle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Triangle);
      markerTriangle.Rotation = -90; // or -90
      markerTriangle.MarkerPlacement = new CIMMarkerPlacementOnLine() { AngleToLine = true, RelativeTo = PlacementOnLineRelativeTo.LineEnd };
    
      var lineSymbolWithArrow = new CIMLineSymbol()
      {
        SymbolLayers = new CIMSymbolLayer[2] { markerTriangle,
                  SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2)
        }
      };
    }
    Dash line with two markers - Method I
    /// <summary>
    /// Create a line symbol with a dash and two markers.<br/>
    /// This line symbol comprises three symbol layers listed below:
    /// 1. A solid stroke that has dashes.
    /// 1. A circle marker.
    /// 1. A square marker.
    /// ![LineSymbolTwoMarkers](https://ArcGIS.github.io/arcgis-pro-sdk/images/Symbology/line-dash-two-markers.png)
    /// </summary>
    {
      //Create a line symbol with a dash and two markers.
      //Note: Run withing QueuedTask
      CIMLineSymbol dash2MarkersLine = new CIMLineSymbol();
      var mySymbolLyrs = new CIMSymbolLayer[]
            {
                  new CIMSolidStroke()
                  {
                      Color = ColorFactory.Instance.BlackRGB,
                      Enable = true,
                      ColorLocked = true,
                      CapStyle = LineCapStyle.Round,
                      JoinStyle = LineJoinStyle.Round,
                      LineStyle3D = Simple3DLineStyle.Strip,
                      MiterLimit = 10,
                      Width = 1,
                      CloseCaps3D = false,
                      Effects = new CIMGeometricEffect[]
                      {
                          new CIMGeometricEffectDashes()
                          {
                              CustomEndingOffset = 0,
                              DashTemplate = new double[] {20, 10, 20, 10},
                              LineDashEnding = LineDashEnding.HalfPattern,
                              OffsetAlongLine = 0,
                              ControlPointEnding = LineDashEnding.NoConstraint
                          },
                          new CIMGeometricEffectOffset()
                          {
                              Method = GeometricEffectOffsetMethod.Bevelled,
                              Offset = 0,
                              Option = GeometricEffectOffsetOption.Fast
                          }
                      },
                  },
                  CreateCircleMarkerPerSpecs(),
                  CreateSquareMarkerPerSpecs()
        };
      dash2MarkersLine.SymbolLayers = mySymbolLyrs;
    
      static CIMMarker CreateCircleMarkerPerSpecs()
      {
        var circleMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.BlackRGB, 5, SimpleMarkerStyle.Circle) as CIMVectorMarker;
        //Modifying the marker to align with line
        //First define "markerplacement"
        CIMMarkerPlacementAlongLineSameSize markerPlacement = new CIMMarkerPlacementAlongLineSameSize()
        {
          AngleToLine = true,
          Offset = 0,
          Endings = PlacementEndings.Custom,
          OffsetAlongLine = 15,
          PlacementTemplate = new double[] { 60 }
        };
        //assign the markerplacement to the marker
        circleMarker.MarkerPlacement = markerPlacement;
        return circleMarker;
      }
      static CIMMarker CreateSquareMarkerPerSpecs()
      {
        var squareMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.BlueRGB, 5, SimpleMarkerStyle.Square) as CIMVectorMarker;
        CIMMarkerPlacementAlongLineSameSize markerPlacement2 = new CIMMarkerPlacementAlongLineSameSize()
        {
          AngleToLine = true,
          Endings = PlacementEndings.Custom,
          OffsetAlongLine = 45,
          PlacementTemplate = new double[] { 60 },
        };
        squareMarker.MarkerPlacement = markerPlacement2;
        return squareMarker;
      }
    }
    Dash line with two markers - Method II
    /// <summary>
    /// Create a line symbol with a dash and two markers. <br/>
    /// In this pattern of creating this symbol, a [CIMVectorMarker](https://doc.esri.com/en/arcgis-pro/latest/sdk/api-reference/#topic6176.html) object is created as a new [CIMSymbolLayer](https://doc.esri.com/en/arcgis-pro/sdk/api-reference/#topic5503.html).
    /// The circle and square markers created by [ContructMarker](https://doc.esri.com/en/arcgis-pro/latest/sdk/api-reference/#topic12350.html) method is then assigned to the [MarkerGraphics](https://doc.esri.com/en/arcgis-pro/sdk/api-reference/#topic6188.html) property of the CIMVectorMarker.
    /// When using this method, the CIMVectorMarker's [Frame](https://doc.esri.com/en/arcgis-pro/sdk/api-reference/#topic6187.html) property needs to be set to the [CIMMarker](https://doc.esri.com/en/arcgis-pro/sdk/api-reference/#topic3264.html) object's Frame.
    /// Similarly, the CIMVectorMarker's [Size](https://doc.esri.com/en/arcgis-pro/latest/sdk/api-reference/#topic3284.html) property needs to be set to the CIMMarker object's size.
    /// This line symbol comprises three symbol layers listed below:
    /// 1. A solid stroke that has dashes.
    /// 1. A circle marker.
    /// 1. A square marker.
    /// ![LineSymbolTwoMarkers](https://ArcGIS.github.io/arcgis-pro-sdk/images/Symbology/line-dash-two-markers.png)
    /// </summary>
    {
      // Create a line symbol with a dash and two markers.
      //default line symbol that will get modified.
      //Note: Run withing QueuedTask
      CIMLineSymbol dash2MarkersLine = new CIMLineSymbol();
      //circle marker to be used in our line symbol as a layer
      var circleMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.BlackRGB, 5, SimpleMarkerStyle.Circle) as CIMVectorMarker;
      //circle marker to be used in our line symbol as a layer
      var squareMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.BlueRGB, 5, SimpleMarkerStyle.Square) as CIMVectorMarker;
      //Create the array of layers that make the new line symbol
      CIMSymbolLayer[] mySymbolLyrs =
          {
                  new CIMSolidStroke() //dash line
                  {
                      Color = ColorFactory.Instance.BlackRGB,
                      Enable = true,
                      ColorLocked = true,
                      CapStyle = LineCapStyle.Round,
                      JoinStyle = LineJoinStyle.Round,
                      LineStyle3D = Simple3DLineStyle.Strip,
                      MiterLimit = 10,
                      Width = 1,
                      CloseCaps3D = false,
                      Effects = new CIMGeometricEffect[]
                      {
                          new CIMGeometricEffectDashes()
                          {
                              CustomEndingOffset = 0,
                              DashTemplate = new double[] {20, 10, 20, 10},
                              LineDashEnding = LineDashEnding.HalfPattern,
                              OffsetAlongLine = 0,
                              ControlPointEnding = LineDashEnding.NoConstraint
                          },
                          new CIMGeometricEffectOffset()
                          {
                              Method = GeometricEffectOffsetMethod.Bevelled,
                              Offset = 0,
                              Option = GeometricEffectOffsetOption.Fast
                          }
                      }
                  },
                  new CIMVectorMarker() //circle marker
                  {
                      MarkerGraphics = circleMarker.MarkerGraphics,
                      Frame = circleMarker.Frame, //need to match the CIMVector marker's frame to the circleMarker's frame.
                      Size = circleMarker.Size,    //need to match the CIMVector marker's size to the circleMarker's size.
                     MarkerPlacement = new CIMMarkerPlacementAlongLineSameSize()
                     {
                         AngleToLine = true,
                         Offset = 0,
                         Endings = PlacementEndings.Custom,
                         OffsetAlongLine = 15,
                         PlacementTemplate = new double[] {60},
                     }
    
                  },
                  new CIMVectorMarker() //square marker
                  {
                     MarkerGraphics = squareMarker.MarkerGraphics,
                     Frame = squareMarker.Frame, //need to match the CIMVector marker's frame to the squareMarker frame.
                     Size = squareMarker.Size, //need to match the CIMVector marker's size to the squareMarker size.
                     MarkerPlacement = new CIMMarkerPlacementAlongLineSameSize()
                     {
                         AngleToLine = true,
                         Endings = PlacementEndings.Custom,
                         OffsetAlongLine = 45,
                         PlacementTemplate = new double[] {60},
                     }
                  }
        };
      dash2MarkersLine.SymbolLayers = mySymbolLyrs;
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also