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


IMap.Layer Property (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Carto)  

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 Snippets

Get GeoFeatureLayer from Layer Index Number | Get Index Number from Layer Name | Set Data Source | TimeControl Playback | Get FeatureLayer from Layer Index Number | Toggle Visibility Of Composite Layer

.NET Samples

Convert part to feature command (Code Files: ConvertPart) | Editing using a custom form (Code Files: EditorForm) | Dynamic cache layer manager controller (Code Files: CacheManagerDlg) | Custom selection extension (Code Files: SelectionExtension) | Create a custom selection extension by extending ArcObjects (Code Files: SelectionExtension ZoomToLayerMultiItem)

.NET Related Topics

Converting labels to geodatabase annotation for a single layer | Converting labels to map annotation for a single layer | How to create an edit session | How to use symbol level drawing | Managing application state | Persisting cache information for use in dynamic display