Adds a layer to the map.
[Visual Basic .NET] Public Sub AddLayer ( _ ByVal Layer As ILayer _ )
[C#] public void AddLayer ( ILayer Layer );
[C++]
HRESULT AddLayer(
ILayer* Layer
);
[C++]Parameters
Layer [in]Layer is a parameter of type ILayer
Product Availability
Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.
Remarks
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