ArcGIS Pro 3.5 API Reference Guide
ArcGIS.Desktop.Presentations Namespace / MapPresentationPage Class / SetCamera Method / SetCamera(IEnumerable<Layer>) Method
A list of layers.
Example

In This Topic
    SetCamera(IEnumerable<Layer>) Method
    In This Topic
    Sets the map page extent using the extent of multiple layers. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetCamera( 
       IEnumerable<Layer> layers
    )
    Public Overloads Sub SetCamera( _
       ByVal layers As IEnumerable(Of Layer) _
    ) 

    Parameters

    layers
    A list of layers.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Change map page camera settings
    //Must be on the QueuedTask
    await QueuedTask.Run(() =>
    {
      //Reference a map page
      var mpage = activePresentationView.Presentation.GetPage(4) as MapPresentationPage;
    
      //Set the map frame extent based on the new camera's X,Y, Scale and heading values
      Camera cam = new Camera(329997.6648, 6248553.1457, 2403605.8968, 24);
      mpage.SetCamera(cam);
    });
    Zoom map page to extent of a single layer
    //Must be on the QueuedTask
    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, Windows 10

    ArcGIS Pro version: 3.5 or higher.
    See Also