ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / FindLayer Method
The URI of the layer. Which is unique identifier for each layer
(optional) When true the search continues in group layers. (default value = true)
Example

In This Topic
    FindLayer Method (Map)
    In This Topic
    Finds a layer using a URI.
    Syntax
    public Layer FindLayer( 
       string layerURI,
       bool recursive
    )
    Public Function FindLayer( _
       ByVal layerURI As String, _
       Optional ByVal recursive As Boolean _
    ) As Layer

    Parameters

    layerURI
    The URI of the layer. Which is unique identifier for each layer
    recursive
    (optional) When true the search continues in group layers. (default value = true)

    Return Value

    Example
    Find a layer
    //Finds layers by name and returns a read only list of Layers
    IReadOnlyList<Layer> layers = aMap.FindLayers("cities", true);
    
    //Finds a layer using a URI.
    //The Layer URI you pass in helps you search for a specific layer in a map
    var lyrFindLayer = MapView.Active.Map.FindLayer("CIMPATH=map/u_s__states__generalized_.xml");
    
    //This returns a collection of layers of the "name" specified. You can use any Linq expression to query the collection.  
    var lyrExists = MapView.Active.Map.GetLayersAsFlattenedList()
                       .OfType<FeatureLayer>().Any(f => f.Name == "U.S. States (Generalized)");
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also