ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / ZoomTo Method / ZoomTo(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
    ZoomTo(Camera,Nullable<TimeSpan>) Method
    In This Topic
    Zoom the view to a camera position. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Function ZoomTo( _
       ByVal camera As Camera, _
       Optional ByVal duration As Nullable(Of TimeSpan) _
    ) As 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.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    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