Visual Basic (Declaration) | |
---|---|
Public ReadOnly Property Capabilities As IEnumerable(Of String) |
C# | |
---|---|
public IEnumerable<string> Capabilities {get;} |
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 ArcGISTiledMapServiceLayer can be found by opening the Services Directory for an ArcGIS Server site. To do this copy the ArcGISTiledMapServiceLayer.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:
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 ArcGISTiledMapServiceLayer 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, ArcGISTiledMapServiceLayer.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.
XAML | Copy 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 ArcGISTiledMapServiceLayer'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 ArcGISTiledMapServiceLayer.Capabilities are not discoverable via code. --> http://serverapps.esri.com/ArcGIS/rest/services/NZTopo/MapServer </ComboBoxItem> <ComboBoxItem> <!-- A non-existant (bogus) ArcGISTiledMapServiceLayer. --> 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 ArcGISTiledMapServiceLayer 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, ArcGISTiledMapServiceLayer.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 ArcGISTiledMapServiceLayer 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 ArcGISTiledMapServiceLayer. string theUrl = ComboBox1.SelectionBoxItem.ToString(); if (theUrl != null) { // Create a new ArcGISTiledMapServiceLayer using the Url and add it to the Map Control. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer theArcGISTiledMapServiceLayer = new ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer(); theArcGISTiledMapServiceLayer.Url = theUrl; Map1.Layers.Add(theArcGISTiledMapServiceLayer); // Wire up the Intialized Event Handler. This will be used to display the ArcGISTiledMapServiceLayer // Capabilities information. theArcGISTiledMapServiceLayer.Initialized += theArcGISTiledMapServiceLayer_Initialized; // Wire up the IntializationFailed Event Handler. This will be used to display any errors with the loading of // the ArcGISTiledMapServiceLayer. In this example the 4th choice in the ComboBox: // http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/BOGUS/MapServer // in not even a valid ArcGISTiledMapServiceLayer so an error should appear in the InitializationFailed Event. theArcGISTiledMapServiceLayer.InitializationFailed += theArcGISTiledMapServiceLayer_InitializationFailed; } } private void theArcGISTiledMapServiceLayer_Initialized(object sender, EventArgs e) { // This function will display the ArcGISTiledMapServiceLayer.Capabilities back to the user // in the form of a MessageBox. If the ArcGISTiledMapServiceLayer is being hosted on a machine // with v10.0 or higher the Capabilities will be displayed. If a bogus ArcGISTiledMapServiceLayer // is used the ArcGISTiledMapServiceLayer.InitializationFailed Event will fire. // Get the ArcGISTiledMapServiceLayer. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = null; myArcGISTiledMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer)sender; // Do a check to make sure that the creation of the ArcGISTiledMapServiceLayer succeded. if (myArcGISTiledMapServiceLayer.InitializationFailure == null) { // We did not get any error information for the ArcGISTiledMapServiceLayer, so continue. // Get the Capabilities of the ArcGISTiledMapServiceLayer. IEnumerable<string> myCapabilities = myArcGISTiledMapServiceLayer.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 ArcGISTiledMapServiceLayer 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 theArcGISTiledMapServiceLayer_InitializationFailed(object sender, EventArgs e) { // This event fires where there is a problem with the loading of the ArcGISTiledMapServiceLayer. // Get the ArcGISTiledMapServiceLayer. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = null; myArcGISTiledMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer)sender; // Get the InitializationFailure error message. System.Exception myInitializationFailure = myArcGISTiledMapServiceLayer.InitializationFailure; // Display the error message to the user. MessageBox.Show(myInitializationFailure.Message); } |
VB.NET | 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 Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) ' In this code example, each of the Url's options for the ArcGISTiledMapServiceLayer 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 ArcGISTiledMapServiceLayer. Dim theUrl As String = ComboBox1.SelectionBoxItem.ToString If theUrl IsNot Nothing Then ' Create a new ArcGISTiledMapServiceLayer using the Url and add it to the Map Control. Dim theArcGISTiledMapServiceLayer As New ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer theArcGISTiledMapServiceLayer.Url = theUrl Map1.Layers.Add(theArcGISTiledMapServiceLayer) ' Wire up the Intialized Event Handler. This will be used to display the ArcGISTiledMapServiceLayer ' Capabilities information. AddHandler theArcGISTiledMapServiceLayer.Initialized, AddressOf theArcGISTiledMapServiceLayer_Initialized ' Wire up the IntializationFailed Event Handler. This will be used to display any errors with the loading of ' the ArcGISTiledMapServiceLayer. In this example the 4th choice in the ComboBox: ' http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/BOGUS/MapServer ' in not even a valid ArcGISTiledMapServiceLayer so an error should appear in the InitializationFailed Event. AddHandler theArcGISTiledMapServiceLayer.InitializationFailed, AddressOf theArcGISTiledMapServiceLayer_InitializationFailed End If End Sub Private Sub theArcGISTiledMapServiceLayer_Initialized(sender As Object, e As EventArgs) ' This function will display the ArcGISTiledMapServiceLayer.Capabilities back to the user ' in the form of a MessageBox. If the ArcGISTiledMapServiceLayer is being hosted on a machine ' with v10.0 or higher the Capabilities will be displayed. If a bogus ArcGISTiledMapServiceLayer ' is used the ArcGISTiledMapServiceLayer.InitializationFailed Event will fire. ' Get the ArcGISTiledMapServiceLayer. Dim myArcGISTiledMapServiceLayer As ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = CType(sender, ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) ' Do a check to make sure that the creation of the ArcGISTiledMapServiceLayer succeded. If myArcGISTiledMapServiceLayer.InitializationFailure Is Nothing Then ' We did not get any error information for the ArcGISTiledMapServiceLayer, so continue. ' Get the Capabilities of the ArcGISTiledMapServiceLayer. Dim myCapabilities As IEnumerable(Of String) = myArcGISTiledMapServiceLayer.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 ArcGISTiledMapServiceLayer 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 theArcGISTiledMapServiceLayer_InitializationFailed(sender As Object, e As EventArgs) ' This event fires where there is a problem with the loading of the ArcGISTiledMapServiceLayer. ' Get the ArcGISTiledMapServiceLayer. Dim myArcGISTiledMapServiceLayer As ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = CType(sender, ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) ' Get the InitializationFailure error message. Dim myInitializationFailure As System.Exception = myArcGISTiledMapServiceLayer.InitializationFailure ' Display the error message to the user. MessageBox.Show(myInitializationFailure.Message) End Sub |
Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7