Symbol layer drawing using the Arc GIS Pro SDK for .NET

1211
3
06-24-2021 06:02 AM
JFr87
by
New Contributor II

Hi,

I have two questions regarding the Symbol Layer Drawing using the Arc GIS Pro SDK for .NET:

  1. How do you enable the Symbol Layer Drawing (equivalent to the marked setting below)?
  2. I want to set the drawing order of symbols in a group layer, like in the Screenshot below. Background: there are multiple occasions where some symbols overlap other symbols. Changing the order of the layer in this group layer is no solution. If I try this, then other symbols are not visible anymore.
    Therefore, I want to set the drawing order for the symbols. Is there a way to achieve this by using the ArcGIS Pro SDK?

JFr87_0-1624539564733.png

Thanks in advance.

0Kudos
3 Replies
CharlesMacleod
亚博搜索yabovip28点com

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 isnotsomething 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 drawingconfigured(eg using one of the two techniques I mentioned above) - you can enable/disable it using the following code below:

在我的例子中,我系紧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().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 } }); }

:

melihgüldaş
New Contributor

can you update code to 3.0 how can use advanced masked layer at code with mask layer and masked layer defining

0Kudos
JFr87
by
New Contributor II

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.

0Kudos