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


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

IMapServerObjects2.LayerID Property

The layer specified by the map name and layer ID. If the mapName is blank, the default map (active data frame) will be assumed.

[Visual Basic .NET]
Public Function get_LayerID ( _
    ByVal MapName As String, _
    ByVal pLayer As ILayer _
) As Integer
[C#]
public int get_LayerID (
    string MapName,
    ILayer pLayer
);
[C++]
HRESULT get_LayerID(
  BSTR MapName,
  ILayer* pLayer,
  System.Int32* ID
);
[C++]
Parameters
MapName [in]

MapName is a parameter of type BSTR pLayer [in]
pLayer is a parameter of type ILayer* ID [out, retval]
ID is a parameter of type long*

Product Availability

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

Remarks

LayerID is a unique identifier for a layer in a given instance of ArcGIS for Server map service. It is important to note that LayerID, SourceID and the index of layers (see MapLayerInfos) in a map document are not the same. SourceID is used for map service interaction with the GPServer.

When a map service is published, a unique ID is assigned to all layers within the original map document (.mxd) starting from 0 (zero). This ID is accessible from IMapServerObjects2, MapLayerInfo, LayerDescription, MapServerLegendInfo, MapServerIdentifyResult, MapServerFindResult and FeatureExtent.

LayerID is not re-usable and does not change if the order of the layer is changed. This would change the how each layer is ordered in the index of layers. Adding new a layer results in a new LayerID being assigned.  LayerIDs keep incrementing as new layers are added to the map service. The limit of id numbers available is the limit of Long data type.

Please note that if the layer order in the TOC of the original map is changed or if layers are added/removed, the IDs will change accordingly.

See Also

IMapServerObjects2 Interface