ArcGIS Pro 2.9 API Reference Guide
CreateLayer(Item,ILayerContainerEdit,LayerPosition,String) Method

ArcGIS.Desktop.Mapping Namespace > LayerFactory Class > CreateLayer Method : CreateLayer(Item,ILayerContainerEdit,LayerPosition,String) Method
An ArcGIS.Desktop.Core.Item
A map or group layer instance to which the Layer will be added
LayerPosition specifies whether the layer should be auto positioned or be on the top or at the bottom
(optional) It not provided, the default display name gets used e.g. the dataset name or alias. (default value = "")
Overloaded. Creates a new Layer instance using the specified ItemInfoValue and adds that to a container such as a map or group layer. Optionally you can provide a name to override the default display name. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
Public Overloads Function CreateLayer( _
   ByVal item As Item, _
   ByVal mapOrGroupLayer As ILayerContainerEdit, _
   Optional ByVal position As LayerPosition, _
   Optional ByVal layerName As String _
) As Layer

Parameters

item
An ArcGIS.Desktop.Core.Item
mapOrGroupLayer
A map or group layer instance to which the Layer will be added
position
LayerPosition specifies whether the layer should be auto positioned or be on the top or at the bottom
layerName
(optional) It not provided, the default display name gets used e.g. the dataset name or alias. (default value = "")

Return Value

Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Remarks
You should always check using LayerFactory.Instance.CanCreateLayerFrom() method before passing an item to this method.
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

LayerFactory Class
LayerFactory Members
Overload List