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

IMap.AddLayer Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IM > IMap Interface > IMap.AddLayer Method
ArcGIS Developer Help

IMap.AddLayer Method

Adds a layer to the map.

[Visual Basic .NET]
Public Sub AddLayer ( _
    ByVal Layer As ILayer _
public void AddLayer (
    ILayer Layer
  ILayer* Layer
Layer [in]

Layer is a parameter of type ILayer*

Product Availability

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


The AddLayer method adds a layer to the Map. Use the LayerCount property to get the total number of layers in the map.
AddLayer automatically attempts to set the Map's SpatialReference property if a coordinate system has not yet been defined for the map.  When the SpatialReference property is set, the Map's MapUnits and DistanceUnits properties are additionally set.  AddLayer also sets the spatial reference of the layer (ILayer::SpatialReference ). 
If no layers have a spatial reference, AddLayer checks the extent of the first layer (ILayer::AreaOfInterest) and if it has coordinates that look like geographic coordinates (XMin >= -180 and XMax <= 180 and YMin >= -90 and YMax <= 90), ArcMap assumes the data is in decimal degrees and sets the MapUnits to esriDecimalDegrees and DistanceUnits to esriMiles.
If no spatial reference is found and the coordinates do not look like geographic coordinates, ArcMap sets no spatial reference and sets the MapUnits to esriMeters and the DistanceUnits to esriMeters.
The full extent is recalculated each time a layer added.

See Also

IMap Interface | IMap.LayerCount Property | IMap.AddLayers Method