

Public Class CIMSimpleRenderer Inherits CIMRenderer Implements System.ComponentModel.INotifyPropertyChanged, System.Xml.Serialization.IXmlSerializable
public class CIMSimpleRenderer : CIMRenderer, System.ComponentModel.INotifyPropertyChanged, System.Xml.Serialization.IXmlSerializable
{
//Note: Needs QueuedTask to run
//Get simple renderer from the feature layer
CIMSimpleRenderer currentRenderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
if (currentRenderer == null)
return;
//Set symbol's real world setting to be the same as that of the feature layer
symbol.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes);
//Update the symbol of the current simple renderer
currentRenderer.Symbol = symbol.MakeSymbolReference();
//Update the feature layer renderer
featureLayer.SetRenderer(currentRenderer);
}
{
//Note: Needs QueuedTask to run
//Get simple renderer from the feature layer
CIMSimpleRenderer currentRenderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
if (currentRenderer == null)
return;
//Get symbol from the SymbolStyleItem
CIMSymbol symbolToApply = symbolStyleItem.Symbol;
//Set symbol's real world setting to be the same as that of the feature layer
symbolToApply.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes);
//Update the symbol of the current simple renderer
currentRenderer.Symbol = symbolToApply.MakeSymbolReference();
//Update the feature layer renderer
featureLayer.SetRenderer(currentRenderer);
}
/// <summary> /// Renders a Polygon feature layer using a single symbol. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Creating a polygon with a red fill and blue outline. CIMStroke outline = SymbolFactory.Instance.ConstructStroke( ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid); CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol( ColorFactory.Instance.CreateRGBColor(255, 190, 190), SimpleFillStyle.Solid, outline); //Get the layer's current renderer //Note: Run within QueuedTask CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; //Update the symbol of the current simple renderer renderer.Symbol = fillWithOutline.MakeSymbolReference(); //Update the feature layer renderer featureLayer.SetRenderer(renderer); }
/// <summary> /// Renders a Point feature layer using a single symbol. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.ShapeType == esriGeometryType.esriGeometryPoint); if (featureLayer == null) { MessageBox.Show("This renderer works with a point feature layer", "Data missing"); } //Create a circle marker var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 8, SimpleMarkerStyle.Circle); //Get the layer's current renderer //Note: Run within QueuedTask CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; //Update the symbol of the current simple renderer renderer.Symbol = pointSymbol.MakeSymbolReference(); //Update the feature layer renderer featureLayer.SetRenderer(renderer); }
/// <summary> /// Renders a Line feature layer using a single symbol. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways"); if (featureLayer == null) { MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Create a circle marker var lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 2, SimpleLineStyle.DashDotDot); //Get the layer's current renderer //Note: Run within QueuedTask CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; //Update the symbol of the current simple renderer renderer.Symbol = lineSymbol.MakeSymbolReference(); //Update the feature layer renderer featureLayer.SetRenderer(renderer); }
/// <summary> /// Renders a Line feature layer using a style from a StyleProjectItem. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways"); if (featureLayer == null) { MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Get all styles in the project var styleProjectItem2D = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D"); //Get a specific style in the project by name var arrowLineSymbol = styleProjectItem2D.SearchSymbols(StyleItemType.LineSymbol, "Arrow Line 2 (Mid)")[0]; if (arrowLineSymbol == null) return; //Note: Run within QueuedTask //Get the layer's current renderer var renderer = featureLayer?.GetRenderer() as CIMSimpleRenderer; //Update the symbol of the current simple renderer renderer.Symbol = arrowLineSymbol.Symbol.MakeSymbolReference(); //Update the feature layer renderer featureLayer.SetRenderer(renderer); }
System.Object
ArcGIS.Core.CIM.CIMObject
ArcGIS.Core.CIM.CIMRenderer
ArcGIS.Core.CIM.CIMSimpleRenderer
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)