This document is archived and information here might be outdated.  Recommended version.


IMap.Layer Property (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IM > IMap Interface > IMap.Layer Property
ArcGIS Developer Help

IMap.Layer Property

The layer at the given index.

[Visual Basic .NET]
Public Function get_Layer ( _
    ByVal Index As Integer _
) As ILayer
[C#]
public ILayer get_Layer (
    int Index
);
[C++]
HRESULT get_Layer(
  long Index,
  ILayer** Layer
);
[C++]
Parameters
Index [in]

Index is a parameter of type long Layer [out, retval]
Layer is a parameter of type ILayer**

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

Maps are typically composed of numerous layers from various data sources.  Use the Layer property to access a particular layer in a map.  The collection of layers is 0-based.  Use the Layer property in conjunction with the LayerCount property to loop through all the layers in the map.

The Layer property returns an ILayer reference; attempt a Query Interface to determine the type of layer object.  For example, do not assume that all layers in a map are FeatureLayers. Valid layers are those that implement ILayer and IDataLayer.

Each Map also has a basic graphics layer (CompositeGraphicLayer) that is not comprised in the collection of layers returned by this property; a reference to this layer is obtainable through the BasicGraphicsLayer property.

See Also

IMap Interface | IMap.LayerCount Property

.NET Samples

Dynamic cache layer manager controller Editing using a custom form Custom selection extension Create a custom selection extension by extending ArcObjects Create a custom selection extension by extending ArcObjects