ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FeatureLayer Class / HasSymbolLayerDrawingAdded Method
Example

In This Topic
    HasSymbolLayerDrawingAdded Method (FeatureLayer)
    In This Topic
    Determine whether the feature layer or a parent group layer has Symbol Layer Drawing added. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public ValueTuple<bool,bool> HasSymbolLayerDrawingAdded()
    Public Function HasSymbolLayerDrawingAdded() As ValueTuple(Of Boolean,Boolean)

    Return Value

    Returns a tuple (addedOnLayer, addedOnParent). addedOnLayer will be True if the feature layer has SLD added. addedOnParent will be true if the feature layer is participating in SLD controlled by a parent group layer with SLD added.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    The tuple returns two values (addedOnLayer, addedOnParent). If the feature layer has SLD added then tuple.addedOnLayer will be true. If the feature layer is part of a group layer that has SLD added then tuple.addedOnLayer will be false and tuple.addedOnParent will be true. If a layer, or parent group layer, had SLD added but but it contains invalid identifiers on the symbol layers then HasSymbolLayerDrawingAdded() will return false for the respective tuple value(s).
    Use CanAddSymbolLayerDrawing to determine if a feature layer can have Symbol Layer Drawing, SLD, added.
    Example
    Determine if a layer has SLD added
    //SLD can be added to feature layers and group layers
    //For a group layer, SLD controls all child feature layers
    //that are participating in the SLD
    
    //var featLayer = ...;//retrieve the feature layer
    //var groupLayer = ...;//retrieve the group layer
    QueuedTask.Run(() =>
    {
      //Check if the layer has SLD added -returns a tuple
      var tuple = featLayer.HasSymbolLayerDrawingAdded();
      if (tuple.addedOnLayer)
      {
        //SLD is added on the layer
      }
      else if (tuple.addedOnParent)
      {
        //SLD is added on the parent (group layer) - 
        //check parent...this can be recursive
        var parentLayer = GetParentLayerWithSLD(featLayer.Parent as GroupLayer);
        /*
         * 
       //Recursively get the parent with SLD
       public GroupLayer GetParentLayerWithSLD(GroupLayer groupLayer) 
       {
         if (groupLayer == null)
           return null;
         //Must be on QueuedTask
         var sld_added = groupLayer.HasSymbolLayerDrawingAdded();
         if (sld_added.addedOnLayer)
           return groupLayer;
         else if (sld_added.addedOnParent)
           return GetParentLayerWithSLD(groupLayer.Parent as GroupLayer);
         return null;
       }
      */
      }
    });
    
    Enable/Disable SLD
    QueuedTask.Run(() =>
    {
      //A layer may have SLD added but is not using it
      //HasSymbolLayerDrawingAdded returns a tuple - to check
      //the layer has SLD (not its parent) check addedOnLayer
      if (featLayer.HasSymbolLayerDrawingAdded().addedOnLayer)
      {
        //the layer has SLD but is the layer currently using it?
        //GetUseSymbolLayerDrawing returns a tuple - useOnLayer for 
        //the layer (and useOnParent for the parent layer)
        if (!featLayer.GetUseSymbolLayerDrawing().useOnLayer)
        {
          //enable it
          featLayer.SetUseSymbolLayerDrawing(true);
        }
      }
    
      //Enable/Disable SLD on a layer parent
      if (featLayer.HasSymbolLayerDrawingAdded().addedOnParent)
      {
        //check parent...this can be recursive
        var parent = GetParentLayerWithSLD(featLayer.Parent as GroupLayer);
        if (parent.GetUseSymbolLayerDrawing().useOnLayer)
          parent.SetUseSymbolLayerDrawing(true);
      }
      /*
       * 
       //Recursively get the parent with SLD
       public GroupLayer GetParentLayerWithSLD(GroupLayer groupLayer) 
       {
         if (groupLayer == null)
           return null;
         //Must be on QueuedTask
         var sld_added = groupLayer.HasSymbolLayerDrawingAdded();
         if (sld_added.addedOnLayer)
           return groupLayer;
         else if (sld_added.addedOnParent)
           return GetParentLayerWithSLD(groupLayer.Parent as GroupLayer);
         return null;
       }
      */
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also