We are currently trying to optimise some of our code (which uses version 100.10 of the SDK), and the Graphics in particular. We are currently setting the symbol of each Graphic to a PictureMarkerSymbol, which seems to be quite inefficient as suggested by this forum post: https://community.esri.com/t5/arcgis-runtime-sdk-for-net-questions/adding-a-large-number-of-graphics... We have lots of different symbols in our program, but many Graphics are using the same symbol. Each type of Graphic is added to a different graphics overlay.
I have been experimenting with using renderers as suggested by the linked post, but feels like I have hit a dead end. Our Graphics represent things like ships currently sailing, and we need to update the position and rotation of each graphic roughly once per second. I have got a DictionaryRenderer working with attribute dictionaries for the Graphics to start with the correct rotation, but my issue is that I don't see a way of then updating the rotation after the Graphics have been added to the overlay.
Is there a way to get this working? Or is there another approach that would be better for dynamic data visualisation like this?
Solved! Go to Solution.
If all graphics of one graphic overlay use the same symbol, you can use a SimpleRenderer based on your picture marker symbol.
If the symbol is depending on an attribute you can use an UniqueValueRenderer
Then you can set a rotation expression on the renderer to apply a rotation based on an expression. For example, if the expected rotation is coming from an attribute:
renderer.RotationExpression = "[rotation]"
Hi Dominique, thanks for the reply. I have set up the rotation expression as described for my DictionaryRenderer, and I then initialise the Graphic like this:
Dictionary<string, object> attributes = new Dictionary<string, object>(); attributes["ANGLE"] = boat.angle; attributes["Style"] = "BoatImage"; Graphic graphic = new Graphic(boat.Location, attributes); graphicsOverlay.Graphics.Add(graphic);
This correctly sets the rotation, but I don't see how to change the rotation after this. Modifying the attribute dictionary does not seem to have any effect. Am I misunderstanding how the attributes work?
> Graphic does have the Attributes property, but as far as I can tell it has no SetAttributeValue method?
You can use:
myGraphic.Attributes["fieldname"] = newValue;
Looking at you code in your initial post, I see you mentioned you are using a DictionaryRenderer. I think you might be mixing up creating a dictionary of attributes to a DictionaryRenderer.
DictionaryRenderer is a renderer based on arcade script in a stylx file. The stylx file contains symbols and values is published from pro. When this stylx is used to create a dictionary renderer, elements (graphics or features) are rendered sing symbols from this symbol style file based on the attribute value configured in dictionary renderer.