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 FeatureLayer from Layer Index Number | TimeControl Playback | Set Data Source | Get Index Number from Layer Name | Get GeoFeatureLayer 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