ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / ZoomToAsync Method / ZoomToAsync(Camera,Nullable<TimeSpan>) Method
The new camera to use for the view.
The amount of time to navigate the view to the new camera position. If null it uses the default navigation duration.
Example

In This Topic
    ZoomToAsync(Camera,Nullable<TimeSpan>) Method
    In This Topic
    Zoom the view to a camera position.
    Syntax
    Public Overloads Function ZoomToAsync( _
       ByVal camera As Camera, _
       Optional ByVal duration As Nullable(Of TimeSpan) _
    ) As Task(Of Boolean)

    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.
    Remarks
    This is equivalent to setting the camera position for the view. Use this method in combination with Camera to get and then modify the position of the view's camera. If the camera's spatial reference is in a different spatial reference than the map this method projects the camera into the spatial reference of the map.
    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);
      });
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also