ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / LayerFactory Class / CreateLayers Method / CreateLayers(BulkLayerCreationParams,ILayerContainerEdit) Method
A BulkLayerCreationParams object.
A map or group layer where the Layers will be added.
Example Version

CreateLayers(BulkLayerCreationParams,ILayerContainerEdit) Method
Creates a readonly list of new Layer instances using the specified BulkLayerCreationParams and adds it to a container such as a map. This method must be called on the MCT. Use QueuedTask.Run.
Syntax

Parameters

layerParams
A BulkLayerCreationParams object.
container
A map or group layer where the Layers will be added.

Return Value

A Readonly list of Layer.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
layerParams or container is null.
An elevation surface layer cannot be used as a container for bulk layer creation.
Unable to bulk create layers with a combination of standard and custom items.
Example
Create mutliple layers with BulkLayerCreationParams
  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 }; ;

  // set the index and visibility
  var blkParams = new BulkLayerCreationParams(uris);
  blkParams.MapMemberPosition = MapMemberPosition.Index;
  blkParams.MapMemberIndex = 2;
  blkParams.IsVisible = false;

  var layers = LayerFactory.Instance.CreateLayers(blkParams, MapView.Active.Map);
}

Add a GeoPackage to the Map
string pathToGeoPackage = @"C:\Data\Geopackage\flooding.gpkg";
//Create lists to hold the URIs of the layers and tables in the geopackage
var layerUris = new List<Uri>();
var tableUris = new List<Uri>();
//Create an item from the geopackage
var item = ItemFactory.Instance.Create(pathToGeoPackage, ItemFactory.ItemType.PathItem);
var children = item.GetItems();
//Collect the table and spatial data in the geopackage
foreach (var child in children)
{
  var childPath = child.Path;

  if (child.TypeID == "sqlite_table")
    tableUris.Add(new Uri(childPath));
  else
    layerUris.Add(new Uri(childPath));
}
//Add the spatial data in the geopackage using the BulkLayerCreationParams
if (layerUris.Count > 0)
{
  BulkLayerCreationParams bulklcp = new BulkLayerCreationParams(layerUris);
  LayerFactory.Instance.CreateLayers(bulklcp, MapView.Active.Map);
}
// add the tables separately
foreach (var tableUri in tableUris)
{
  StandaloneTableFactory.Instance.CreateStandaloneTable(tableUri, MapView.Active.Map);
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3.4 or higher.
See Also