ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Camera Class / SpatialReference Property
Example

In This Topic
    SpatialReference Property (Camera)
    In This Topic
    Gets or sets the Spatial Reference of the Camera. This property applies to both 2D and 3D views.
    Syntax
    public SpatialReference SpatialReference {get; set;}
    Public Property SpatialReference As SpatialReference
    Remarks
    X, Y, Z, and SpatialReference describe the position of the viewing location. Setting an appropriate spatial reference for the position of the camera allows the camera to be applied across views with different spatial references. The camera's relative location to the Earth remains unchanged. Project the camera if its spatial reference has a different datum than the map's spatial reference using the ArcGIS.Core.Geometry api. If the spatial reference is null the camera assumes the spatial reference of the map to which it is applied.
    Example
    Project Camera
    public Task<Camera> ProjectCamera(Camera camera, ArcGIS.Core.Geometry.SpatialReference spatialReference)
    {
      return QueuedTask.Run(() =>
      {
        var mapPoint = MapPointBuilderEx.CreateMapPoint(camera.X, camera.Y, camera.Z, camera.SpatialReference);
        var newPoint = GeometryEngine.Instance.Project(mapPoint, spatialReference) as MapPoint;
        var newCamera = new Camera()
        {
          X = newPoint.X,
          Y = newPoint.Y,
          Z = newPoint.Z,
          Scale = camera.Scale,
          Pitch = camera.Pitch,
          Heading = camera.Heading,
          Roll = camera.Roll,
          Viewpoint = camera.Viewpoint,
          SpatialReference = spatialReference
        };
        return newCamera;
      });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also