ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / LayerFactory Class / CreateLayers Method / CreateLayers(IEnumerable<Uri>,ILayerContainerEdit,Int32) Method
The set of URIs that represent the path to a set of datasets.
A map or group layer where the Layers will be added.
The position of the first Layer in the map or group layer. 0 represents the top most position.
Example

In This Topic
    CreateLayers(IEnumerable<Uri>,ILayerContainerEdit,Int32) Method
    In This Topic
    Creates a readonly list of new Layer instance for each of the specified dataset paths and adds them to a container such as a map. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    layerUris
    The set of URIs that represent the path to a set of datasets.
    container
    A map or group layer where the Layers will be added.
    index
    The position of the first Layer in the map or group layer. 0 represents the top most position.

    Return Value

    A Readonly list of Layer.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    layerUris or container is null.
    An elevation surface layer cannot be used as a container for bulk layer creation.
    Remarks

    Some sample paths to:

    A FeatureClass in a FileGeodatabase C:\Data\MyFileGDB.gdb\Census
    A shape file in a folder \\Machine\SharedFolder\MySpatialData.dbf
    A RasterDataset in a FileGeodatabase C:\Data\MyFileGDB.gdb\DEM
    A FeatureClass from a SDE C:\Connections\MySDEConnection.sde\Roads
    An image file in a folder \\Machine\SharedFolder\Imagery.tif
    A .lyrx or .lpkx file \\Machine\SharedFolder\Fires.lyrx
    A map service layer http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer
    A feature layer off a map or feature service http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer/0

    Example
    Create multiple layers
    var uriShp = new Uri(@"c:\data\roads.shp");
    var uriSde = new Uri(@"c:\MyDataConnections\MySDE.sde\Census");
    var uri = new Uri(@"http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer/0");
    
    var uris = new List<Uri>() { uriShp, uriSde, uri };
    
    var layers = LayerFactory.Instance.CreateLayers(uris, MapView.Active.Map);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.4 or higher.
    See Also