ESRI.ArcGIS.ADF.IMS
Layers Property
See Also  Example Send Feedback
ESRI.ArcGIS.ADF.IMS.Carto Namespace > MapView Class : Layers Property




Gets or sets the layers of the current MapView.

Syntax

Visual Basic (Declaration) 
Public Property Layers As LayerCollection
Visual Basic (Usage)Copy Code
Dim instance As MapView
Dim value As LayerCollection
 
instance.Layers = value
 
value = instance.Layers
C# 
public LayerCollection Layers {get; set;}

Example

The following example gets a reference to the map's layer colleciton, then iterates through the collection, and prints out whether the layer is a feature (vector) layer or image layer. The code assumes an existing MapView object.
C#Copy Code
StringBuilder sb = new StringBuilder();
 
LayerCollection mapLayers = mapView.Layers;
 
for (int i = 0; i < mapLayers.Count; i++)
{
    if (mapLayers[i] is FeatureLayer)
    {
        FeatureLayer fLyr = (FeatureLayer) mapLayers[i];
        sb.Append(fLyr.Name + " is a feature layer, type " + fLyr.Type.ToString() + "<br>");
    }
    else if (mapLayers[i] is ImageLayer)
    {
        ImageLayer iLyr = (ImageLayer) mapLayers[i];
        sb.Append(iLyr.Name + " is an image layer.<br>");
    }
}
Label1.Text = sb.ToString();
Visual BasicCopy Code
Dim sb As New StringBuilder()
 
Dim mapLayers As LayerCollection = mapView.Layers
Dim i As Integer
 
For i = 0 To mapLayers.Count-1
 
    If mapLayers(i) Is FeatureLayer
    
        FeatureLayer fLyr = CType(mapLayers(i), FeatureLayer)
        sb.Append(fLyr.Name + " is a feature layer, type " + fLyr.Type.ToString() + "<br>")
    
    Else If mapLayers(i) Is ImageLayer
    
        ImageLayer iLyr = CType(mapLayers(i), ImageLayer)
        sb.Append(iLyr.Name + " is an image layer.<br>")
    End If
Next
Label1.Text = sb.ToString()

Remarks

Layers allows access to the layers in the map. Use the layer collection to access an individual layer, from which layer properties can be read and set. For example, if you want to set the visibility of a layer, obtain the layer from this collection and set its Visible property.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2011 All Rights Reserved.