ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / ZoomToAsync Method / ZoomToAsync(Geometry,Nullable<TimeSpan>,Boolean) Method
The geometry defining the extent in which to zoom.
The amount of time to navigate the view to the new camera position. If null it uses the default navigation duration.
Indicates if the Pitch and Heading should remain the same after the navigation is completed. If false the Heading will be set to 15.0 and the Pitch will be set to -60.0. This parameter only effects 3D views.
Example

In This Topic
    ZoomToAsync(Geometry,Nullable<TimeSpan>,Boolean) Method
    In This Topic
    Zoom the view to the extent defined by a geometry.
    Syntax
    Public Overloads Function ZoomToAsync( _
       ByVal geometry As Geometry, _
       Optional ByVal duration As Nullable(Of TimeSpan), _
       Optional ByVal maintainViewDirection As Boolean _
    ) As Task(Of Boolean)

    Parameters

    geometry
    The geometry defining the extent in which to zoom.
    duration
    The amount of time to navigate the view to the new camera position. If null it uses the default navigation duration.
    maintainViewDirection
    Indicates if the Pitch and Heading should remain the same after the navigation is completed. If false the Heading will be set to 15.0 and the Pitch will be set to -60.0. This parameter only effects 3D views.

    Return Value

    True if the navigation is completed, false if it was interrupted by another view navigation.
    Remarks
    This is equivalent to setting the extent of the view. Use this method in combination with the Extent property to get and then modify the view's extent. If the geometry's spatial reference is in a different spatial reference than the map this method projects the geometry into the spatial reference of the map.
    Example
    Zoom To an Extent
    public Task<bool> ZoomToExtent(double xMin, double yMin, double xMax, double yMax, ArcGIS.Core.Geometry.SpatialReference spatialReference)
    {
      //Get the active map view.
      var mapView = MapView.Active;
      if (mapView == null)
        return Task.FromResult(false);
    
      //Create the envelope
      var envelope = ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(xMin, yMin, xMax, yMax, spatialReference);
    
      //Zoom the view to a given extent.
      return mapView.ZoomToAsync(envelope, TimeSpan.FromSeconds(2));
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also