Select to view content in your preferred language

feature layer not  binding to the Unique Value renderer

3385
9
02-07-2011 06:06 AM
JaskiratAnand
Emerging Contributor
I have a feature layer which i'm binding to a unique value renderer in the xaml file. the result is that nothing comes up on the map. have tried to bind the unique value renderer in the xaml.cs file also on layer initialization complete event also but no result on the map. I took the xaml code from the ESRI resources help section but it doesn't seem to work. Also, i already have a unique value renderer on this layer in the Map document that I created using the ArcMap. i'm trying to change the rendering depending on user preference.
Any help is welcome.
0 Kudos
9 Replies
JenniferNery
Esri Regular Contributor
Does your UniqueValueRenderer define a DefaultSymbol? Do the features get the DefaultSymbol atleast?

Maybe the graphic.Attribute value does not match any of the UniqueValueInfo.Value. The values must have the same data type.

I tried the following code for this layerhttp://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer/0

For simplicity, I have only one UniqueValueInfo. Graphics whose ftype attribute do not match my UniqueValueInfo.Value will get the default symbol.
<esri:UniqueValueRenderer  x:Key="MyRenderer" Attribute="ftype">
 <esri:UniqueValueRenderer.DefaultSymbol>
  <esri:SimpleMarkerSymbol Color="Blue" Size="10" Style="Circle"/>
 </esri:UniqueValueRenderer.DefaultSymbol>
 <esri:UniqueValueInfo >
  <esri:UniqueValueInfo.Value>
   <sys:Int32>10901</sys:Int32>  </esri:UniqueValueInfo.Value>
  <esri:UniqueValueInfo.Symbol>
   <esri:SimpleMarkerSymbol Color="Yellow" Size="10" Style="Diamond"/>
  </esri:UniqueValueInfo.Symbol>
 </esri:UniqueValueInfo>   
</esri:UniqueValueRenderer>
0 Kudos
JaskiratAnand
Emerging Contributor
Using the below code in my xaml file. The "LEASELEFT" attribute is a numeric field in Oracle db. The spatial data is of type polygon. Only the default symbolgy comes on the feature layer, however, I have atleast 75 shapes with attribute LEASELEFT having value 1.

<esri:UniqueValueRenderer x:Name="UniqueValueRenderer" Attribute="LEASELEFT" >
<esri:UniqueValueRenderer.DefaultSymbol>
<esriSymbols:SimpleFillSymbol Fill="Blue" BorderBrush="Green" BorderThickness="2"/>
</esri:UniqueValueRenderer.DefaultSymbol>
<esri:UniqueValueInfo >
<esri:UniqueValueInfo.Value>
<sys:Int32>1</sys:Int32>
</esri:UniqueValueInfo.Value>
<esri:UniqueValueInfo.Symbol>
<esriSymbols:SimpleFillSymbol Fill="Red" BorderBrush="Green" BorderThickness="2"/>
</esri:UniqueValueInfo.Symbol>
</esri:UniqueValueInfo>
</esri:UniqueValueRenderer>


finally binding it to the feature layer
<esri:FeatureLayer ID="MyFeatureLayer" Url="Map layer url" Renderer="{StaticResource UniqueValueRenderer}" />
0 Kudos
JenniferNery
Esri Regular Contributor
So did that work for you? Do your features get a symbol now?
0 Kudos
JaskiratAnand
Emerging Contributor
no it does not work. I mentioned in my previous reply also that only default symbology comes on the map. there are 75 other shapes with LEASELEFT value of 1, they don't get the desired symbology.
0 Kudos
JenniferNery
Esri Regular Contributor
Can you subscribe to UpdateCompleted event and then check each graphic attribute LEASELEFT? If this value is null, make sure that OutFields in the FeatureLayer include this attribute. Otherwise, check the data type, make sure it matches your UniqueValueInfo.Value. It's actually good that your UniqueValueRenderer.DefaultSymbol is now used. You just need to find out why the UniqueValueInfo.Symbol is not picked up. The symbol should also be fitting for the geometry type. Since you are using SimpleFillSymbol, the features must be polygon geometry.
0 Kudos
JaskiratAnand
Emerging Contributor
double checked all the points mentioned Jennifer, the data is not null for the attribute LEASELEFT. the data type is numeric if Oracle db 10g and I'm using int32 in my unique value renderer for it. any new pointers will be very helpful
0 Kudos
JenniferNery
Esri Regular Contributor
I'm not sure what else to tell you. Maybe the numeric value is a double not an integer?

You can create a class that implements IRenderer with UniqueValueRenderer (UVR) as one of its properties. Use this renderer for your layer instead so you can debug where it may be failing.


You can implement GetSymbol() this way. Step through when it fails to find a matching info.
public Symbol GetSymbol(Graphic graphic)
{
 if (graphic != null && UVR.Attribute != null)
 {
  if (graphic.Attributes.ContainsKey(UVR.Attribute))
  {
   object objValue = graphic.Attributes[UVR.Attribute];
   foreach (UniqueValueInfo info in UVR.Infos)
   {
    if (info.Value == objValue || objValue != null && info.Value != null && objValue.GetHashCode() == info.Value.GetHashCode())
     return info.Symbol;
   }
  }
 }
 return UVR.DefaultSymbol;
}
0 Kudos
JaskiratAnand
Emerging Contributor
thanks for the quick response. will try the class implementation logic and hope it works.
thanks for all the help Jennifer 🙂
0 Kudos
RobChouinard
Frequent Contributor
Sorry to bring up an old thread. I had this same problem also and just solved it. To clarify, my problem was I had a feature layer with a unique value renderer and the only symbol being displayed was the default symbol.

Looking at the rest service details on a browser, I saw all my fields were uppercase and under "unique value renderer" my "field 1" was lowercase.

What I did was open the related map, removed the layer, added the layer back in and rebuild the symbology from scratch, saved, restarted my map service, cleared my rest cache and voila! My unique value renderer - field 1 is now uppercase and my feature layer displays correctly. So it appears in ArcMap renderer fields are not case sensitive (I don't know how it got to be lowercase to begin with), but in Silverlight they ARE case sensitive.

Hope this helps people who come across the same problem.
0 Kudos