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

Gets or sets the DynamicLayerInfoCollection used to define the way a Dynamic Layer is drawn. In the context of the IdentifyParameters Class, this Property allows Identify information to be obtained for a Dynamic Layer.

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.

Example

How to use:

After the Layers load in the Map, click on a 'County' to obtain Identify information for the Dynamic Layer. The Dynamic Layer that is generated is based upon the 'Workspace Type' of 'Database' using a LayerMapSource for the LayerDataSource. The point is to show how the ESRI.ArcGIS.Client.Tasks.IdentifyParameters.DynamicLayerInfos Property can be used to obtain Identify information about a Dynamic Layer.

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.

Performing an Identify on Features in a Dynamic Layer.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
  
  <!-- 
  Add a Map Control. Zoom to Alaska. Note the use of the MouseClick and Loaded Events are used with
  code-behind logic.
  -->
  <esri:Map Background="White" HorizontalAlignment="Left" Margin="0,204,0,0" Name="Map1" 
          VerticalAlignment="Top" Height="350" Width="500" Extent="-20686124,6677550,-13657836,11597352"
          MouseClick="Map1_MouseClick"  Loaded="Map1_Loaded">
    
    <!-- Add a backdrop ArcGISTiledMapServiceLayer. -->
    <esri:ArcGISTiledMapServiceLayer ID="myArcGISTiledMapServiceLayer" 
      Url="http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer" />
    
    <!-- 
    Add a Dynamic Layer based on an existing ArcMap and ArcGIS Server map service ArcGISDynamicMapServiceLayer 
    sub-layer (specifically the 'Counties' or [3] sub-layer). A Dynamic Layer is a web request where the client 
    application issues an ArcGIS Server command to generate an on-the-fly layer for display in the Map Control. 
    Note: the DisableClientCaching is set to true so that what ever is returned from the server will be displayed.
            
    In order to create the Dynamic Layer the following are occuring: 
    (1) create a DynamicLayerInfo object and set the .ID and .Source Properties
    (2) add that DynamicLayerInfo object to the ArcGISDynamicMapServiceLayer .DynamicLayerInfos collection
    Note: It is not mandatory to set the ArcGISDynamicMapServiceLayer.LayerDrawingOptions if your Dynamic
    Layer is based upon a LayerMapSource. The Dynamic Layer that is getting created automatically uses the
    existing Symbology of the ArcGISDynamicMapServiceLayer sub-layer, unless you override it.
    -->
    <esri:ArcGISDynamicMapServiceLayer ID="myArcGISDynamicMapServiceLayer" Opacity="0.2" DisableClientCaching="True"
                                       Url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer" >
      <esri:ArcGISDynamicMapServiceLayer.DynamicLayerInfos>
        <esri:DynamicLayerInfoCollection>
          <esri:DynamicLayerInfo ID="99">
            <esri:DynamicLayerInfo.Source>
              <esri:LayerMapSource MapLayerID="3" />
            </esri:DynamicLayerInfo.Source>
          </esri:DynamicLayerInfo>
        </esri:DynamicLayerInfoCollection>
      </esri:ArcGISDynamicMapServiceLayer.DynamicLayerInfos>
    </esri:ArcGISDynamicMapServiceLayer>
    
    <!-- 
    Add an empty GraphicsLayer to showcase where the user clicks on the Map for the feature being Identified. 
    -->
    <esri:GraphicsLayer ID="myGraphicsLayer" />
  </esri:Map>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="147" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" 
   TextWrapping="Wrap" Text="After the Layers load in the Map, click on a 'County' to obtain Identify information
   for the Dynamic Layer. The Dynamic Layer that is generated is based upon the 'Workspace Type' of 'Database' 
   using a LayerMapSource for the LayerDataSource. The point is to show how the 
   ESRI.ArcGIS.Client.Tasks.IdentifyParameters.DynamicLayerInfos Property can be used to obtain Identify
   information about a Dynamic Layer."/>
   
</Grid>
C#Copy Code
// Create some Member (i.e Global in scope) variables for the ArGISDynamicMapServiceLayer, IdentifyParameters,
// and IdentifyTask objects.
private ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer _MyArcGISDynamicMapServiceLayer;
private ESRI.ArcGIS.Client.Tasks.IdentifyParameters _MyIdentifyParameters = new ESRI.ArcGIS.Client.Tasks.IdentifyParameters();
private ESRI.ArcGIS.Client.Tasks.IdentifyTask _MyIdentifyTask = new ESRI.ArcGIS.Client.Tasks.IdentifyTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer");
            
private void Map1_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
  // When the Map loads all of its Layers, get the ArcGISDynamicMapServiceLayer defined in XAML. Allow
  // DisableClientCaching for the IdentifyTask request.
  _MyArcGISDynamicMapServiceLayer = Map1.Layers["myArcGISDynamicMapServiceLayer"] as ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer;
  _MyIdentifyTask.DisableClientCaching = true;
  
  // Create some Event Handlers to account for when the IdentifyTask completes.
  _MyIdentifyTask.ExecuteCompleted += identify_ExecuteCompleted;
  _MyIdentifyTask.Failed += identify_Failed;
}
            
private void Map1_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
{
  // Set all of the Parameters on the IdentifyTask request.
  _MyIdentifyParameters.Geometry = e.MapPoint; // Where the user clicked on the Map.
  _MyIdentifyParameters.ReturnGeometry = true; // Get the spatial geometry information.
  _MyIdentifyParameters.SpatialReference = Map1.SpatialReference; // Get the SpatialReference information.
  _MyIdentifyParameters.MapExtent = Map1.Extent; // Get the Extent of the Map.
  _MyIdentifyParameters.DynamicLayerInfos = _MyArcGISDynamicMapServiceLayer.DynamicLayerInfos; // Get the Dynamic Layer information.
  _MyIdentifyParameters.Height = Convert.ToInt32(Map1.Height); // Required parameter setting for services on AGS 10.1 and higher.
  _MyIdentifyParameters.Width = Convert.ToInt32(Map1.Width);  // Required parameter setting for services on AGS 10.1 and higher.
  
  // Catch for the user clicking again on the Map before a first Identify results are processed.
  if (_MyIdentifyTask.IsBusy)
  {
    _MyIdentifyTask.CancelAsync();
  }
  
  // Execute the Asynchronous request to Identify the Dynamic Layer Features where the user clicked on the Map.
  _MyIdentifyTask.ExecuteAsync(_MyIdentifyParameters);
}
            
private void identify_Failed(object sender, ESRI.ArcGIS.Client.Tasks.TaskFailedEventArgs e)
{
  // "Houston, we have a problem!"
  MessageBox.Show(e.Error.Message);
}
            
private void identify_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.IdentifyEventArgs e)
{
  // Get the Graphics Layer defined in XAML and clear out any previous Graphics.
  ESRI.ArcGIS.Client.GraphicsLayer myGraphicsLayer = (ESRI.ArcGIS.Client.GraphicsLayer)(Map1.Layers["myGraphicsLayer"]);
  myGraphicsLayer.ClearGraphics();
  
  // Create a StringBuilder object to hold Identify information that will be relayed to the user.
  Text.StringBuilder myStringBuilder = new Text.StringBuilder();
  
  // Get the IdentifyResults.
  System.Collections.Generic.List<ESRI.ArcGIS.Client.Tasks.IdentifyResult> myListOfIdentifyResult = e.IdentifyResults;
  
  if (myListOfIdentifyResult.Count == 1)
  {
    // We are only interested in the first result of the Identify. 
    
    // Create a SimpleFillSymbol using the solid Yellow brush and set the Border to be Red with a thickness 
    // of 2. This will be used to accentuate the display of the Feature the user clicked on.
    ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol newSimpleFillSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol();
    newSimpleFillSymbol.Fill = new System.Windows.Media.SolidColorBrush(Colors.Yellow);
    newSimpleFillSymbol.BorderBrush = new System.Windows.Media.SolidColorBrush(Colors.Red);
    newSimpleFillSymbol.BorderThickness = 2;
    
    // Get the Feature (a Graphic) that is returned from the Identify operation, set it's Symbol, and
    // add it to the GraphicsLayer. This will cause an automatic redraw of the Map.
    ESRI.ArcGIS.Client.Graphic myGraphic = myListOfIdentifyResult[0].Feature;
    myGraphic.Symbol = newSimpleFillSymbol;
    myGraphicsLayer.Graphics.Add(myGraphic);
    
    // Get the DisplayFieldName and its Value of the first result.
    string myDisplayFieldName = myListOfIdentifyResult[0].DisplayFieldName;
    string myValue = myListOfIdentifyResult[0].Value.ToString();
    
    // Add the Identify information into the StringBuilder and display it in a MessageBox.
    myStringBuilder.Append(myDisplayFieldName + ": " + myValue);
    MessageBox.Show(myStringBuilder.ToString());
  }
  else
  {
    // Let the user know they did not click on a Feature.
    MessageBox.Show("No Features Found!");
  }
}
VB.NETCopy Code
' Create some Member (i.e Global in scope) variables for the ArGISDynamicMapServiceLayer, IdentifyParameters,
' and IdentifyTask objects.
Private _MyArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
Private _MyIdentifyParameters As New ESRI.ArcGIS.Client.Tasks.IdentifyParameters()
Private _MyIdentifyTask As New ESRI.ArcGIS.Client.Tasks.IdentifyTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer")
            
Private Sub Map1_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs)
  
  ' When the Map loads all of its Layers, get the ArcGISDynamicMapServiceLayer defined in XAML. Allow
  ' DisableClientCaching for the IdentifyTask request.
  _MyArcGISDynamicMapServiceLayer = TryCast(Map1.Layers("myArcGISDynamicMapServiceLayer"), ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  _MyIdentifyTask.DisableClientCaching = True
  
  ' Create some Event Handlers to account for when the IdentifyTask completes.
  AddHandler _MyIdentifyTask.ExecuteCompleted, AddressOf identify_ExecuteCompleted
  AddHandler _MyIdentifyTask.Failed, AddressOf identify_Failed
  
End Sub
  
Private Sub Map1_MouseClick(sender As System.Object, e As ESRI.ArcGIS.Client.Map.MouseEventArgs)
  
  ' Set all of the Parameters on the IdentifyTask request.
  _MyIdentifyParameters.Geometry = e.MapPoint ' Where the user clicked on the Map.
  _MyIdentifyParameters.ReturnGeometry = True ' Get the spatial geometry information.
  _MyIdentifyParameters.SpatialReference = Map1.SpatialReference ' Get the SpatialReference information.
  _MyIdentifyParameters.MapExtent = Map1.Extent ' Get the Extent of the Map.
  _MyIdentifyParameters.DynamicLayerInfos = _MyArcGISDynamicMapServiceLayer.DynamicLayerInfos ' Get the Dynamic Layer information. 
  _MyIdentifyParameters.Height = CInt(Map1.Height) 'Required parameter setting for services on AGS 10.1 and higher.
  _MyIdentifyParameters.Width = CInt(Map1.Width) 'Required parameter setting for services on AGS 10.1 and higher.
  
  ' Catch for the user clicking again on the Map before a first Identify results are processed.
  If _MyIdentifyTask.IsBusy Then
    _MyIdentifyTask.CancelAsync()
  End If
  
  ' Execute the Asynchronous request to Identify the Dynamic Layer Features where the user clicked on the Map.
  _MyIdentifyTask.ExecuteAsync(_MyIdentifyParameters)
  
End Sub
  
Private Sub identify_Failed(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Client.Tasks.TaskFailedEventArgs)
  
  ' "Houston, we have a problem!"
  MessageBox.Show(e.Error.Message)
  
End Sub
  
Private Sub identify_ExecuteCompleted(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Client.Tasks.IdentifyEventArgs)
  
  ' Get the Graphics Layer defined in XAML and clear out any previous Graphics.
  Dim myGraphicsLayer As ESRI.ArcGIS.Client.GraphicsLayer = CType(Map1.Layers("myGraphicsLayer"), ESRI.ArcGIS.Client.GraphicsLayer)
  myGraphicsLayer.ClearGraphics()
  
  ' Create a StringBuilder object to hold Identify information that will be relayed to the user.
  Dim myStringBuilder As New Text.StringBuilder
  
  ' Get the IdentifyResults.
  Dim myListOfIdentifyResult As System.Collections.Generic.List(Of ESRI.ArcGIS.Client.Tasks.IdentifyResult) = e.IdentifyResults
  
  If myListOfIdentifyResult.Count = 1 Then
    
    ' We are only interested in the first result of the Identify. 
      
    ' Create a SimpleFillSymbol using the solid Yellow brush and set the Border to be Red with a thickness 
    ' of 2. This will be used to accentuate the display of the Feature the user clicked on.
    Dim newSimpleFillSymbol As New ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol
    newSimpleFillSymbol.Fill = New System.Windows.Media.SolidColorBrush(Colors.Yellow)
    newSimpleFillSymbol.BorderBrush = New System.Windows.Media.SolidColorBrush(Colors.Red)
    newSimpleFillSymbol.BorderThickness = 2
    
    ' Get the Feature (a Graphic) that is returned from the Identify operation, set it's Symbol, and
    ' add it to the GraphicsLayer. This will cause an automatic redraw of the Map.
    Dim myGraphic As ESRI.ArcGIS.Client.Graphic = myListOfIdentifyResult(0).Feature
    myGraphic.Symbol = newSimpleFillSymbol
    myGraphicsLayer.Graphics.Add(myGraphic)
    
   ' Get the DisplayFieldName and its Value of the first result.
    Dim myDisplayFieldName As String = myListOfIdentifyResult(0).DisplayFieldName
    Dim myValue As String = myListOfIdentifyResult(0).Value.ToString
    
    ' Add the Identify information into the StringBuilder and display it in a MessageBox.
    myStringBuilder.Append(myDisplayFieldName + ": " + myValue)
    MessageBox.Show(myStringBuilder.ToString)
    
  Else
    
    ' Let the user know they did not click on a Feature.
    MessageBox.Show("No Features Found!")
    
  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.