ArcGIS Runtime SDK for WPF - Library Reference
LayerDrawingOptions Property
See Also  Example
ESRI.ArcGIS.Client Namespace > ArcGISDynamicMapServiceLayer Class : LayerDrawingOptions Property

Gets or sets the LayerDrawingOptionsCollection used to define the way a Dynamic Layer is drawn.

Syntax

Visual Basic (Declaration) 
Public Property LayerDrawingOptions As LayerDrawingOptionsCollection
C# 
public LayerDrawingOptionsCollection LayerDrawingOptions {get; set;}

Remarks

Dynamic Layers allow the execution of various ArcGIS Server requests from a client application. An in-depth discussion about Dynamic Layers is in the ArcGISDynamicMapServiceLayer Class documentation. The client side requests that can be issued to ArcGIS Server include the ability to:

Dynamic Layers are new in ArcGIS Server v10.1 and require the ArcGIS Runtime SDK 1.0 for WPF and higher.

It is necessary for a Dynamic Layer that will be displayed in a Map Control to have the appropriate Rendering applied. The ArcGISDynamicMapServiceLayer.LayerDrawingOptions Property (which is a LayerDrawingOptionsCollection Class) is used to set the Rendering of each Dynamic Layer. Like the ArcGISDynamicMapServiceLayer.DynamicLayerInfos Property, the ArcGISDynamicMapServiceLayer.LayerDrawingOptions Property is also empty (meaning Nothing/null) when an ArcGISDynamicMapServiceLayer is created in ArcMap and served up via ArcGIS Server.

There is not a specific Method to generate a LayerDrawingOptionsCollection that is pre-populated with existing Rendering options of the sub-layers in an ArcGISDynamicMapServiceLayer similar to the ArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos Method. In order create a new Dynamic Layer using the Rendering of a sub-layer that already exists in an ArcGISDynamicMapServiceLayer, one only needs to specify the DynamicLayerInfo.Source to that of an existing LayerMapSource object (see the code example in the LayerDrawingOptionsCollection Class).

When creating a new Dynamic Layer and specifying a custom Rendering make sure that the LayerDrawingOptions.LayerID and DynamicLayerInfo.ID match in order for the Dynamic Layer to draw in the Map.

NOTE: Because creating and using Dynamic Layers requires both ArcGIS Server v10.1 and higher and the development framework of ArcGIS Runtime SDK 1.0 for WPF and higher; use the ArcGISDynamicMapServiceLayer.SupportsDynamicLayers Property to ensure that these conditions have been met.

Example

How to use:

Click the button to change the Rendering of the first sub-layer of the ArcGISDynamimcMapServiceLayer using the Dynamic Layer capabilities of ArcGIS Server 10.1 and higher.

The XAML code in this example is used in conjunction with the code-behind (C# or VB.NET) to demonstrate the functionality.

The following screen shot corresponds to the code example in this page.

Using a Dynamic Layer to change the ArcGIS Server side Rendering of an ArcGISDynamicMapServiceLayer.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
  
  <!-- Add a Map Control. Zoom to the South-Western United States. -->
  <esri:Map Background="White" HorizontalAlignment="Left" Margin="0,180,0,0" Name="Map1" 
          VerticalAlignment="Top" Height="350" Width="500" Extent="-13468458,3546553,-12238506,4578324">
  
    <!--Add a backdrop ArcGISTiledMapServiceLayer. -->
    <esri:ArcGISTiledMapServiceLayer ID="myArcGISTiledMapServiceLayer" 
      Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
  
    <!-- Add an ArcGISDynamicMapServiceLayer. -->
    <esri:ArcGISDynamicMapServiceLayer ID="myArcGISDynamicMapServiceLayer"
         Url="http://servicesbeta4.esri.com/arcgis/rest/services/USA/MapServer" />
  
  </esri:Map>
  
  <!-- Add a Button to change the Rendering of the first sub-layer of the ArcGISDynamicMapServiceLayer. -->
  <Button Content="Change the Rendering of the first sub-layer in the ArcGISDynamicMapServiceLayer" Height="23" 
          HorizontalAlignment="Left" Margin="0,151,0,0" Name="Button1" VerticalAlignment="Top" Width="500" 
          Click="Button1_Click"/>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="75" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="500" 
       TextWrapping="Wrap" Text="Click the button to change the Rendering of the first sub-layer of the
             ArcGISDynamimcMapServiceLayer using the Dynamic Layer capabilities of 
             ArcGIS Server 10.1 and higher." />
  
</Grid>
C#Copy Code
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // Get the ArcGISDynamicMapServiceLayer defined in XAML.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)(Map1.Layers["myArcGISDynamicMapServiceLayer"]);
  
  // Using Dynamic Layers to change the symbology of an ArcGISDynamicMapServiceLayer is only avilable on ArcGIS Server 10.1 and higher.
  double version = myArcGISDynamicMapServiceLayer.Version;
  if (version >= 10.1)
  {
    // Get the DynamicLayerInfoCollection which contains information about the sub-layers of an ArcGISDynamicMapServiceLayer
    ESRI.ArcGIS.Client.DynamicLayerInfoCollection myDynamicLayerInfoCollection = myArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos();
    
    // Get the first sub-layer information (i.e. the 'Cities' or [0] sub-layer)
    ESRI.ArcGIS.Client.DynamicLayerInfo myDynamicLayerInfo = myDynamicLayerInfoCollection.FirstOrDefault();
    
    // Define a new SimpleMarkerSymbol (a green cross, size 10)
    ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol mySimpleMarkerSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol();
    mySimpleMarkerSymbol.Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Cross;
    mySimpleMarkerSymbol.Color = new System.Windows.Media.SolidColorBrush(Colors.Green);
    mySimpleMarkerSymbol.Size = 10;
    
    // Define a new SimpleRenderer and set the Symbol to the new SymbolMarkerSymbol just created.
    ESRI.ArcGIS.Client.SimpleRenderer mySimpleRenderer = new ESRI.ArcGIS.Client.SimpleRenderer();
    mySimpleRenderer.Symbol = mySimpleMarkerSymbol;
    
    // Create a new LayerDrawingOptions object which will change the symbology of the existing first sub-layer of 
    // the ArcGISDynamicMapServiceLayer.
    ESRI.ArcGIS.Client.LayerDrawingOptions myLayerDrawinOptions = new ESRI.ArcGIS.Client.LayerDrawingOptions();
    myLayerDrawinOptions.LayerID = myDynamicLayerInfo.ID;
    myLayerDrawinOptions.Renderer = mySimpleRenderer;
    
    // Create a LayerDrawingOptionsCollection to house the individual LayerDrawingOptions objects.
    ESRI.ArcGIS.Client.LayerDrawingOptionsCollection myLayerDrawingOptionsCollection = new ESRI.ArcGIS.Client.LayerDrawingOptionsCollection();
    
    // Apply the new settings of the Dynamic Layer and refresh the ArcGISDynamicMapServiceLayer. The Refresh Method
    // will make this client-side request to the ArcGIS Server to re-render the ArcGISDynamicMapServiceLayer using 
    // the newly defined symbology.
    myArcGISDynamicMapServiceLayer.LayerDrawingOptions = myLayerDrawingOptionsCollection;
    myArcGISDynamicMapServiceLayer.LayerDrawingOptions.Add(myLayerDrawinOptions);
    myArcGISDynamicMapServiceLayer.Refresh();
  }
  else
  {
    // Notify the user if using a Dyanmic Layer is not possible.
    MessageBox.Show("Changing the symbology of a Dynamic Layer not possible. Upgrade to ArcGIS Server 10.1 or higher.");
  }
}
VB.NETCopy Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  
  ' Get the ArcGISDynamicMapServiceLayer defined in XAML.
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = CType(Map1.Layers("myArcGISDynamicMapServiceLayer"), ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  
  ' Using Dynamic Layers to change the symbology of an ArcGISDynamicMapServiceLayer is only avilable on ArcGIS Server 10.1 and higher.
  Dim version As Double = myArcGISDynamicMapServiceLayer.Version
  If version >= 10.1 Then
    
    ' Get the DynamicLayerInfoCollection which contains information about the sub-layers of an ArcGISDynamicMapServiceLayer
    Dim myDynamicLayerInfoCollection As ESRI.ArcGIS.Client.DynamicLayerInfoCollection = myArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos
    
    ' Get the first sub-layer information (i.e. the 'Cities' or [0] sub-layer)
    Dim myDynamicLayerInfo As ESRI.ArcGIS.Client.DynamicLayerInfo = myDynamicLayerInfoCollection.FirstOrDefault
    
    ' Define a new SimpleMarkerSymbol (a green cross, size 10)
    Dim mySimpleMarkerSymbol As New ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol
    mySimpleMarkerSymbol.Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Cross
    mySimpleMarkerSymbol.Color = New System.Windows.Media.SolidColorBrush(Colors.Green)
    mySimpleMarkerSymbol.Size = 10
    
    ' Define a new SimpleRenderer and set the Symbol to the new SymbolMarkerSymbol just created.
    Dim mySimpleRenderer As New ESRI.ArcGIS.Client.SimpleRenderer
    mySimpleRenderer.Symbol = mySimpleMarkerSymbol
    
    ' Create a new LayerDrawingOptions object which will change the symbology of the existing first sub-layer of 
    ' the ArcGISDynamicMapServiceLayer.
    Dim myLayerDrawinOptions As New ESRI.ArcGIS.Client.LayerDrawingOptions
    myLayerDrawinOptions.LayerID = myDynamicLayerInfo.ID
    myLayerDrawinOptions.Renderer = mySimpleRenderer
    
    ' Create a LayerDrawingOptionsCollection to house the individual LayerDrawingOptions objects.
    Dim myLayerDrawingOptionsCollection As New ESRI.ArcGIS.Client.LayerDrawingOptionsCollection
    
    ' Apply the new settings of the Dynamic Layer and refresh the ArcGISDynamicMapServiceLayer. The Refresh Method
    ' will make this client-side request to the ArcGIS Server to re-render the ArcGISDynamicMapServiceLayer using 
    ' the newly defined symbology.
    myArcGISDynamicMapServiceLayer.LayerDrawingOptions = myLayerDrawingOptionsCollection
    myArcGISDynamicMapServiceLayer.LayerDrawingOptions.Add(myLayerDrawinOptions)
    myArcGISDynamicMapServiceLayer.Refresh()
    
  Else
    
    ' Notify the user if using a Dyanmic Layer is not possible.
    MessageBox.Show("Changing the symbology of a Dynamic Layer not possible. Upgrade to ArcGIS Server 10.1 or higher.")
    
  End If
  
End Sub

Requirements

Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8

See Also

© ESRI, Inc. All Rights Reserved.