CIMPolygonSymbol ConstructPolygonSymbol( CIMColor color )
Overloads Function ConstructPolygonSymbol( _ ByVal color As CIMColor _ ) As CIMPolygonSymbol
Parameters
- color
- ArcGIS.Core.CIM.CIMColor
CIMPolygonSymbol ConstructPolygonSymbol( CIMColor color )
Overloads Function ConstructPolygonSymbol( _ ByVal color As CIMColor _ ) As CIMPolygonSymbol
{
CIMPolygonSymbol polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB);
//Get symbol reference from the symbol
CIMSymbolReference symbolReference = polySymbol.MakeSymbolReference();
}
{
var mapWithClip = MapView.Active.Map;
await QueuedTask.Run(() =>
{
//If clipping is set to ArcGIS.Core.CIM.ClippingMode.None or ArcGIS.Core.CIM.ClippingMode.MapSeries null is returned
//If clipping is set to ArcGIS.Core.CIM.ClippingMode.MapExtent the ArcGIS.Core.CIM.CIMMap.CustomFullExtent is returned.
//Otherwise, if clipping is set to ArcGIS.Core.CIM.ClippingMode.CustomShape the custom clip polygon is returned.
var poly = mapWithClip.GetClipGeometry();
//You can use the polygon returned
//For example: We make a polygon graphic element and add it to a Graphics Layer.
var gl = mapWithClip.GetLayersAsFlattenedList().OfType<GraphicsLayer>().FirstOrDefault();
if (gl == null)
{
return;
}
var polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(CIMColor.CreateRGBColor(255, 255, 0));
var cimGraphicElement = new CIMPolygonGraphic
{
Polygon = poly,
Symbol = polygonSymbol.MakeSymbolReference()
};
gl.AddElement(cimGraphicElement);
});
}
{
await QueuedTask.Run(() =>
{
//Place a polygon symbol using the mapview extent geometry
var extent = mapView.Extent;
//Contract the extent
var polygonEnv = extent.Expand(-100000, -90000, false);
//create a polygon using the envelope
var polygon = PolygonBuilderEx.CreatePolygon(polygonEnv);
//specify a symbol
var poly_symbol = SymbolFactory.Instance.ConstructPolygonSymbol(
ColorFactory.Instance.GreenRGB);
//create a CIMGraphic
var graphic = new CIMPolygonGraphic()
{
Symbol = poly_symbol.MakeSymbolReference(),
Polygon = polygon,
};
graphicsLayer.AddElement(graphic);
});
}
/// <summary> /// Renders a feature layer using graduated colors and manual intervals to draw quantities. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.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"); } //Change these class breaks to be appropriate for your data. These class breaks defined below apply to the US States feature class List<CIMClassBreak> listClassBreaks = new List<CIMClassBreak> { new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB).MakeSymbolReference(), UpperBound = 24228 }, new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreenRGB).MakeSymbolReference(), UpperBound = 67290 }, new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlueRGB).MakeSymbolReference(), UpperBound = 121757 }, new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB).MakeSymbolReference(), UpperBound = 264435 }, new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.WhiteRGB).MakeSymbolReference(), UpperBound = 576594 } }; CIMClassBreaksRenderer cimClassBreakRenderer = new CIMClassBreaksRenderer { ClassBreakType = ClassBreakType.GraduatedColor, ClassificationMethod = ClassificationMethod.Manual, Field = "NumericFieldInLayer", //Important to add the Minimum break for your data to be classified correctly. //This is vital especially if you have data with negative values. //MinimumBreak = Breaks = listClassBreaks.ToArray() }; await QueuedTask.Run(() => featureLayer?.SetRenderer(cimClassBreakRenderer)); }
/// <summary> /// Create a procedural symbol that can be applied to a polygon building footprint layer ///  /// Note: The rule package used in this method can be obtained from the Sample Data included in the arcgis-pro-sdk-community-samples repository. /// </summary> { //Note: Run withing QueuedTask string _rulePkgPath = @"C:\Data\RulePackages\Venice_2014.rpk"; //Polygon symbol to hold the procedural layer var proceduralSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(); //Array of layers to hold a procedural symbol layer CIMSymbolLayer[] proceduralSymbolLyr = { new CIMProceduralSymbolLayer() { PrimitiveName = "Venice Rule package 2014", RulePackage = _rulePkgPath, RulePackageName = "Venice_2014", } }; proceduralSymbol.SymbolLayers = proceduralSymbolLyr; //To apply the symbol to a polygon feature layer //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer; //renderer.Symbol = proceduralSymbol.MakeSymbolReference(); //theLayer.SetRenderer(renderer); }
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)