Visual Basic (Declaration) | |
---|---|
Public Sub GetDetails( _ ByVal id As Integer, _ ByVal onCompleted As Action(Of FeatureLayerInfo,Exception) _ ) |
C# | |
---|---|
public void GetDetails( int id, Action<FeatureLayerInfo,Exception> onCompleted ) |
The GetDetails Method returns a FeatureLayerInfo object for a specific sub-layer ID. The FeatureLayerInfo object is rich with numerous Properties that can be used to get metadata information about the ArcGISTiledMapServiceLayer web service. To get the details for all sub-layers in an ArcGISTiledMapServiceLayer consider using the ArcGISTiledMapServiceLayer.GetAllDetails instead.
The ArcGISTiledMapServiceLayer.Layers Property provides information on the sub-layers that comprise an ArcGISTiledMapServiceLayer. One of the key pieces of information obtained from the ArcGISTiledMapServiceLayer.Layers Property is the LayerInfo.ID Property. The LayerInfo.ID is the integer value of the specific sub-layer in the ArcGISTiledMapServiceLayer. This can be used as the 'id' parameter of the GetDetails Method.
Parameters
- id
- The sub-layer or table id.
- onCompleted
- The method to call when details of the sub-layer or table is retrieved.
How to use:
When the application loads an ArcGISTiledMapServiceLayer will display and the sub-layer ID's will be shown in the ListBox. Choose a sub-layer ID and then click one of the four Buttons to display the sub-layer Name that was obtained via the ArcGISTiledMapServiceLayer.GetDetails Method. Each of the four Buttons uses a slightly different coding practice to achieve the same results.
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 Map Control. Set the Extent to that of the Great Lakes region. --> <esri:Map Background="White" HorizontalAlignment="Left" Margin="6,227,0,0" Name="Map1" Height="361" VerticalAlignment="Top" Width="616" Extent="-10726306,4955978,-8152376,6464401"> <!-- Add an ArcGISTiledMapServiceLayer. Wire up the Initialized Event to display the sub-layer ID's in the Listbox. --> <esri:ArcGISTiledMapServiceLayer ID="Soil_Survey_Map" Url="http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/Soil_Survey_Map/MapServer" Initialized="ArcGISTiledMapServiceLayer_Initialized" /> </esri:Map> <!-- Display the sub-layer Name when the user clicks any of the Buttons. --> <sdk:Label Height="19" HorizontalAlignment="Left" Margin="11,192,0,0" Name="Label_SubLayerName" VerticalAlignment="Top" Width="100" Content="Sub-Layer Name:"/> <TextBox Height="23" HorizontalAlignment="Left" Margin="117,188,0,0" Name="TextBox_SubLayerName" VerticalAlignment="Top" Width="505" /> <!-- Have the user choose a sub-layer ID from the ListBox. --> <TextBlock Text="Pick a sub-layer ID and Click one of the buttons:" TextWrapping="Wrap" Margin="625,227,97,260" /> <ListBox Height="143" HorizontalAlignment="Left" Margin="625,296,0,0" Name="ListBox_SubLayerID" VerticalAlignment="Top" Width="78" /> <!-- Each of the four Buttons uses the ArcGISTiledMapServiceLayer.GetDetails Method to display the sub-layer Name in the TextBox. Each button uses a slightly different coding methadology but accompolishes the same result. --> <Button Content="Option1" Height="23" HorizontalAlignment="Left" Margin="625,445,0,0" Name="Button1" VerticalAlignment="Top" Width="75" Click="Button1_Click"/> <Button Content="Option2" Height="23" HorizontalAlignment="Left" Margin="627,479,0,0" Name="Button2" VerticalAlignment="Top" Width="75" Click="Button2_Click"/> <Button Content="Option3" Height="23" HorizontalAlignment="Left" Margin="628,514,0,0" Name="Button3" VerticalAlignment="Top" Width="75" Click="Button3_Click" /> <Button Content="Option4" Height="23" HorizontalAlignment="Left" Margin="628,548,0,0" Name="Button4" VerticalAlignment="Top" Width="75" Click="Button4_Click"/> <!-- Provide the instructions on how to use the sample code. --> <TextBlock Height="102" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="622" TextWrapping="Wrap" Text="When the application loads an ArcGISTiledMapServiceLayer will display and the sub-layer ID's will be shown in the ListBox. Choose a sub-layer ID and then click one of the four Buttons to display the sub-layer Name that was obtained via the ArcGISTiledMapServiceLayer.GetDetails Method. Each of the four Buttons uses a slightly different coding practice to achieve the same results." /> </Grid> |
C# | Copy Code |
---|---|
private void ArcGISTiledMapServiceLayer_Initialized(object sender, System.EventArgs e) { // Get the ArcGISTiledMapServiceLayer. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = null; myArcGISTiledMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer)sender; // Get the collection of LayerInfo objects ESRI.ArcGIS.Client.LayerInfo[] myLayerInfos = myArcGISTiledMapServiceLayer.Layers; // Loop throgh each LayerInfo object and display the sub-layer ID value in the ListBox. foreach (ESRI.ArcGIS.Client.LayerInfo myLayerInfo in myLayerInfos) { ListBox_SubLayerID.Items.Add(myLayerInfo.ID); } // If we have more than one sub-layer ID, select the first one as the default. if (myLayerInfos.Count() > 0) { ListBox_SubLayerID.SelectedIndex = 0; } } // IMPORTANT NOTE: // Each of the four options below accompolish the same result of using the ArcGISTiledMapServiceLayer.GetDetails // Method to display a sub-layer Name in the TextBox. The various options are shown to demonstrate different // coding styles you may want to consider using. Options #1 and #2 are beneficial for small bits of code. // The external sub-routine options (#3 and #4) are better when the coding algorithms get longer and more // complicated. #region Option1: in-line lambda version private void Button1_Click(object sender, System.Windows.RoutedEventArgs e) { // Clear out any prior sub-layer ID text value. TextBox_SubLayerName.Text = ""; // Get the ArcGISTiledMapServiceLayer. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = null; myArcGISTiledMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer)(Map1.Layers["Soil_Survey_Map"]); // Get the user selected sub-layer ID value. int mySubLayerID = (int)ListBox_SubLayerID.SelectedValue; // Use a lambda expression for the ArcGISTiledMapServiceLayer.GetDetails Method to display the sub-layer Name in the TextBox. myArcGISTiledMapServiceLayer.GetDetails(mySubLayerID, (ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo myFeatureLayerInfo, Exception myException) => { if (myException == null) { TextBox_SubLayerName.Text = myFeatureLayerInfo.Name; } }); } #endregion #region Option2: Action version private void Button2_Click(object sender, System.Windows.RoutedEventArgs e) { // Clear out any prior sub-layer ID text value. TextBox_SubLayerName.Text = ""; // Get the ArcGISTiledMapServiceLayer. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = null; myArcGISTiledMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer)(Map1.Layers["Soil_Survey_Map"]); // Define an Action to handle the work of the ArcGISTiledMapServiceLayer.GetDetails Method to display the sub-layer Name in the TextBox. Action<ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo, Exception> myAction = (myFeatureLayerInfo, myException) => { if (myException == null) { TextBox_SubLayerName.Text = myFeatureLayerInfo.Name; } }; // Get the user selected sub-layer ID value. int mySubLayerID = (int)ListBox_SubLayerID.SelectedValue; // Invoke the ArcGISTiledMapServiceLayer.GetDetails Method, which will use the Action. myArcGISTiledMapServiceLayer.GetDetails(mySubLayerID, myAction); } #endregion #region Option3: external function call version private void Button3_Click(object sender, System.Windows.RoutedEventArgs e) { // Clear out any prior sub-layer ID text value. TextBox_SubLayerName.Text = ""; // Get the ArcGISTiledMapServiceLayer. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = null; myArcGISTiledMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer)(Map1.Layers["Soil_Survey_Map"]); // Get the user selected sub-layer ID value. int mySubLayerID = (int)ListBox_SubLayerID.SelectedValue; // Invoke the ArcGISTiledMapServiceLayer.GetDetails Method, which will use an external sub-routine via AddressOf. myArcGISTiledMapServiceLayer.GetDetails(mySubLayerID, ShowName); } private void ShowName(ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo myFeatureLayerInfo, Exception myException) { // Display the sub-layer Name in the TextBox. if (myException == null) { TextBox_SubLayerName.Text = myFeatureLayerInfo.Name; } } #endregion #region Option4: external function call via Action version private void Button4_Click(object sender, System.Windows.RoutedEventArgs e) { // Clear out any prior sub-layer ID text value. TextBox_SubLayerName.Text = ""; // Get the ArcGISTiledMapServiceLayer. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = null; myArcGISTiledMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer)(Map1.Layers["Soil_Survey_Map"]); // Define an Action to handle the work of the ArcGISTiledMapServiceLayer.GetDetails Method to display the sub-layer Name in the TextBox. Action<ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo, Exception> myAction = ShowName2; // Get the user selected sub-layer ID value. int mySubLayerID = (int)ListBox_SubLayerID.SelectedValue; // Invoke the ArcGISTiledMapServiceLayer.GetDetails Method, which will use the Action. myArcGISTiledMapServiceLayer.GetDetails(mySubLayerID, myAction); } private void ShowName2(ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo myFeatureLayerInfo, Exception myException) { // Display the sub-layer Name in the TextBox. if (myException == null) { TextBox_SubLayerName.Text = myFeatureLayerInfo.Name; } } #endregion |
VB.NET | Copy Code |
---|---|
Private Sub ArcGISTiledMapServiceLayer_Initialized(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Get the ArcGISTiledMapServiceLayer. Dim myArcGISTiledMapServiceLayer As ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = CType(sender, ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) ' Get the collection of LayerInfo objects Dim myLayerInfos As ESRI.ArcGIS.Client.LayerInfo() = myArcGISTiledMapServiceLayer.Layers ' Loop throgh each LayerInfo object and display the sub-layer ID value in the ListBox. For Each myLayerInfo As ESRI.ArcGIS.Client.LayerInfo In myLayerInfos ListBox_SubLayerID.Items.Add(myLayerInfo.ID) Next ' If we have more than one sub-layer ID, select the first one as the default. If myLayerInfos.Count > 0 Then ListBox_SubLayerID.SelectedIndex = 0 End If End Sub ' IMPORTANT NOTE: ' Each of the four options below accompolish the same result of using the ArcGISTiledMapServiceLayer.GetDetails ' Method to display a sub-layer Name in the TextBox. The various options are shown to demonstrate different ' coding styles you may want to consider using. Options #1 and #2 are beneficial for small bits of code. ' The external sub-routine options (#3 and #4) are better when the coding algorithms get longer and more ' complicated. #Region "Option1: in-line lambda version" Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) ' Clear out any prior sub-layer ID text value. TextBox_SubLayerName.Text = "" ' Get the ArcGISTiledMapServiceLayer. Dim myArcGISTiledMapServiceLayer As ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = CType(Map1.Layers("Soil_Survey_Map"), ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) ' Get the user selected sub-layer ID value. Dim mySubLayerID As Integer = ListBox_SubLayerID.SelectedValue ' Use a lambda expression for the ArcGISTiledMapServiceLayer.GetDetails Method to display the sub-layer Name in the TextBox. myArcGISTiledMapServiceLayer.GetDetails(mySubLayerID, Sub(myFeatureLayerInfo As ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo, myException As Exception) If myException Is Nothing Then TextBox_SubLayerName.Text = myFeatureLayerInfo.Name End If End Sub) End Sub #End Region #Region "Option2: Action version" Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) ' Clear out any prior sub-layer ID text value. TextBox_SubLayerName.Text = "" ' Get the ArcGISTiledMapServiceLayer. Dim myArcGISTiledMapServiceLayer As ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer = Nothing myArcGISTiledMapServiceLayer = CType(Map1.Layers("Soil_Survey_Map"), ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) ' Define an Action to handle the work of the ArcGISTiledMapServiceLayer.GetDetails Method to display the sub-layer Name in the TextBox. Dim myAction As Action(Of ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo, Exception) = Sub(myFeatureLayerInfo, myException) If myException Is Nothing Then TextBox_SubLayerName.Text = myFeatureLayerInfo.Name End If End Sub ' Get the user selected sub-layer ID value. Dim mySubLayerID As Integer = ListBox_SubLayerID.SelectedValue ' Invoke the ArcGISTiledMapServiceLayer.GetDetails Method, which will use the Action. myArcGISTiledMapServiceLayer.GetDetails(mySubLayerID, myAction) End Sub #End Region #Region "Option3: external function call via Addressof version" Private Sub Button3_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) ' Clear out any prior sub-layer ID text value. TextBox_SubLayerName.Text = "" ' Get the ArcGISTiledMapServiceLayer. Dim myArcGISTiledMapServiceLayer As ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = CType(Map1.Layers("Soil_Survey_Map"), ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) ' Get the user selected sub-layer ID value. Dim mySubLayerID As Integer = ListBox_SubLayerID.SelectedValue ' Invoke the ArcGISTiledMapServiceLayer.GetDetails Method, which will use an external sub-routine via AddressOf. myArcGISTiledMapServiceLayer.GetDetails(mySubLayerID, AddressOf ShowName) End Sub Private Sub ShowName(myFeatureLayerInfo As ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo, myException As Exception) ' Display the sub-layer Name in the TextBox. If myException Is Nothing Then TextBox_SubLayerName.Text = myFeatureLayerInfo.Name End If End Sub #End Region #Region "Option4: external function call via Action Addressof version" Private Sub Button4_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) ' Clear out any prior sub-layer ID text value. TextBox_SubLayerName.Text = "" ' Get the ArcGISTiledMapServiceLayer. Dim myArcGISTiledMapServiceLayer As ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = CType(Map1.Layers("Soil_Survey_Map"), ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) ' Define an Action to handle the work of the ArcGISTiledMapServiceLayer.GetDetails Method to display the sub-layer Name in the TextBox. Dim myAction As Action(Of ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo, Exception) = AddressOf ShowName2 ' Get the user selected sub-layer ID value. Dim mySubLayerID As Integer = ListBox_SubLayerID.SelectedValue ' Invoke the ArcGISTiledMapServiceLayer.GetDetails Method, which will use the Action. myArcGISTiledMapServiceLayer.GetDetails(mySubLayerID, myAction) End Sub Private Sub ShowName2(myFeatureLayerInfo As ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo, myException As Exception) ' Display the sub-layer Name in the TextBox. If myException Is Nothing Then TextBox_SubLayerName.Text = myFeatureLayerInfo.Name End If End Sub #End Region |
Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8