Hi,
I have two questions regarding the Symbol Layer Drawing using the Arc GIS Pro SDK for .NET:
Thanks in advance.
We do not have support for this directly in the public API and, as a minimum, I think we can add enabling/disabling symbol layer drawing, SLD, to the public API at 2.9.
_Configuring_ drawing order by symbol layer is not trivial and is not something that really should be attempted via the public API and the CIM - though it is possible - the code would be very brittle. Any change to the symbology, eg changing a feature symbol definition or altering a unique value class, for example, could break any add-in code that was making assumptions about the structure of a given layer's symbology and renderer.
I recommend that you continue to configure the SLD order using the UI and when you have the symbology configured to your liking, save the layer out as a layer file (.lyrx).
It is a straightforward process to read the layer file via the API and apply the renderer with the correct SLD defined to an existing layer of the same schema - ProSnippet: Apply Symbology to a layer from a Layer file, - or to simply create a new layer based off the layer file - ProSnippet: Create layer from a lyrx file
Meanwhile, in lieu of having a dedicated public API method to enable/disable SLD, assuming that you do have a layer with symbol layer drawing configured (eg using one of the two techniques I mentioned above) - you can enable/disable it using the following code below:
In my example, I am toggling SLD on/off for a feature layer called "rivers". However, in my testing of this code, even though SLD was being toggled on the layer, the symbology UI did _not_ update the "Enable symbol layer drawing" check box on the SLD pane. So we have a bug in Pro there that we also need to address. Please be aware of that. I am using Pro version 2.8.
protected override void OnClick()
{
var rivers = MapView.Active.Map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().FirstOrDefault(l => l.Name == "rivers");
if (rivers == null)
return;
QueuedTask.Run(() =>
{
var def = rivers.GetDefinition() as CIMFeatureLayer;
//def.SymbolLayerDrawing will be null if symbol layer drawing has not
//previously been configured
if (def.SymbolLayerDrawing != null)
{
//toggle symbol layer drawing on/off
//TODO: Bug in UI. "Enable symbol layer drawing" checkbox does not update
def.SymbolLayerDrawing.UseSymbolLayerDrawing = !def.SymbolLayerDrawing.UseSymbolLayerDrawing;
rivers.SetDefinition(def);//commit
}
});
}
:
can you update code to 3.0 how can use advanced masked layer at code with mask layer and masked layer defining
Thanks for the reply.
The code snippet will be useful for my add-in.
For the answer to my second question, i'll have to talk to some collegues about how to move on in this regard. Perhaps there will be another question by me to this topic in the near future (the next two weeks or so), so I like leave this post open for a while.