ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ILayerFactory Interface / CreateLayer Method / CreateLayer(Uri,ILayerContainerEdit,Int32,String) Method
An URI represents the path or url to a dataset or .lyrx or .lpkx file.
A map or group layer instance where the Layer will be added
The position of the layer in the map or group layer. 0 represents the top most position.
(optional) When it is not provided, the default display name gets used e.g. the dataset name or alias. (default value = "")
Example

In This Topic
    CreateLayer(Uri,ILayerContainerEdit,Int32,String) Method
    In This Topic
    Creates a new Layer instance with the specified path to a dataset and adds it to a container such as a map or a 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
    Overloads Function CreateLayer( _
       ByVal dataUri As Uri, _
       ByVal container As ILayerContainerEdit, _
       Optional ByVal index As Integer, _
       Optional ByVal layerName As String _
    ) As Layer

    Parameters

    dataUri
    An URI represents the path or url to a dataset or .lyrx or .lpkx file.
    container
    A map or group layer instance where the Layer will be added
    index
    The position of the layer in the map or group layer. 0 represents the top most position.
    layerName
    (optional) When it is not provided, the default display name gets used e.g. the dataset name or alias. (default value = "")
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    DataUri or conainer is null.
    Example
    Create Stream Layer with URI
    //Must be on the QueuedTask
    var url = "https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer";
    var createParam = new FeatureLayerCreationParams(new Uri(url))
    {
      IsVisible = false //turned off by default
    };
    var streamLayer = LayerFactory.Instance.CreateLayer<StreamLayer>(createParam, map);
    
    //or use "original" create layer (will be visible by default)
    Uri uri = new Uri(url);
    streamLayer = LayerFactory.Instance.CreateLayer(uri, map) as StreamLayer;
    streamLayer.SetVisibility(false);//turn off
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also