public CIMSymbolReference Symbol {get; set;}
Public Property Symbol As CIMSymbolReference
public CIMSymbolReference Symbol {get; set;}
Public Property Symbol As CIMSymbolReference
public Task SetFeatureLayerSymbolFromStyleItemAsync( FeatureLayer ftrLayer, SymbolStyleItem symbolItem) { if (ftrLayer == null || symbolItem == null) throw new System.ArgumentNullException(); return QueuedTask.Run(() => { //Get simple renderer from the feature layer CIMSimpleRenderer currentRenderer = ftrLayer.GetRenderer() as CIMSimpleRenderer; if (currentRenderer == null) return; //Get symbol from the SymbolStyleItem CIMSymbol symbol = symbolItem.Symbol; //Set symbol's real world setting to be the same as that of the feature layer symbol.SetRealWorldUnits(ftrLayer.UsesRealWorldSymbolSizes); //Update the symbol of the current simple renderer currentRenderer.Symbol = symbol.MakeSymbolReference(); //Update the feature layer renderer ftrLayer.SetRenderer(currentRenderer); }); }
// var map = MapView.Active.Map; // if (map == null) // return; // var pointFeatureLayer = // map.GetLayersAsFlattenedList() // .OfType<FeatureLayer>() // .Where(fl => fl.ShapeType == esriGeometryType.esriGeometryPoint); // await ApplySymbolToFeatureLayerAsync(pointFeatureLayer.FirstOrDefault(), "Fire Station"); public Task ApplySymbolToFeatureLayerAsync(FeatureLayer featureLayer, string symbolName) { return QueuedTask.Run(async () => { //Get the ArcGIS 2D System style from the Project var arcGIS2DStyle = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D"); //Search for the symbolName style items within the ArcGIS 2D style project item. var items = await QueuedTask.Run(() => arcGIS2DStyle.SearchSymbols(StyleItemType.PointSymbol, symbolName)); //Gets the CIMSymbol CIMSymbol symbol = items.FirstOrDefault().Symbol; //Get the renderer of the point feature layer CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; //Set symbol's real world setting to be the same as that of the feature layer symbol.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes); //Apply the symbol to the feature layer's current renderer renderer.Symbol = symbol.MakeSymbolReference(); //Appy the renderer to the feature layer featureLayer.SetRenderer(renderer); }); }
public async Task ApplyColorRampAsync(FeatureLayer featureLayer, List<string> fields) { StyleProjectItem style = Project.Current.GetItems<StyleProjectItem>() .FirstOrDefault(s => s.Name == "ColorBrewer Schemes (RGB)"); if (style == null) return; var colorRampList = await QueuedTask.Run(() => style.SearchColorRamps("Red-Gray (10 Classes)")); if (colorRampList == null || colorRampList.Count == 0) return; CIMColorRamp cimColorRamp = null; CIMRenderer renderer = null; await QueuedTask.Run(() => { cimColorRamp = colorRampList[0].ColorRamp; var rendererDef = new UniqueValueRendererDefinition(fields, null, cimColorRamp); renderer = featureLayer?.CreateRenderer(rendererDef); featureLayer?.SetRenderer(renderer); }); }
Target Platforms: Windows 11, Windows 10, Windows 8.1