Select to view content in your preferred language

Unique Value Rendering based on joined attributes

2059
2
Jump to solution
11-16-2012 06:12 AM
YogeshKhandelwal
New Contributor
Hello,
I am trying to apply the examples:

http://help.arcgis.com/en/webapi/silverlight/3.0/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.ArcGIS...
http://help.arcgis.com/en/webapi/silverlight/3.0/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.ArcGIS...
http://help.arcgis.com/en/webapi/silverlight/3.0/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.LayerD...

to the my situation.  I would like to create a color scheme for a feature class exposed through a service based on a set of data located in a separate table.  I've tried several iterations of solutions just to try and make it work and the one the came closest was when I I created a join through arcmap to expose the data through the feature class attributes then created a dynamic layer and assigned it a unique value renderer that pointed at the desired joined attribute in the feature service.  But by having the joined attribute exposed through the service it seems to break the unique value renderer to where it will only use the default symbol...  I've confirmed the code below works when I remove the join from the service and base the renderer on a different attribute.

Is there something I'm missing?  Is there a better approach given this scenario?  Any help would be greatly appreciated.
Thanks! djordan

        void SetImportedMapRenderers(Layer _importedLayer)         {             // Get the ArcGISDynamicMapServiceLayer that was defined in XAML but not shown visually in the Map.             ArcGISDynamicMapServiceLayer importedLayer = (ArcGISDynamicMapServiceLayer)(_importedLayer);              // Create a new DynamicLayerInfoCollection based upon the existing ArcGISDynamicMapServiceLayer.             DynamicLayerInfoCollection layerInfoCollection = importedLayer.CreateDynamicLayerInfosFromLayerInfos(); //myCREATED_DynamicLayerInfoCollection              // Loop through each DynamicLayerInfo object (i.e. sub-layer information about the ArcGISDynamicMapServiceLayer)             foreach (DynamicLayerInfo dlInfo in layerInfoCollection)             {                 // Get the ID of the sub-layer.                 int myID = dlInfo.ID;                 // Get the name of the sub-layer.                 string subLayerName = dlInfo.Name;                  LayerSource dlInfoSource = dlInfo.Source;                 if (dlInfoSource is LayerMapSource)                 {                     // We are only interested in the 'Counties' sub-layer for this sample code.                     if (Regex.IsMatch(subLayerName, "parcel", RegexOptions.IgnoreCase))                     {                         // Create a new DynamicLayerInfo object (i.e. the container for the new Dynamic Layer)                         DynamicLayerInfo newDynamicLayerInfo = new DynamicLayerInfo();                          //// Base the DynamicLayerInfo Properties on what was published in the 'Counties' sub-layer.                         newDynamicLayerInfo.ID = myID;                         newDynamicLayerInfo.Source = dlInfoSource;                          DynamicLayerInfoCollection newDynamicLayerInfoCollection = new DynamicLayerInfoCollection();                         newDynamicLayerInfoCollection.Add(newDynamicLayerInfo);                          ArcGISDynamicMapServiceLayer newLayer = new ArcGISDynamicMapServiceLayer();                         newLayer.InitializationFailed += newArcGISDynamicMapServiceLayer_InitializationFailed;                         newLayer.Initialized += newArcGISDynamicMapServiceLayer_Initialized;                         newLayer.ID = importedLayer.ID;                         newLayer.DisplayName = importedLayer.DisplayName;                         newLayer.Url = importedLayer.Url;                         newLayer.DisableClientCaching = true;                         newLayer.DynamicLayerInfos = newDynamicLayerInfoCollection;                          // Use Rendering that is defined here on the client-side.                         SimpleFillSymbol defaultSym = new SimpleFillSymbol()                         {                             BorderBrush = new SolidColorBrush(Colors.Green),                             BorderThickness = 3.0,                             Fill = new SolidColorBrush(Colors.LightGray)                         };                         SimpleFillSymbol defaultSym1 = new SimpleFillSymbol()                         {                             BorderBrush = new SolidColorBrush(Colors.Orange),                             BorderThickness = 3.0,                             Fill = new SolidColorBrush(Colors.Magenta)                         };                         SimpleFillSymbol defaultSym2 = new SimpleFillSymbol()                         {                             BorderBrush = new SolidColorBrush(Colors.Blue),                             BorderThickness = 3.0,                             Fill = new SolidColorBrush(Colors.Purple)                         };                         SimpleFillSymbol defaultSym3 = new SimpleFillSymbol()                         {                             BorderBrush = new SolidColorBrush(Colors.Purple),                             BorderThickness = 3.0,                             Fill = new SolidColorBrush(Colors.Blue)                         };                         SimpleFillSymbol defaultSym4 = new SimpleFillSymbol()                         {                             BorderBrush = new SolidColorBrush(Colors.DarkGray),                             BorderThickness = 3.0,                             Fill = new SolidColorBrush(Colors.Brown)                         };                         SimpleFillSymbol defaultSym5 = new SimpleFillSymbol()                         {                             BorderBrush = new SolidColorBrush(Colors.Red),                             BorderThickness = 3.0,                             Fill = new SolidColorBrush(Colors.Yellow)                         };                         SimpleFillSymbol defaultSym6 = new SimpleFillSymbol()                         {                             BorderBrush = new SolidColorBrush(Colors.Black),                             BorderThickness = 3.0,                             Fill = new SolidColorBrush(Colors.Red)                         };                         // Create a new SimpleRenderer based up the SimpleFillSymbol.                          SimpleRenderer newSimpleRenderer = new SimpleRenderer();                         newSimpleRenderer.Symbol = defaultSym6;                          UniqueValueRenderer uvr = new UniqueValueRenderer();                         uvr.DefaultSymbol = defaultSym;                         uvr.Field = "Status_Name"; // THIS IS THE ATTRIBUTE EXPOSED THROUGH THE JOIN                         uvr.Infos.Add(new UniqueValueInfo()                         {                             Symbol = defaultSym1,                             Value = "Granted",                             Label = "Granted"                         });                         uvr.Infos.Add(new UniqueValueInfo()                         {                             Symbol = defaultSym2,                             Value = "Court Granted",                             Label = "Court Granted"                         });                         uvr.Infos.Add(new UniqueValueInfo()                         {                             Symbol = defaultSym3,                             Value = "No Letter Sent",                             Label = "No Letter Sent"                         });                         uvr.Infos.Add(new UniqueValueInfo()                         {                             Symbol = defaultSym4,                             Value = "LS",                             Label = "LS"                         });                         uvr.Infos.Add(new UniqueValueInfo()                         {                             Symbol = defaultSym5,                             Value = "Pending",                             Label = "Pending"                         });                         uvr.Infos.Add(new UniqueValueInfo()                         {                             Symbol = defaultSym6,                             Value = "EXP",                             Label = "EXP"                         });                         LayerDrawingOptions newLayerDrawingOptions = new LayerDrawingOptions();                         newLayerDrawingOptions.LayerID = myID;                         newLayerDrawingOptions.Renderer = uvr;                          // Create a new LayerDrawinOptionsCollection and add the LayerDraingOptions object into it.                         LayerDrawingOptionsCollection newLayerDrawingOptionsCollection = new LayerDrawingOptionsCollection();                         newLayerDrawingOptionsCollection.Add(newLayerDrawingOptions);                          // Apply the custom Rendering for the Dynamic Layer.                         newLayer.LayerDrawingOptions = newLayerDrawingOptionsCollection;                         ApprovedImportedLayers.ChildLayers.Add(newLayer);                     }                     else                     {}                     importedLayer.Visible = true;                 }             }         }
0 Kudos
1 Solution

Accepted Solutions
YogeshKhandelwal
New Contributor
Hi,

Is there a reason that you can't render the data in the service via ArcMap instead of on the client?  I have done that sucessfully with a joined table.  It seems much simpler.

Chris


Hi, this is something that I had considered but I need to have the ability to dynamically set the styles based on various data points.  I actually found what the issue was....  when exposing joined attributes through a service the field names change from the "short version"  (i.e.  Field1) to a "fully qualified version" (i.e.  geoDB.sde.Table1.Field1)   So in my case I just needed to specify the database and table name as a prefix delimited by a period...

View solution in original post

0 Kudos
2 Replies
ChrisBradberry
Occasional Contributor
Hi,

Is there a reason that you can't render the data in the service via ArcMap instead of on the client?  I have done that sucessfully with a joined table.  It seems much simpler.

Chris
0 Kudos
YogeshKhandelwal
New Contributor
Hi,

Is there a reason that you can't render the data in the service via ArcMap instead of on the client?  I have done that sucessfully with a joined table.  It seems much simpler.

Chris


Hi, this is something that I had considered but I need to have the ability to dynamically set the styles based on various data points.  I actually found what the issue was....  when exposing joined attributes through a service the field names change from the "short version"  (i.e.  Field1) to a "fully qualified version" (i.e.  geoDB.sde.Table1.Field1)   So in my case I just needed to specify the database and table name as a prefix delimited by a period...
0 Kudos