ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / BulkLayerCreationParams Class
Members Example

In This Topic
    BulkLayerCreationParams Class
    In This Topic
    Represents an object to initialize and create multiple layers with pre-defined properties. See LayerFactory.CreateLayers.
    Syntax
    Public Class BulkLayerCreationParams 
       Inherits BulkMapMemberCreationParams
    public class BulkLayerCreationParams : BulkMapMemberCreationParams 
    Example
    Create multiple layers with BulkLayerCreationParams 1
    {
        //Uris to the datasets for the layers to be created
        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");
        // Create a list of URIs to be used for creating multiple layers
        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;
        // Create multiple layers using the BulkLayerCreationParams
        //Note: Needs QueuedTask to run
        var layers = LayerFactory.Instance.CreateLayers(blkParams, MapView.Active.Map);
    }
    Create multiple layers with BulkLayerCreationParams 2 - invalid
    {
        // get a feature class that is selected in the catalog pane
        Item item = Project.GetCatalogPane().SelectedItems.FirstOrDefault();
    
        var uriShp = new Uri(@"c:\data\roads.shp");
        var lcpShp = new FeatureLayerCreationParams(uriShp);
        lcpShp.Name = "Roads";
        lcpShp.IsVisible = false;
        lcpShp.DefinitionQuery = new DefinitionQuery("shpQuery", "OBJECTID > 10");
    
        var lcpItem = new FeatureLayerCreationParams(item);
        lcpItem.Name = "Census Polygons";
        lcpItem.IsVisible = true;
    
        // list contains a Uri data source and an Item data source
        // LayerFactory.Instance.CreateLayers will throw an ArgumentException
        var lcps = new List<FeatureLayerCreationParams>();
        lcps.Add(lcpShp);
        lcps.Add(lcpItem);
    
        var blkParams = new BulkLayerCreationParams(lcps);
    
        // LayerFactory.Instance.CreateLayers will thrown an ArgumentException
        // because the LayerCreationParams are created using different 
        // types of data sources (1 Uri and 1 Item)
        var layers = LayerFactory.Instance.CreateLayers(blkParams, MapView.Active.Map);
    }
    Create multiple layers with BulkLayerCreationParams 2 - Valid
    {
    
        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 lcpShp = new FeatureLayerCreationParams(uriShp);
        lcpShp.Name = "Roads";
        lcpShp.IsVisible = false;
        lcpShp.DefinitionQuery = new DefinitionQuery("shpQuery", "OBJECTID > 10");
    
        var lcpSde = new FeatureLayerCreationParams(uriSde);
        lcpSde.Name = "Census Polygons";
        lcpSde.IsVisible = true;
    
        var lcpService = new FeatureLayerCreationParams(uri);
        lcpService.Name = "Shelters";
        lcpService.IsVisible = true;
        // set some renderer here ...
        //lcpService.RendererDefinition = ...
    
        var lcps = new List<FeatureLayerCreationParams>();
        lcps.Add(lcpShp);
        lcps.Add(lcpSde);
        lcps.Add(lcpService);
    
        var blkParams = new BulkLayerCreationParams(lcps);
        // set the positioning on the BulkLayerCreationParams
        blkParams.MapMemberPosition = MapMemberPosition.Index;
        blkParams.MapMemberIndex = 0;
    
        var layers = LayerFactory.Instance.CreateLayers(blkParams, MapView.Active.Map);
    }
    Create multiple layers with BulkLayerCreationParams - Using RollbackBehavior
    {
    
        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 lcpShp = new FeatureLayerCreationParams(uriShp);
        lcpShp.Name = "Roads";
        lcpShp.IsVisible = false;
        lcpShp.DefinitionQuery = new DefinitionQuery("shpQuery", "OBJECTID > 10");
    
        var lcpSde = new FeatureLayerCreationParams(uriSde);
        lcpSde.Name = "Census Polygons";
        lcpSde.IsVisible = true;
    
        var lcpService = new FeatureLayerCreationParams(uri);
        lcpService.Name = "Shelters";
        lcpService.IsVisible = true;
        // set some renderer here ...
        //lcpService.RendererDefinition = ...
    
        var lcps = new List<FeatureLayerCreationParams>();
        lcps.Add(lcpShp);
        lcps.Add(lcpSde);
        lcps.Add(lcpService);
    
        var blkParams = new BulkLayerCreationParams(lcps);
        // set the positioning on the BulkLayerCreationParams
        blkParams.MapMemberPosition = MapMemberPosition.Index;
        blkParams.MapMemberIndex = 0;
    
        // set the rollback behavior
        // - rollback if one or more layers cannot be created due to an invalid data source
        blkParams.RollbackBehavior = LayerCreationRollbackBehavior.RollbackOnMissingLayers;
    
        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
        //Note: Needs QueuedTask to run
        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);
        }
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.BaseCreationParams
          ArcGIS.Desktop.Mapping.BulkMapMemberCreationParams
             ArcGIS.Desktop.Mapping.BulkLayerCreationParams

    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.4 or higher.
    See Also