ZoomTo(Camera,Nullable<TimeSpan>) Method
Zoom the view to a camera position. This method must be called on the MCT. Use QueuedTask.Run.
Parameters
- camera
- The new camera to use for the view.
- duration
- The amount of time to navigate the view to the new camera position. If null it uses the default navigation duration.
Return Value
True if the navigation is completed, false if it was interrupted by another view navigation.
Rotate Map View Synchronous
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);
});
}
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.