Select to view content in your preferred language

Temporary symbol for a graphic in Feature Layer

581
1
11-11-2011 12:58 PM
OrlandoCarvajal
Deactivated User
Hi there,

I have a point feature layer in my map; the renderer defined in the MXD and Map Service is a Unique Value renderer. In a particular case, I want to have one single point to be drawn with a different symbol during a specific process, and then have the symbol set back to be drawn by the default renderer. So this is what I do:
I set: RendererTakesPrecedence="False" in XAML.
I set the symbol on the graphic (which is originally NULL):
myGraphic.Symbol = new SimpleMarkerSymbol()
     {
          Style = SimpleMarkerSymbol.SimpleMarkerStyle.Diamond,
          Size = 8,
          Color = new SolidColorBrush(Colors.Green)
      };

A zoom to the point takes place at the same moment and the new symbol is displayed correctly.
Later on I finish my process and I set the Symbol of the graphic back to null:
myGraphic.Symbol = null;
myPointLayer.Refresh();

Note that I had to call Refresh on the layer. Then the original symbol generated from the renderer is displayed.
The problem occurs the next time I want to assign the custom symbol on the same graphic: it just doesn't get displayed and the point dissapears completely from the map. Calling Refresh() after setting the symbol doesn't help. When I set the symbol back to null it shows up again as expected. If I try a different graphic, same thing happens; this is: I can only see the custom symbol the first time I use it on a particular graphic.
Am I supposed to do something else or is it a bug?

Thanks in advance for any help. Cheers,
Orlando
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
We have a work item for RendererTakesPrecedence=False not respected when graphic.Symbol is null. At this point, your graphic must already have a symbol before you set RendererTakesPrecedence to false.

If your UniqueValueRenderer has a DefaultSymbol defined and your graphic.Attribute does not match any of the UniqueValueInfo.Value, the graphic will use DefaultSymbol. You can try this with the following SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#RenderersXAML. Comment one of the UniqueValueInfo and replace with DefaultSymbol. In this solution, you can set graphic.Attribute to a value that will make it fall back to default symbol. When you're ready to have the graphic use the service-defined symbol, update its attribute.

Another approach is to use GraphicsLayer above your FeatureLayer. Your GraphicsLayer can have a SimpleRenderer with the symbol you use for this specific case. When you're ready to have the graphic use the service-defined renderer, you can add the graphic to your FeatureLayer and remove the temporary GraphicsLayer above it.
0 Kudos