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,
long* 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
Remarks
LayerID is a unique identifier for a layer in a given instance of ArcGIS Server map service. It is important to note that LayerID, SourceID and the index of layers (see MapLayerInfos) in 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.