Select to view content in your preferred language

Refresh Graphics after Renderer Change

3179
2
09-12-2012 06:40 AM
KeithSandell
Regular Contributor
I have graphics layer who's symbology is set by default using a SimpleRenderer.

Upon applying a UniqueValueRenderer to the graphics layer I confirmed in Firebug it took...

The docs do not show, but Firebug does show a .refresh() method for the graphicsLayer. I tried this, but it doesn't work.

How do I get the layer's display to update with the new symbology?
0 Kudos
2 Replies
derekswingley1
Deactivated User
Please post the code you're using to specify the new renderer.
0 Kudos
KeithSandell
Regular Contributor
I found the problem.

The docs show that the defaultSymbology for the UniqueValueRenderer is "optional" so I did not provide one as I am capturing and using all possible values in the target attributeField(s).

So I only passed the attributeField name into the new renderer, but by doing this the graphicsLayer renderFields property was not updating.

I added a place holder for the default symbology ("") and passed it in with the attributeField to make it work.

The refresh method was working all along, but it couldn't apply symbology to an undefined attributeField, duh.

Guess the gotcha here was that the defaultSymbology is not really, really optional; you have to pass something in its places so that the required attributeField is read correctly.
0 Kudos