ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / MapFrame Class / Camera Property
Example

In This Topic
    Camera Property (MapFrame)
    In This Topic
    Gets the camera settings associated with the map frame.
    Syntax
    public Camera Camera {get;}
    Public ReadOnly Property Camera As Camera

    Property Value

    Type: Camera
    Example
    Change map frame camera settings
    {
      //Change a map frame's camera settings.
    
      //Reference MapFrame
      MapFrame mf = layout.FindElement("Map Frame") as MapFrame;
    
      //Reference the camera associated with the map frame and change the scale
      Camera cam = mf.Camera;
      cam.Scale = 100000;
    
      //Set the map frame extent based on the new camera info
      mf.SetCamera(cam);
    }
    Change map frame extent to single feature with 15 percent buffer
    {
      //Change map frame extent to single feature with 10 percent buffer
      await QueuedTask.Run(() =>
      {
        //Reference the mapframe and its associated map
        Map m = mapFrame.Map;
    
        //Reference a feature layer and build a query (to return a single feature)
        FeatureLayer fl = m.FindLayers("GreatLakes").First() as FeatureLayer;
        QueryFilter qf = new QueryFilter();
        string whereClause = "NAME = 'Lake Erie'";
        qf.WhereClause = whereClause;
    
        //Zoom to the feature
        using (ArcGIS.Core.Data.RowCursor rowCursor = fl.Search(qf))
        {
          while (rowCursor.MoveNext())
          {
            //Get the shape from the row and set extent
            using (var feature = rowCursor.Current as ArcGIS.Core.Data.Feature)
            {
              Polygon polygon = feature.GetShape() as Polygon;
              Envelope env = polygon.Extent as Envelope;
              mapFrame.SetCamera(env);
    
              //Zoom out 15 percent
              Camera cam = mapFrame.Camera;
              cam.Scale = cam.Scale * 1.15;
              mapFrame.SetCamera(cam);
            }
          }
        }
      });
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also