PanToAsync(Geometry,Nullable<TimeSpan>) Method
Pan the view to the extent defined by a geometry.
Parameters
- geometry
- The geometry defining the extent in which to pan.
- 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.
Pan To Extent Asynchronous
public async Task<bool> PanToExtentAsync(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));
//Pan the view to a given extent.
return await mapView.PanToAsync(envelope, TimeSpan.FromSeconds(2));
}
Pan To an Extent
public Task<bool> PanToExtent(double xMin, double yMin, double xMax, double yMax, ArcGIS.Core.Geometry.SpatialReference spatialReference)
{
return QueuedTask.Run(() =>
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return false;
//Pan the view to a given extent.
var envelope = ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(xMin, yMin, xMax, yMax, spatialReference);
return mapView.PanTo(envelope);
});
}
public Task<bool> PanToExtentAsync(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);
//Pan the view to a given extent.
return mapView.PanToAsync(envelope, TimeSpan.FromSeconds(2));
}
Target Platforms: Windows 11, Windows 10, Windows 8.1
ArcGIS Pro version: 2.0 or higher.