ZoomToAsync(Geometry,Nullable<TimeSpan>,Boolean) Method
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.
Zoom To Extent Asynchronous
public async Task<bool> ZoomToExtentAsync(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 false;
//Create the envelope
var envelope = await QueuedTask.Run(() => ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(xMin, yMin, xMax, yMax, spatialReference));
//Zoom the view to a given extent.
return await mapView.ZoomToAsync(envelope, TimeSpan.FromSeconds(2));
}
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));
}
Target Platforms: Windows 11, Windows 10, Windows 8.1
ArcGIS Pro version: 2.0 or higher.