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

Gets or sets the DynamicLayerInfoCollection used to define the way a Dynamic Layer is drawn. Use the ArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos Property to generate an initial DynamicLayerInfoCollection because using the get/Read option of this Property will return null/Nothing for an ArcGISDynamicMapServiceLayer service that was defined via ArcMap and served up using ArcGIS Server.

Syntax

Visual Basic (Declaration) 
Public Property DynamicLayerInfos As DynamicLayerInfoCollection
C# 
public DynamicLayerInfoCollection DynamicLayerInfos {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.

The key to creating a Dynamic Layer is to set the DynamicLayerInfo.Source Property to the appropriate LayerSource object. The LayerSource is an Abstract Class and has two inherited Classes that should be used in setting the DynamicLayerInfo.Source, they are: LayerDataSource and LayerMapSource (review the 'LayerSource Digression' topic section in the ArcGISDynamicMapServiceLayer Class documentation for a more in-depth discussion). One DynamicLayerInfo object is used per Dynamic Layer and is added to a DynamicLayerInfoCollection which is set to the ArcGISDynamicMapServiceLayer.DynamicLayerInfos Property. By default, an ArcGISDynamicMapServiceLayer that was created in ArcMap and served up via ArcGIS Server has its DynamicLayerInfos collection being empty (meaning Nothing/null). Developers can use the ArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos Method to populate the DynamicLayerInfoCollection to serve as a starting point for creating a Dynamic Layer or they can create individual DynamicLayerInfo objects from scratch and add them to the DynamicLayerInfoCollection.

The collection of DynamicLayerInfo objects is used to change the Layer ordering or to redefine the Dynamic Layers drawn in the Map. The order of the objects in the DynamicLayerInfoCollection defines the Layer drawing order; specifically the first element of the collection draws on top of all other Layers.

Example

How to use:

When the application starts a Dynamic Layer (Black lines) is added to the Map Control via XAML. Click the button to add another Dynamic Layer (Red solid circles) via code-behind. The Dynamic Layers used in this example code are based upon using a LayerDataSource that is undiscoverable via the public ArcGIS Server Directory REST pages. The 'WorkspaceID' and 'DataSourceName' for each Dynamic Layer must be provided to the developer by Manager/Adminstrator of the ArcGISDynamicMapServiceLayer. Examples of the 'WorkspaceID' and 'DataSourceName' are provided as comments in the XAML and code-behind for a public ArcGIS Server that has Dynamic Layers enabled via the LayerDataSource object.

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.

Adding Dynammic Layers via a LayerDataSource.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
  
  <!-- Add a Map Control. Set the Extent to the Continental United States. -->
  <esri:Map Background="White" HorizontalAlignment="Left" Margin="0,180,0,0" Name="Map1" 
          VerticalAlignment="Top" Height="350" Width="500" Extent="-14070971,2468307,-7345298,6748281">
  
    <!--Add a backdrop ArcGISTiledMapServiceLayer. -->
    <esri:ArcGISTiledMapServiceLayer ID="myArcGISTiledMapServiceLayer" 
      Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
    
     
    <!-- 
    Add a Layer on-the-fly based on an ArcGISDynamicMapServiceLayer that has Dynamic Layer capabalities enabled.
    The Layer being added DOES NOT come from an existing sub-layer in a LayerMapSource. Rather the Dynamic Layer
    is being generated uses the 'Workspace Type' of 'File GDB' via the LayerDataSource object. Review the
    ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer Class documentation in the API reference for a full discussion.
    In order to create this Dynamic Layer, information was shared between the Manager/Admininstrator of the
    ArcGISDynamicMapServiceLayer ArcGIS Server service and the application developer.
          
    The Url for the ArcGISDynamicMapServiceLayer is: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer".
          
    The WorkspaceID used in the LayerDataSource for the Dynamic Layer is: "CensusFileGDBWorkspaceID"
          
    There are several DataSourceName types associated with the WorkspaceID that could be used to create the Rendering 
    of a Dynamic Layer. Think of the DataSourceName as the string name of the layer that will be drawn dynamically.
    A listing of the available DataSourceNames (and their geometry type) are:
    "cities" <== Points
    "counties" <== Polygons
    "highways" <== Polylines
    "lakes" <== Polygons
    "states" <== Points
    
    Note: the DisableClientCaching is set to true so that what ever is returned from the server will be displayed.
            
    The following high-level things are occuring to create the Dynamic Layer:
    (1) create a DynamicLayerInfo object and set the .ID and .Source Properties
    (2) add that DynamicLayerInfo object to the ArcGISDynamicMapServiceLayer .DynamicLayerInfos collection
    (3) create a LayerDrawingOptions object and set the .LayerID and .Renderer Properties
    (4) add that LayerDrawingOptions object to the ArcGISDynamicMapServiceLayer .LayerDrawingOptions collection
    -->
    <esri:ArcGISDynamicMapServiceLayer Url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer" DisableClientCaching="True">
      <esri:ArcGISDynamicMapServiceLayer.DynamicLayerInfos>
        <esri:DynamicLayerInfoCollection>
          <esri:DynamicLayerInfo ID="101">
            <esri:DynamicLayerInfo.Source>
              <esri:LayerDataSource>
                <esri:LayerDataSource.DataSource>
                  <esri:TableDataSource WorkspaceID="CensusFileGDBWorkspaceID" DataSourceName="highways"/>
                </esri:LayerDataSource.DataSource>
              </esri:LayerDataSource>
            </esri:DynamicLayerInfo.Source>
          </esri:DynamicLayerInfo>
        </esri:DynamicLayerInfoCollection>
      </esri:ArcGISDynamicMapServiceLayer.DynamicLayerInfos>
      <esri:ArcGISDynamicMapServiceLayer.LayerDrawingOptions>
        <esri:LayerDrawingOptionsCollection>
          <esri:LayerDrawingOptions LayerID="101" >
            <esri:LayerDrawingOptions.Renderer>
              <esri:SimpleRenderer>
                <esri:SimpleLineSymbol Color="Black" Width="3" Style="Solid" />
              </esri:SimpleRenderer>
            </esri:LayerDrawingOptions.Renderer>
          </esri:LayerDrawingOptions>
        </esri:LayerDrawingOptionsCollection>
      </esri:ArcGISDynamicMapServiceLayer.LayerDrawingOptions>
    </esri:ArcGISDynamicMapServiceLayer>
    
  </esri:Map>
  
  <!-- Button to add a Dynamic Layer (using LayerDataSource) via code-behind. -->
  <Button Content="Add a Dynamic Layer using a LayerDataSource" 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="145" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" 
   TextWrapping="Wrap" Text="When the application starts a Dynamic Layer (Black lines) is added to the Map 
   Control via XAML. Click the button to add another Dynamic Layer (Red solid circles) via code-behind. The 
   Dynamic Layers used in this example code are based upon using a LayerDataSource that is undiscoverable via 
   the public ArcGIS Server Directory REST pages. The 'WorkspaceID' and 'DataSourceName' for each Dynamic Layer 
   must be provided to the developer by Manager/Adminstrator of the ArcGISDynamicMapServiceLayer. Examples of 
   the 'WorkspaceID' and 'DataSourceName' are provided as comments in the XAML and code-behind for a public 
   ArcGIS Server that has Dynamic Layers enabled via the LayerDataSource object."/>
  
</Grid>
C#Copy Code
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // Add a Layer on-the-fly based on an ArcGISDynamicMapServiceLayer that has Dynamic Layer capabalities enabled.
  // The Layer being added DOES NOT come from an existing sub-layer in a LayerMapSource. Rather the Dynamic Layer
  // is being generated uses the 'Workspace Type' of 'File GDB' via the LayerDataSource object. Review the
  // ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer Class documentation in the API reference for a full discussion.
  // In order to create this Dynamic Layer, information was shared between the Manager/Admininstrator of the
  // ArcGISDynamicMapServiceLayer ArcGIS Server service and the application developer.
  //
  // The Url for the ArcGISDynamicMapServiceLayer is: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer".
  //
  // The WorkspaceID used in the LayerDataSource for the Dynamic Layer is: "CensusFileGDBWorkspaceID"
  //
  // There are several DataSourceName types associated with the WorkspaceID that could be used to create the Rendering 
  // of a Dynamic Layer. Think of the DataSourceName as the string name of the layer that will be drawn dynamically.
  // A listing of the available DataSourceNames (and their geometry type) are:
  // "cities" <== Points
  // "counties" <== Polygons
  // "highways" <== Polylines
  // "lakes" <== Polygons
  // "states" <== Points
  
  // Create a new TableDataSource object and set it's .WorkspaceID and .DataSourceName Properties to valid values.
  ESRI.ArcGIS.Client.TableDataSource myTableDataSource = new ESRI.ArcGIS.Client.TableDataSource();
  myTableDataSource.WorkspaceID = "CensusFileGDBWorkspaceID";
  myTableDataSource.DataSourceName = "cities";
  
  // Create a new LayerDataSource and set its DataSource Property to the TableDataSource.
  ESRI.ArcGIS.Client.LayerDataSource myLayerDataSource = new ESRI.ArcGIS.Client.LayerDataSource();
  myLayerDataSource.DataSource = myTableDataSource;
  
  // Create a new DynamicLayerInfo object and set its ID and Source Properties.
  ESRI.ArcGIS.Client.DynamicLayerInfo myDynamicLayerInfo = new ESRI.ArcGIS.Client.DynamicLayerInfo();
  myDynamicLayerInfo.ID = 102; // Must be the same as the LayerDrawingOptions.LayerID
  myDynamicLayerInfo.Source = myLayerDataSource;
  
  // Create a new DynamicLayerInfoCollection and add the DynamicLayerInfo object into it.
  ESRI.ArcGIS.Client.DynamicLayerInfoCollection myDynamicLayerInfoCollection = new ESRI.ArcGIS.Client.DynamicLayerInfoCollection();
  myDynamicLayerInfoCollection.Add(myDynamicLayerInfo);
  
  // Create a SimpleMarkerSymbol and sets it Style to a circle, Color to Red, and Size to 10 points.
  ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol mySimpleMarkerSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol();
  mySimpleMarkerSymbol.Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle;
  mySimpleMarkerSymbol.Color = new System.Windows.Media.SolidColorBrush(Colors.Red);
  mySimpleMarkerSymbol.Size = 10;
  
  // Create a new SimpleRenderer based upon the SimpleMarkerSymbol.
  ESRI.ArcGIS.Client.SimpleRenderer mySimpleRenderer = new ESRI.ArcGIS.Client.SimpleRenderer();
  mySimpleRenderer.Symbol = mySimpleMarkerSymbol;
  
  // Create a new LayerDrawingOptions object which is key to applying our custom Rendering of the Dynamic Layer.
  // It is imperative that the LayerDrawingOptions.LayerID = DynamicLayerInfo.ID so that the Dynamic Layer draws
  // using the new symbology.
  ESRI.ArcGIS.Client.LayerDrawingOptions myLayerDrawingOptions = new ESRI.ArcGIS.Client.LayerDrawingOptions();
  myLayerDrawingOptions.LayerID = 102; // Must be the same as the DynammicLayerInfo.ID
  myLayerDrawingOptions.Renderer = mySimpleRenderer;
  
  // Create a new LayerDrawinOptionsCollection and add the LayerDraingOptions object into it.
  ESRI.ArcGIS.Client.LayerDrawingOptionsCollection myLayerDrawingOptionsCollection = new ESRI.ArcGIS.Client.LayerDrawingOptionsCollection();
  myLayerDrawingOptionsCollection.Add(myLayerDrawingOptions);
  
  // Create a new Dynamic Layer that is based upon on a LayerDataSource of an ArcGISDynamicMapServiceLayer
  // and apply it's custom rendering.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = new ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer();
  myArcGISDynamicMapServiceLayer.Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer";
  myArcGISDynamicMapServiceLayer.DisableClientCaching = true;
  myArcGISDynamicMapServiceLayer.DynamicLayerInfos = myDynamicLayerInfoCollection;
  myArcGISDynamicMapServiceLayer.LayerDrawingOptions = myLayerDrawingOptionsCollection;
  
  // Because ArcGIS Server restricts only 1000 features being returned per request (this is set as the default
  // unless it is overridden by the ArcGIS Server Manager/Admininstrator), we will apply a LayerDefinition
  // where clause to restrict the amount of features that are returned. This block of code would not be necessary
  // if your service allowed unlimited features being returned per request or your services did not have more than
  // 1000 features to display.
  ESRI.ArcGIS.Client.LayerDefinition myLayerDefinition = new ESRI.ArcGIS.Client.LayerDefinition();
  myLayerDefinition.Definition = "POP2000 > 100000";
  myLayerDefinition.LayerID = 102;
  myArcGISDynamicMapServiceLayer.LayerDefinitions.Add(myLayerDefinition);
  
  // Add the Dynamic Layer to the Map Control. This causes the round trip server request to occur.
  Map1.Layers.Add(myArcGISDynamicMapServiceLayer);
}
VB.NETCopy Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  
  ' Add a Layer on-the-fly based on an ArcGISDynamicMapServiceLayer that has Dynamic Layer capabalities enabled.
  ' The Layer being added DOES NOT come from an existing sub-layer in a LayerMapSource. Rather the Dynamic Layer
  ' is being generated uses the 'Workspace Type' of 'Database' via the LayerDataSource object. Review the
  ' ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer Class documentation in the API reference for a full discussion.
  ' In order to create this Dynamic Layer, information was shared between the Manager/Admininstrator of the
  ' ArcGISDynamicMapServiceLayer ArcGIS Server service and the application developer.
  '
  ' The Url for the ArcGISDynamicMapServiceLayer is: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer".
  '
  ' The WorkspaceID used in the LayerDataSource for the Dynamic Layer is: "CensusFileGDBWorkspaceID"
  '
  ' There are several DataSourceName types associated with the WorkspaceID that could be used to create the Rendering 
  ' of a Dynamic Layer. Think of the DataSourceName as the string name of the layer that will be drawn dynamically.
  ' A listing of the available DataSourceNames (and their geometry type) are:
  ' "cities" <== Points
  ' "counties" <== Polygons
  ' "highways" <== Polylines
  ' "lakes" <== Polygons
  ' "states" <== Points
  
  ' Create a new TableDataSource object and set it's .WorkspaceID and .DataSourceName Properties to valid values.
  Dim myTableDataSource As New ESRI.ArcGIS.Client.TableDataSource
  myTableDataSource.WorkspaceID = "CensusFileGDBWorkspaceID"
  myTableDataSource.DataSourceName = "cities"
  
  ' Create a new LayerDataSource and set its DataSource Property to the TableDataSource.
  Dim myLayerDataSource As New ESRI.ArcGIS.Client.LayerDataSource
  myLayerDataSource.DataSource = myTableDataSource
  
  ' Create a new DynamicLayerInfo object and set its ID and Source Properties.
  Dim myDynamicLayerInfo As New ESRI.ArcGIS.Client.DynamicLayerInfo
  myDynamicLayerInfo.ID = 102 ' Must be the same as the LayerDrawingOptions.LayerID 
  myDynamicLayerInfo.Source = myLayerDataSource
  
  ' Create a new DynamicLayerInfoCollection and add the DynamicLayerInfo object into it.
  Dim myDynamicLayerInfoCollection As New ESRI.ArcGIS.Client.DynamicLayerInfoCollection
  myDynamicLayerInfoCollection.Add(myDynamicLayerInfo)
  
  ' Create a SimpleMarkerSymbol and sets it Style to a circle, Color to Red, and Size to 10 points.
  Dim mySimpleMarkerSymbol As New ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol
  mySimpleMarkerSymbol.Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle
  mySimpleMarkerSymbol.Color = New System.Windows.Media.SolidColorBrush(Colors.Red)
  mySimpleMarkerSymbol.Size = 10
  
  ' Create a new SimpleRenderer based upon the SimpleMarkerSymbol.
  Dim mySimpleRenderer As New ESRI.ArcGIS.Client.SimpleRenderer
  mySimpleRenderer.Symbol = mySimpleMarkerSymbol
  
  ' Create a new LayerDrawingOptions object which is key to applying our custom Rendering of the Dynamic Layer.
  ' It is imperative that the LayerDrawingOptions.LayerID = DynamicLayerInfo.ID so that the Dynamic Layer draws
  ' using the new symbology.
  Dim myLayerDrawingOptions As New ESRI.ArcGIS.Client.LayerDrawingOptions
  myLayerDrawingOptions.LayerID = 102 ' Must be the same as the DynammicLayerInfo.ID
  myLayerDrawingOptions.Renderer = mySimpleRenderer
  
  ' Create a new LayerDrawinOptionsCollection and add the LayerDraingOptions object into it.
  Dim myLayerDrawingOptionsCollection As New ESRI.ArcGIS.Client.LayerDrawingOptionsCollection
  myLayerDrawingOptionsCollection.Add(myLayerDrawingOptions)
  
  ' Create a new Dynamic Layer that is based upon on a LayerDataSource of an ArcGISDynamicMapServiceLayer
  ' and apply it's custom rendering.
  Dim myArcGISDynamicMapServiceLayer As New ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
  myArcGISDynamicMapServiceLayer.Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer"
  myArcGISDynamicMapServiceLayer.DisableClientCaching = True
  myArcGISDynamicMapServiceLayer.DynamicLayerInfos = myDynamicLayerInfoCollection
  myArcGISDynamicMapServiceLayer.LayerDrawingOptions = myLayerDrawingOptionsCollection
  
  ' Because ArcGIS Server restricts only 1000 features being returned per request (this is set as the default
  ' unless it is overridden by the ArcGIS Server Manager/Admininstrator), we will apply a LayerDefinition
  ' where clause to restrict the amount of features that are returned. This block of code would not be necessary
  ' if your service allowed unlimited features being returned per request or your services did not have more than
  ' 1000 features to display.
  Dim myLayerDefinition As New ESRI.ArcGIS.Client.LayerDefinition
  myLayerDefinition.Definition = "POP2000 > 100000"
  myLayerDefinition.LayerID = 102
  myArcGISDynamicMapServiceLayer.LayerDefinitions.Add(myLayerDefinition)
  
  ' Add the Dynamic Layer to the Map Control. This causes the round trip server request to occur.
  Map1.Layers.Add(myArcGISDynamicMapServiceLayer)
  
  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.