ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMUniqueValueClass Class / Label Property
Example

In This Topic
    Label Property (CIMUniqueValueClass)
    In This Topic
    Gets or sets the label.
    Syntax
    public string Label {get; set;}
    Public Property Label As String
    Example
    Create a UniqueValueRenderer to specify symbols to values
    return QueuedTask.Run(() =>
    {
      //The goal is to construct the CIMUniqueValueRenderer which will be applied to the feature layer.
      // To do this, the following are the objects we need to set the renderer up with the fields and symbols.
      // As a reference, this is the USCities dataset. Snippet will create a unique value renderer that applies 
      // specific symbols to all the cities in California and Alabama.  The rest of the cities will use a default symbol.
    
      // First create a "CIMUniqueValueClass" for the cities in Alabama.
      List<CIMUniqueValue> listUniqueValuesAlabama = new List<CIMUniqueValue> { new CIMUniqueValue { FieldValues = new string[] { "Alabama" } } };
      CIMUniqueValueClass alabamaUniqueValueClass = new CIMUniqueValueClass
      {
        Editable = true,
        Label = "Alabama",
        Patch = PatchShape.Default,
        Symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB).MakeSymbolReference(),
        Visible = true,
        Values = listUniqueValuesAlabama.ToArray()
    
      };
      // Create a "CIMUniqueValueClass" for the cities in California.
      List<CIMUniqueValue> listUniqueValuescalifornia = new List<CIMUniqueValue> { new CIMUniqueValue { FieldValues = new string[] { "California" } } };
      CIMUniqueValueClass californiaUniqueValueClass = new CIMUniqueValueClass
      {
        Editable = true,
        Label = "California",
        Patch = PatchShape.Default,
        Symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.BlueRGB).MakeSymbolReference(),
        Visible = true,
        Values = listUniqueValuescalifornia.ToArray()
      };
      //Create a list of the above two CIMUniqueValueClasses
      List<CIMUniqueValueClass> listUniqueValueClasses = new List<CIMUniqueValueClass>
        {
                      alabamaUniqueValueClass, californiaUniqueValueClass
        };
      //Create a list of CIMUniqueValueGroup
      CIMUniqueValueGroup uvg = new CIMUniqueValueGroup
      {
        Classes = listUniqueValueClasses.ToArray(),
      };
      List<CIMUniqueValueGroup> listUniqueValueGroups = new List<CIMUniqueValueGroup> { uvg };
      //Create the CIMUniqueValueRenderer
      CIMUniqueValueRenderer uvr = new CIMUniqueValueRenderer
      {
        UseDefaultSymbol = true,
        DefaultLabel = "all other values",
        DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreyRGB).MakeSymbolReference(),
        Groups = listUniqueValueGroups.ToArray(),
        Fields = new string[] { "STATE_NAME" }
      };
      //Set the feature layer's renderer.
      featureLayer.SetRenderer(uvr);
    });
    Setting a unique value renderer for latest observations
    var url = @"https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer";
    var uri = new Uri(url, UriKind.Absolute);
    //Must be on QueuedTask!
    
    var createParams = new FeatureLayerCreationParams(uri)
    {
      IsVisible = false
    };
    var streamLayer = LayerFactory.Instance.CreateLayer<StreamLayer>(
                        createParams, map);
    //Define the unique values by hand
    var uvr = new CIMUniqueValueRenderer()
    {
      Fields = new string[] { "ACTYPE" },
      UseDefaultSymbol = true,
      DefaultLabel = "Others",
      DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol(
                  CIMColor.CreateRGBColor(185, 185, 185), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
    };
    
    var classes = new List<CIMUniqueValueClass>();
    //add in classes - one for ACTYPE of 727, one for DC 9
    classes.Add(
      new CIMUniqueValueClass() {
            Values = new CIMUniqueValue[] {
                  new CIMUniqueValue() { FieldValues = new string[] { "B727" } } },
            Visible = true,
            Label = "Boeing 727",
            Symbol = SymbolFactory.Instance.ConstructPointSymbol(
                  ColorFactory.Instance.RedRGB, 10, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
    });
    classes.Add(
      new CIMUniqueValueClass()
      {
        Values = new CIMUniqueValue[] {
                  new CIMUniqueValue() { FieldValues = new string[] { "DC9" } } },
        Visible = true,
        Label = "DC 9",
        Symbol = SymbolFactory.Instance.ConstructPointSymbol(
                  ColorFactory.Instance.GreenRGB, 10, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
      });
    //add the classes to a group
    var groups = new List<CIMUniqueValueGroup>()
    {
      new CIMUniqueValueGroup() {
         Classes = classes.ToArray()
      }
    };
    //add the groups to the renderer
    uvr.Groups = groups.ToArray();
    //Apply the renderer (for current observations)
    streamLayer.SetRenderer(uvr);
    streamLayer.SetVisibility(true);//turn on the layer
    
    Setting a unique value renderer for latest observations
    var url = @"https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer";
    var uri = new Uri(url, UriKind.Absolute);
    //Must be on QueuedTask!
    
    var createParams = new FeatureLayerCreationParams(uri)
    {
      IsVisible = false
    };
    var streamLayer = LayerFactory.Instance.CreateLayer<StreamLayer>(
                        createParams, map);
    //Define the unique values by hand
    var uvr = new CIMUniqueValueRenderer()
    {
      Fields = new string[] { "ACTYPE" },
      UseDefaultSymbol = true,
      DefaultLabel = "Others",
      DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol(
                  CIMColor.CreateRGBColor(185, 185, 185), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
    };
    
    var classes = new List<CIMUniqueValueClass>();
    //add in classes - one for ACTYPE of 727, one for DC 9
    classes.Add(
      new CIMUniqueValueClass() {
            Values = new CIMUniqueValue[] {
                  new CIMUniqueValue() { FieldValues = new string[] { "B727" } } },
            Visible = true,
            Label = "Boeing 727",
            Symbol = SymbolFactory.Instance.ConstructPointSymbol(
                  ColorFactory.Instance.RedRGB, 10, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
    });
    classes.Add(
      new CIMUniqueValueClass()
      {
        Values = new CIMUniqueValue[] {
                  new CIMUniqueValue() { FieldValues = new string[] { "DC9" } } },
        Visible = true,
        Label = "DC 9",
        Symbol = SymbolFactory.Instance.ConstructPointSymbol(
                  ColorFactory.Instance.GreenRGB, 10, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
      });
    //add the classes to a group
    var groups = new List<CIMUniqueValueGroup>()
    {
      new CIMUniqueValueGroup() {
         Classes = classes.ToArray()
      }
    };
    //add the groups to the renderer
    uvr.Groups = groups.ToArray();
    //Apply the renderer (for current observations)
    streamLayer.SetRenderer(uvr);
    streamLayer.SetVisibility(true);//turn on the layer
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also