ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / LayerCreationParams Class / LayerCreationParams Constructor / LayerCreationParams Constructor(Uri)
A System.Uri represents the path or url to a dataset or .lyrx or .lpkx file.
Example

In This Topic
    LayerCreationParams Constructor(Uri)
    In This Topic
    Creates a parameter object with System.Uri.
    Syntax
    Public Function New( _
       ByVal uri As Uri _
    )
    public LayerCreationParams( 
       Uri uri
    )

    Parameters

    uri
    A System.Uri represents the path or url to a dataset or .lyrx or .lpkx file.
    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
    Connect to an AGS Service using ServiceConnectionProperties
    {
        //Connect to the AGS service. Note: the connection will persist for the
        //duration of the Pro session.
        var serverUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services";
    
        var username = "user1";
        var password = "user1";
    
        //at any point before creating a layer, first make a connection to the server
        //if one has not been already established for the current session
        var uri = new Uri(serverUrl);
        var props = new ServiceConnectionProperties(uri)
        {
            User = username
        };
        //It is preferred that you use the Windows Credential Manager to store the password
    
        //However, it can be set as clear text if you so choose
        props.Password = password; //not recommended
    
    
        //Establish a connection to the server at any point in time _before_
        //creating a layer from a service on the server
        //Note: Needs QueuedTask to run
        var gdb = new Geodatabase(props);
        gdb.Dispose();//you do not need the geodatabase object after you have connected.
    
        //later in the session, as needed...create a layer from one of the services
        //on the server
        var serviceUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure/MapServer";
        var lc = new LayerCreationParams(new Uri(serviceUrl));
        //Note: Needs QueuedTask to run
        LayerFactory.Instance.CreateLayer<MapImageLayer>(lc, map);
    }
    Create a Scene Layer
    {
      // Note: call within QueuedTask.Run()
      {
        //Create with initial visibility set to false. Add to current scene
        var createparams = new LayerCreationParams(new Uri(sceneLayerUrl, UriKind.Absolute))
        {
          IsVisible = false
        };
    
        //cast to specific type of scene layer being created - in this case FeatureSceneLayer
        var sceneLayer = LayerFactory.Instance.CreateLayer<Layer>(
                 createparams, MapView.Active.Map) as FeatureSceneLayer;
        //or...specify the cast directly
        var sceneLayer2 = LayerFactory.Instance.CreateLayer<FeatureSceneLayer>(
                 createparams, MapView.Active.Map);
        //ditto for BuildingSceneLayer, PointCloudSceneLayer, IntegratedMeshSceneLayer
        //...
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also