Frm cim-spec/docs/v3/Overview-Symbols.md at main · Esri/cim-spec (github.com), I can read the number and properties of symbol and symbol layers. However, how to add a symbol or symbol layer of an existing symbolic system in a layer with SDK?
Hi,
Are you looking to add a new class break to a Unique Value renderer? If so, here is a code snippet:
var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(); if (layer == null) return; QueuedTask.Run( () => { var uvr = layer.GetRenderer() as CIMUniqueValueRenderer; if (uvr == null) return; var cimUniqueValueGroup = uvr.Groups[0] as CIMUniqueValueGroup; var classes = cimUniqueValueGroup.Classes; var cimUniqueValueClass = new CIMUniqueValueClass(); cimUniqueValueClass.Label = "New Value"; var lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 2.0, SimpleLineStyle.Solid) ; lineSymbol.UseRealWorldSymbolSizes = false; cimUniqueValueClass.Symbol = lineSymbol.MakeSymbolReference(); #region New value to the class var cimUniqueValues = new List<CIMUniqueValue>(); var cimUniqueValue = new CIMUniqueValue() { FieldValues = new string[] { "New Value" } }; cimUniqueValues.Add(cimUniqueValue); #endregion cimUniqueValueClass.Values = cimUniqueValues.ToArray(); cimUniqueValueClass.Visible = true; var classesList = classes.ToList(); classesList.Add(cimUniqueValueClass); cimUniqueValueGroup.Classes = classesList.ToArray(); uvr.Groups[0] = cimUniqueValueGroup; layer.SetRenderer(uvr); });
Regarding your second question, if you are looking to add a new Symbol layer to an existing symbol, this is the code snippet:
var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault( s => s.ShapeType == esriGeometryType.esriGeometryPolyline); QueuedTask.Run( () => { var simpleRenderer = layer.GetRenderer() as CIMSimpleRenderer; var lineSymbol = simpleRenderer.Symbol.Symbol as CIMLineSymbol; if (lineSymbol == null) return; var layers = lineSymbol.SymbolLayers; var solidStroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2.0, SimpleLineStyle.Solid); var offSetEffect = new CIMGeometricEffectOffset() { Method = GeometricEffectOffsetMethod.Rounded, Offset = 3, Option = GeometricEffectOffsetOption.Fast }; solidStroke.Effects = new CIMGeometricEffect[] { offSetEffect }; var layersList = layers.ToList(); layersList.Add(solidStroke); lineSymbol.SymbolLayers = layersList.ToArray(); simpleRenderer.Symbol = lineSymbol.MakeSymbolReference(); layer.SetRenderer(simpleRenderer); });
For example, if there is a symbol system represented by a unique value, I programmed a CIMLineSymbol variable. How to add it and generate a new line in this table.
Also, when I programmed a CIMSymbolLayer variable, how to add it to the above table as a new line?
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.