ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Presentations Namespace / MapPresentationPage Class / SetCamera Method / SetCamera(Layer) Method
Layer
Example

In This Topic
    SetCamera(Layer) Method
    In This Topic
    Sets the map page extent using the layer's extent. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetCamera( 
       Layer layer
    )
    Public Overloads Sub SetCamera( _
       ByVal layer As Layer _
    ) 

    Parameters

    layer
    Layer
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Zoom map page to extent of a single layer
    {
      await QueuedTask.Run(() =>
      {
        //Reference map page
        var mpage = activePresentationView.Presentation.GetPage(4) as MapPresentationPage;
    
        //Reference map and layer
        MapProjectItem mp = Project.Current.FindItem("Page name") as MapProjectItem;
        Map map = mp.GetMap();
        FeatureLayer lyr = map.FindLayers("GreatLakes").First() as FeatureLayer;
    
        //Set the map frame extent to all features in the layer
        mpage.SetCamera(lyr);
      });
    }
    Requirements

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

    ArcGIS Pro version: 3.5 or higher.
    See Also