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


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

IMap.Layers Property

The layers in the map of the type specified in the uid. If recursive is true it will return layers in group layers.

[Visual Basic .NET]
Public Function get_Layers ( _
    [ByVal uid As UID], _
    [ByVal recursive As Boolean] _
) As IEnumLayer
[C#]
public IEnumLayer get_Layers (
    UID uid,
    bool recursive
);
[C++]
HRESULT get_Layers(
  IUID* uid,
  VARIANT_BOOL recursive,
  IEnumLayer** Layers
);
[C++]
Parameters
uid [in, optional, defaultvalue()]

uid is a parameter of type IUID* recursive [in, optional, defaultvalue()]
recursive is a parameter of type bool Layers [out, retval]
Layers is a parameter of type IEnumLayer**

Product Availability

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

Description

UID specifies the interface identifier (GUID) that represents the type of layer you want returned.

recursive Use True to also return the layers inside group layers.

See the sample code associated with the FeatureSelection property for an example of use.

Remarks

The Layers property returns an IEnumLayer which consists of only those layers with the type specified by the input interface unique indentifier. The Layer property provides access to all of the Layers in a map; using the Layers property however, you can access just the layers of a particular type. For example, use this property to get a collection of FeatureLayers only. To create this collection use IGeoFeatureLayer's GUID as the FeatureLayer object is the only type of layer that implements this interface. Similarly, to get just a collection of the graphics layers, pass the IGraphicsLayer's GUID. Use IDataLayer if you want all the layers that have data in them, this would not include GroupLayers for example. Layers that implement IDataLayer include FeatureLayers, FDOGraphicsLayers (Annotation), TinLayer, RasterLayer, and CoverageAnnotationLayer.
Here are the GUIDs for some of the common intefaces searched for:
{6CA416B1-E160-11D2-9F4E-00C04F6BC78E} IDataLayer
{40A9E885-5533-11d0-98BE-00805F7CED21} IFeatureLayer
{E156D7E5-22AF-11D3-9F99-00C04F6BC78E} IGeoFeatureLayer
{34B2EF81-F4AC-11D1-A245-080009B6F22B} IGraphicsLayer
{5CEAE408-4C0A-437F-9DB3-054D83919850} IFDOGraphicsLayer
{0C22A4C7-DAFD-11D2-9F46-00C04F6BC78E} ICoverageAnnotationLayer
{EDAD6644-1810-11D1-86AE-0000F8751720} IGroupLayer
[C++]

In C++ you can get the GUID of an interface using __uuidof(expression).

See Also

IMap Interface

.NET Samples

Graphics layers ToolControl Multivariate renderer Schematic diagram auto refresh Custom selection extension Create a custom selection extension by extending ArcObjects Subset network evaluators