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

Obtains the type of ArcGIS Server REST 'map service' capabilities for the ArcGISDynamicMapServiceLayer.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property Capabilities As IEnumerable(Of String)
C# 
public IEnumerable<string> Capabilities {get;}

Remarks

The possible REST 'map service' capabilities string values (in bold) that can be returned in the IEnumerable collection and their meaning (in parenthesis) are:

  • Map (allows client applications to view the map layers in your map service)
  • Query (allows client applications to query the features in your map service)
  • Data (allows client applications to perform attribute searches on the features in your map service)

The IEnumerable String values listed above as a result of the Capabilities Property are only available for ArcGIS Server version 10.0 and higher. Using the Capabilities Property request on ArcGIS Server 9.31 and earlier will return and IEnumerable(Of String).Count = 0.

For each REST 'map service' capability there are often one or more REST 'map service' operations that can be performed. Each REST capability and their operations are listed in the following table:

Map Query Data
ComputeDistance GetSQLSyntaxInfo Find
ComputeScale Identify QueryFeatureData
ExportMapImage QueryFeatureCount
FromMapPoints QueryFeatureIDs
GetCacheName QueryHyperlinks
GetDefaultMapName
GetDocumentInfo
GetLayerTile
GetLegendInfo
GetMapCount
GetMapName
GetMapTile
GetServerInfo
GetSupportedImageReturnType
GetTileCacheInfo
GetVirtualCacheDirectory
HasLayerCache
HasSingleFusedMapCache
IsFixedScaleMap
ToMapPoints

More details about the REST ArcGIS Server capabilities can be found in the Tuning and configuring services documentation.

Discovering the specific REST 'map service' operation that is available for the ArcGISDynamicMapServiceLayer can be found by opening the Services Directory for an ArcGIS Server site. To do this copy the ArcGISDynamicMapServiceLayer.Url Property into the address bar of a web browser and then scroll to the bottom of the returned web page and look for the Supported Operations section. See the following screen shot:

Discovering what 'Supported Operations' are available in a map service.

Example

How to use:

Choose a Url from the ComboBox and then click the Button. A Map Control will be created on-the-fly via code-behind and then an ArcGISDynamicMapServiceLayer for then Url will be added to the Map. The Capabilities information will be displayed in a MessageBox. For ArcGIS Server 9.31 and prior, ArcGISDynamicMapServiceLayer.Capabilities are not discoverable via code.

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.

Obtaining the ArcGISDynamicMapServiceLayer.Capabilities.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
  
  <!-- Add a Stack Panel that will be used to hold the Map Control that is added via code-behind.  -->
  <StackPanel HorizontalAlignment="Left" Margin="12,288,0,0" Name="StackPanel1" 
              VerticalAlignment="Top" Width="775" Height="300">
  </StackPanel>
  
  <!-- 
  Add a ComboBox that allows the user to choose Url's for specifying different ArcGISDynamicMapServiceLayer's.
  -->
  <sdk:Label Height="28" HorizontalAlignment="Left" Margin="11,229,0,0" Name="Label1" 
             VerticalAlignment="Top" Width="26" Content="Url:"/>
  <ComboBox Height="28" HorizontalAlignment="Left" Margin="41,223,0,0" Name="ComboBox1" VerticalAlignment="Top" 
            Width="746" SelectedIndex="0">
    <ComboBoxItem>
      <!-- Uses ArcGIS Server v10.01. -->
      http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer
    </ComboBoxItem>
    <ComboBoxItem>
      <!-- Uses ArcGIS Server v10.01. -->
      http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_1990-2000_Population_Change/MapServer
    </ComboBoxItem>
    <ComboBoxItem>
      <!-- Uses ArcGIS Server v9.31. The ArcGISDynamicMapServiceLayer.Capabilities are not discoverable via code. -->
      http://serverapps.esri.com/ArcGIS/rest/services/NZTopo/MapServer
    </ComboBoxItem>
    <ComboBoxItem>
      <!-- A non-existant (bogus) ArcGISDynamicMapServiceLayer. -->
      http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/BOGUS/MapServer
    </ComboBoxItem>
  </ComboBox>
  
  <!-- Add a Button to perform the work. -->
  <Button Content="Get Capabilities" Height="25" HorizontalAlignment="Left" 
          Margin="11,257,0,0" Name="Button1" VerticalAlignment="Top" Width="776" Click="Button1_Click"/>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="183" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="787" 
             TextWrapping="Wrap" Text="Choose a Url from the ComboBox and then click the Button. A Map Control 
             will be created on-the-fly via code-behind and then an ArcGISDynamicMapServiceLayer for then Url 
             will be added to the Map. The Capabilities information will be displayed in a MessageBox. For 
             ArcGIS Server 9.31 and prior, ArcGISDynamicMapServiceLayer.Capabilities are not discoverable via code." />
  
</Grid>
C#Copy Code
// NOTE: From the ESRI.ArcGIS.Client.Map.SpatialReference API documentation:
// -------------------------------------------------------------------------
// The SpatialReference of the Map can be overridden (meaning that you can set the Map.SpatialReference) by 
// explicitly setting the Map.Extent Property with an Envelope that has an Envelope.SpatialReference defined. 
// Initializing a Map’s SpatialReference via the Map.Extent Property has to be done before any layers will be 
// added to the Map. Once the SpatialReference of a Map has been set and the layers have been loaded, the 
// SpatialReference can no longer be changed. If you need to change SpatialReference on the fly, you can 
// instead create a new Map instance, move the layers to this Map, and replace the previous Map instance. 
  
private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // In this code example, each of the Url's options for the ArcGISDynamicMapServiceLayer in the ComboBox
  // will have a different SpatialReference. To make this sample work, we construct the Map Control on-the-fly
  // for each user choice of the ComboBox to accomodate the changing SpatialReference values.
  
  // Get the StackPanel that was defined in a XAML and remove all child controls.
  StackPanel theStackPanel = (StackPanel)(LayoutRoot.Children[0]);
  theStackPanel.Children.Clear();
  
  // Create a new Map Control, define the intial size properties and then add it to the StackPanel UI Control.
  ESRI.ArcGIS.Client.Map Map1 = new ESRI.ArcGIS.Client.Map();
  Map1.Height = 300;
  Map1.Width = 775;
  Map1.WrapAround = true;
  theStackPanel.Children.Add(Map1);
  
  // Get the user choice from the ComboBox that contains the Url for defining an ArcGISDynamicMapServiceLayer.
  string theUrl = ComboBox1.SelectionBoxItem.ToString();
  if (theUrl != null)
  {
    // Create a new ArcGISDynamicMapServiceLayer using the Url and add it to the Map Control. 
    ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer theArcGISDynamicMapServiceLayer = new ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer();
    theArcGISDynamicMapServiceLayer.Url = theUrl;
    Map1.Layers.Add(theArcGISDynamicMapServiceLayer);
    
    // Wire up the Intialized Event Handler. This will be used to display the ArcGISDynamicMapServiceLayer 
    // Capabilities information.
    theArcGISDynamicMapServiceLayer.Initialized += theArcGISDynamicMapServiceLayer_Initialized;
    
    // Wire up the IntializationFailed Event Handler. This will be used to display any errors with the loading of 
    // the ArcGISDynamicMapServiceLayer. In this example the 4th choice in the ComboBox:
    // http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/BOGUS/MapServer
    // in not even a valid ArcGISDynamicMapServiceLayer so an error should appear in the InitializationFailed Event.
    theArcGISDynamicMapServiceLayer.InitializationFailed += theArcGISDynamicMapServiceLayer_InitializationFailed;
  }
}
            
private void theArcGISDynamicMapServiceLayer_Initialized(object sender, EventArgs e)
{
  // This function will display the ArcGISDynamicMapServiceLayer.Capabilities back to the user
  // in the form of a MessageBox. If the ArcGISDynamicMapServiceLayer is being hosted on a machine
  // with v10.0 or higher the Capabilities will be displayed. If a bogus ArcGISDynamicMapServiceLayer
  // is used the ArcGISDynamicMapServiceLayer.InitializationFailed Event will fire.
  
  // Get the ArcGISDynamicMapServiceLayer.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = null;
  myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)sender;
  
  // Do a check to make sure that the creation of the ArcGISDynamicMapServiceLayer succeded.
  if (myArcGISDynamicMapServiceLayer.InitializationFailure == null)
  {
    // We did not get any error information for the ArcGISDynamicMapServiceLayer, so continue.
    
    // Get the Capabilities of the ArcGISDynamicMapServiceLayer.
    IEnumerable<string> myCapabilities = myArcGISDynamicMapServiceLayer.Capabilities;
    
    // Get the Count of the capabilities to see if we are using ArcGIS Server 10.0 and forward.
    if (myCapabilities.Count() > 0)
    {
      // Display the capabilities in a MessageBox.
      System.Text.StringBuilder myMessage = new System.Text.StringBuilder();
      myMessage.Append("The Capabilities of the ArcGISDynamicMapServiceLayer are:" + Environment.NewLine);
      foreach (string myCapability in myCapabilities)
      {
        myMessage.Append(myCapability + Environment.NewLine);
      }
      MessageBox.Show(myMessage.ToString());
    }
    else
    {
      // Obtaining the listing of capabilities is not available for ArcGIS Server 9.31 and earlier.
      MessageBox.Show("The Count of the Capabilities Property = 0. Must be ArcGIS Server version 9.31 or earlier.");
    }
  }
}
            
private void theArcGISDynamicMapServiceLayer_InitializationFailed(object sender, EventArgs e)
{
  // This event fires where there is a problem with the loading of the ArcGISDynamicMapServiceLayer.
  
  // Get the ArcGISDynamicMapServiceLayer.
  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = null;
  myArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)sender;
  
  // Get the InitializationFailure error message.
  System.Exception myInitializationFailure = myArcGISDynamicMapServiceLayer.InitializationFailure;
  
  // Display the error message to the user.
  MessageBox.Show(myInitializationFailure.Message);
  
}
VB.NETCopy Code
' NOTE: From the ESRI.ArcGIS.Client.Map.SpatialReference API documentation:
' -------------------------------------------------------------------------
' The SpatialReference of the Map can be overridden (meaning that you can set the Map.SpatialReference) by 
' explicitly setting the Map.Extent Property with an Envelope that has an Envelope.SpatialReference defined. 
' Initializing a Map’s SpatialReference via the Map.Extent Property has to be done before any layers will be 
' added to the Map. Once the SpatialReference of a Map has been set and the layers have been loaded, the 
' SpatialReference can no longer be changed. If you need to change SpatialReference on the fly, you can 
' instead create a new Map instance, move the layers to this Map, and replace the previous Map instance. 
  
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
  
  ' In this code example, each of the Url's options for the ArcGISDynamicMapServiceLayer in the ComboBox
  ' will have a different SpatialReference. To make this sample work, we construct the Map Control on-the-fly
  ' for each user choice of the ComboBox to accomodate the changing SpatialReference values.
  
  ' Get the StackPanel that was defined in a XAML and remove all child controls.
  Dim theStackPanel As StackPanel = CType(LayoutRoot.Children(0), StackPanel)
  theStackPanel.Children.Clear()
  
  ' Create a new Map Control, define the intial size properties and then add it to the StackPanel UI Control.
  Dim Map1 As ESRI.ArcGIS.Client.Map = New ESRI.ArcGIS.Client.Map
  Map1.Height = 300
  Map1.Width = 775
  Map1.WrapAround = True
  theStackPanel.Children.Add(Map1)
  
  ' Get the user choice from the ComboBox that contains the Url for defining an ArcGISDynamicMapServiceLayer.
  Dim theUrl As String = ComboBox1.SelectionBoxItem.ToString
  If theUrl IsNot Nothing Then
    
    ' Create a new ArcGISDynamicMapServiceLayer using the Url and add it to the Map Control. 
    Dim theArcGISDynamicMapServiceLayer As New ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
    theArcGISDynamicMapServiceLayer.Url = theUrl
    Map1.Layers.Add(theArcGISDynamicMapServiceLayer)
    
    ' Wire up the Intialized Event Handler. This will be used to display the ArcGISDynamicMapServiceLayer 
    ' Capabilities information.
    AddHandler theArcGISDynamicMapServiceLayer.Initialized, AddressOf theArcGISDynamicMapServiceLayer_Initialized
    
    ' Wire up the IntializationFailed Event Handler. This will be used to display any errors with the loading of 
    ' the ArcGISDynamicMapServiceLayer. In this example the 4th choice in the ComboBox:
    ' http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/BOGUS/MapServer
    ' in not even a valid ArcGISDynamicMapServiceLayer so an error should appear in the InitializationFailed Event.
    AddHandler theArcGISDynamicMapServiceLayer.InitializationFailed, AddressOf theArcGISDynamicMapServiceLayer_InitializationFailed
    
  End If
  
End Sub
            
Private Sub theArcGISDynamicMapServiceLayer_Initialized(sender As Object, e As EventArgs)
  
  ' This function will display the ArcGISDynamicMapServiceLayer.Capabilities back to the user
  ' in the form of a MessageBox. If the ArcGISDynamicMapServiceLayer is being hosted on a machine
  ' with v10.0 or higher the Capabilities will be displayed. If a bogus ArcGISDynamicMapServiceLayer
  ' is used the ArcGISDynamicMapServiceLayer.InitializationFailed Event will fire.
  
  ' Get the ArcGISDynamicMapServiceLayer.
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
  myArcGISDynamicMapServiceLayer = CType(sender, ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  
  ' Do a check to make sure that the creation of the ArcGISDynamicMapServiceLayer succeded.
  If myArcGISDynamicMapServiceLayer.InitializationFailure Is Nothing Then
    
    ' We did not get any error information for the ArcGISDynamicMapServiceLayer, so continue.
    
    ' Get the Capabilities of the ArcGISDynamicMapServiceLayer.
    Dim myCapabilities As IEnumerable(Of String) = myArcGISDynamicMapServiceLayer.Capabilities
    
    ' Get the Count of the capabilities to see if we are using ArcGIS Server 10.0 and forward.
    If myCapabilities.Count > 0 Then
      
      ' Display the capabilities in a MessageBox.
      Dim myMessage As New System.Text.StringBuilder
      myMessage.Append("The Capabilities of the ArcGISDynamicMapServiceLayer are:" + vbCrLf)
      Dim myCapability As String = Nothing
      For Each myCapability In myCapabilities
        myMessage.Append(myCapability + vbCrLf)
      Next
      MessageBox.Show(myMessage.ToString)
      
    Else
      
      ' Obtaining the listing of capabilities is not available for ArcGIS Server 9.31 and earlier.
      MessageBox.Show("The Count of the Capabilities Property = 0. Must be ArcGIS Server version 9.31 or earlier.")
    
    End If
    
  End If
  
End Sub
            
Private Sub theArcGISDynamicMapServiceLayer_InitializationFailed(sender As Object, e As EventArgs)
  
  ' This event fires where there is a problem with the loading of the ArcGISDynamicMapServiceLayer.
  
  ' Get the ArcGISDynamicMapServiceLayer.
  Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer
  myArcGISDynamicMapServiceLayer = CType(sender, ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)
  
  ' Get the InitializationFailure error message.
  Dim myInitializationFailure As System.Exception = myArcGISDynamicMapServiceLayer.InitializationFailure
  
  ' Display the error message to the user.
  MessageBox.Show(myInitializationFailure.Message)
  
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.