ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / LayerFactory Class / CreateGroupLayer Method
A layer container i.e. a map or another group layer where the group layer will belong to.
A 0-based index represents the position of the group layer within the container. 0 means it will added to the very top as the first layer in the container.
Name of the group layer
Example

In This Topic
    CreateGroupLayer Method (LayerFactory)
    In This Topic
    Create a group layer. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function CreateGroupLayer( _
       ByVal container As ILayerContainerEdit, _
       ByVal index As Integer, _
       Optional ByVal layerName As String _
    ) As GroupLayer

    Parameters

    container
    A layer container i.e. a map or another group layer where the group layer will belong to.
    index
    A 0-based index represents the position of the group layer within the container. 0 means it will added to the very top as the first layer in the container.
    layerName
    Name of the group layer
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Conainer cannot be null.
    Example
    Create GraphicsLayer
    var map = MapView.Active.Map;
    if (map.MapType != MapType.Map)
      return;// not 2D
    
    var gl_param = new GraphicsLayerCreationParams { Name = "Graphics Layer" };
    QueuedTask.Run(() =>
    {
      //By default will be added to the top of the TOC
      var graphicsLayer = LayerFactory.Instance.CreateLayer<ArcGIS.Desktop.Mapping.GraphicsLayer>(gl_param, map);
    
      //Add to the bottom of the TOC
      gl_param.MapMemberIndex = -1; //bottom
      LayerFactory.Instance.CreateLayer<ArcGIS.Desktop.Mapping.GraphicsLayer>(gl_param, map);
    
      //Add a graphics layer to a group layer...
      var group_layer = map.GetLayersAsFlattenedList().OfType<GroupLayer>().First();
      LayerFactory.Instance.CreateLayer<ArcGIS.Desktop.Mapping.GraphicsLayer>(gl_param, group_layer);
    
      //TODO...use the graphics layer
      //
    
      // or use the specific CreateGroupLayer method
      LayerFactory.Instance.CreateGroupLayer(map, -1, "Graphics Layer");
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also