UniqueValueRenderer, change attributes at runtime

410
2
01-16-2019 03:11 AM
MarcoGregorini
New Contributor II

Hello, I'm using ArcGIS Runtime SDK for Qt 100.3 and UniqueValueRenderer to render Graphic in a GraphicsOverlay. Each graphic has two state, depending on two attributes (the first is fixed, the second can change), so I added the corresponding UniqueValues with the appropriate symbols for the two state. When I add the graphic to the GraphicsOverlay the right symbol is displayed, but if I change at runtime the second attribute the graphic symbol is not updated. I tried to replace the attributes (graphic->attributes()->replaceAttribute("selected", "true");) and to save the attributes as a map, change the required attribute, remove all attributes and add them with setAttributesMap(), but the symbol is not updated. The UniqueValues are correct; if I set the attributes  when I add the graphic, the right symbol is displayed.

Is this by design? Is there a way to force the renderer to redraw the symbol when the attribute change?

Thanks.

Marco

0 Kudos
2 Replies
TroyFoster
Occasional Contributor

After you replace the attribute you need to call updateFeature on the feature.

{code}

theFeature->featureTable()->updateFeature(theFeature);

{code}

If it is a point or multipoint layer which is used to display text you might need to call setDefinitionExpression on the layer again to "jiggle the handle" to get it to reapply the clause.

0 Kudos
MarcoGregorini
New Contributor II

Thanks Troy, but I'm using a GraphicsOverlay, not a FeatureLayer, so I'm afraid your tip is not applicabile. I solved using the renderer to generate the symbol according to the attributes and then set the symbol to the graphic, though if would be better if the UniqueValueRenderer were able to manage the changing of the attributes.

Thanks, Marco

0 Kudos