Heading Property (Camera)
Gets or sets the Heading of the Camera, in degrees from North. 0 is North, 90 is West, 180 is South, -90 is East, etc. This property applies to both 2D and 3D views.
public double Heading {get; set;}
Public Property Heading As Double
Rotate Map View Asynchronous
public void RotateView(double heading)
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return;
//Get the camera for the view, adjust the heading and zoom to the new camera position.
var camera = mapView.Camera;
camera.Heading = heading;
mapView.ZoomToAsync(camera, TimeSpan.Zero);
}
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);
});
}
Target Platforms: Windows 11, Windows 10, Windows 8.1
ArcGIS Pro version: 2.0 or higher.