ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Camera Class
Members Example

In This Topic
    Camera Class
    In This Topic
    Represents an object that defines the displayed content of a view via its viewing location and viewing direction.
    Object Model
    Camera ClassSpatialReference Class
    Syntax
    public class Camera 
    Public Class Camera 
    Remarks

    Both 2D and 3D views define and manage what is being displayed using a camera object. You can get the current camera for the view using the MapView.Camera property.

    In 2D, the camera defines its viewing location using X and Y. The values are in the same units as those defined by the camera's SpatialReference. This will be the center point of the 2D view's extent. The viewing direction, or rotation, of the map is defined using the camera's Heading property. The camera's Scale property then defines how far the view is zoomed in or out, and the 2D view will be able to display content for that area. You can also get the extent from the view using the MapView.Extent property.

    In 3D, the camera defines its viewing location using X, Y and Z. As with 2D, the values are stored in the same units as those defined by the camera's SpatialReference, with the additional possibility that XY units and Z units may be different. This will be the central position for the 3D view, as though a helicopter was hovering in that location. The viewing direction is defined by a combination of the Heading, Pitch, and Roll properties, which will rotate, tilt, and roll how the camera looks at the content around it, and the 3D view will be able to display content for the defined frustum.

    Example
    Rotate the map view
    public Task<bool> RotateView(double heading)
    {
      //Get the active map view.
      var mapView = MapView.Active;
      if (mapView == null)
        return Task.FromResult(false);
    
      //Get the camera for the view, adjust the heading and zoom to the new camera position.
      var camera = mapView.Camera;
      camera.Heading = heading;
      return mapView.ZoomToAsync(camera, TimeSpan.Zero);
    }
    
    // or use the synchronous method
    public Task<bool> RotateViewAsync(double heading)
    {
      return QueuedTask.Run(() =>
      {
        //Get the active map view.
        var mapView = MapView.Active;
        if (mapView == null)
          return false;
    
        //Get the camera for the view, adjust the heading and zoom to the new camera position.
        var camera = mapView.Camera;
        camera.Heading = heading;
        return mapView.ZoomTo(camera, TimeSpan.Zero);
      });
    }
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.Camera

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also