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; } } }
Solved! Go to Solution.
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,
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