Visual Basic (Declaration) | |
---|---|
Public Property VisibleLayers As Integer() |
C# | |
---|---|
public int[] VisibleLayers {get; set;} |
To set visiblility of an ArcGISDynamicMapServiceLayer when a Silverlight application first loads, define the VisibleLayers Property during the Initialized Event.
The screenshot corresponds to the code example in this document. The Url for the ArcGISDynamicMapServiceLayer was "http://sampleserver1.arcgisonline.com:80/arcgis/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer" and was zoomed into the state of Florida.
Property Value
Integer array containing sub-layer ids.C# | Copy Code |
---|---|
private void ArcGISDynamicMapServiceLayer_Initialized(object sender, System.EventArgs e) { // The myArcGISDynamicMapServiceLayer (an ArcGISDynamicServiceLayer object) and TextBlock_VisibleLayers // (a TextBlock object) were defined previously in the XAML or code-behind. // Get the first layer in the LayerInfo collection. ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ArcGISDynamicMapServiceLayer)Map1.Layers[0]; // VisibleLayers (Read/Write) // ========================== // In this example there are three sub-layers (0, 1, 2) that are turned on by default for the // myArcGISDynamicMapServiceLayer. // Uncomment the next two lines of code to set only the 2nd and 3rd sub-layers to be visible. //int[] myVisibleLayers2 = { 1, 2 }; //myArcGISDynamicMapServiceLayer.VisibleLayers = myVisibleLayers2; // Display which sub-layers (via their index number) are visible in a TextBlock. int[] myVisibleLayers = myArcGISDynamicMapServiceLayer.VisibleLayers; if (myVisibleLayers != null) { string myVisibleLayersText = "Number VisibleLayers: " + myVisibleLayers.Length.ToString(); string myVisibleLayersText2 = ""; int I2 = 0; for (I2 = 0; I2 < myVisibleLayers.Length; I2++) { myVisibleLayersText2 = myVisibleLayersText2 + " " + myVisibleLayers[I2].ToString(); } TextBlock_VisibleLayers.Text = myVisibleLayersText + ". VisibleLayers ID's: " + myVisibleLayersText2; } else { TextBlock_VisibleLayers.Text = "[VisibleLayers not set - Meaning all layers are visible.]"; } } |
VB.NET | Copy Code |
---|---|
Private Sub ArcGISDynamicMapServiceLayer_Initialized(ByVal sender As System.Object, ByVal e As System.EventArgs) ' The myArcGISDynamicMapServiceLayer (an ArcGISDynamicServiceLayer object) and TextBlock_VisibleLayers ' (a TextBlock object) were defined previously in the XAML or code-behind. ' Get the first layer in the LayerInfo collection. Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = Map1.Layers.Item(0) ' VisibleLayers (Read/Write) ' ========================== ' In this example there are three sub-layers (0, 1, 2) that are turned on by default for the ' myArcGISDynamicMapServiceLayer. ' Uncomment the next two lines of code to set only the 2nd and 3rd sub-layers to be visible. 'Dim myVisibleLayers2() As Integer = {1, 2} 'myArcGISDynamicMapServiceLayer.VisibleLayers = myVisibleLayers2 ' Display which sub-layers (via their index number) are visible in a TextBlock. Dim myVisibleLayers() As Integer = myArcGISDynamicMapServiceLayer.VisibleLayers If myVisibleLayers IsNot Nothing Then Dim myVisibleLayersText As String = "Number VisibleLayers: " + myVisibleLayers.Length.ToString Dim myVisibleLayersText2 As String = "" Dim I2 As Integer For I2 = 0 To myVisibleLayers.Length - 1 myVisibleLayersText2 = myVisibleLayersText2 + " " + myVisibleLayers(I2).ToString Next TextBlock_VisibleLayers.Text = myVisibleLayersText + ". VisibleLayers ID's: " + myVisibleLayersText2 Else TextBlock_VisibleLayers.Text = "[VisibleLayers not set - Meaning all layers are visible.]" End If End Sub |
Target Platforms:Windows Phone 7