PanTo(IEnumerable<Layer>,Boolean,Nullable<TimeSpan>) Method
Pan the view to the extent of one or more layers. This method must be called on the MCT. Use QueuedTask.Run.
Parameters
- layers
- An enumeration of layers containing the features in which to pan.
- selectedOnly
- Indicates whether only the selected features for a layer should be used to determine 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 Visible Layers Synchronous
public Task<bool> PanToAllVisibleLayersAsync()
{
return QueuedTask.Run(() =>
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return false;
//Pan to all visible layers in the map.
var visibleLayers = mapView.Map.Layers.Where(l => l.IsVisible);
return mapView.PanTo(visibleLayers);
});
}
Pan To Visible Layers
public Task<bool> PanToAllVisibleLayersAsync()
{
return QueuedTask.Run(() =>
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return false;
//Pan to all visible layers in the map.
var visibleLayers = mapView.Map.Layers.Where(l => l.IsVisible);
return mapView.PanTo(visibleLayers);
});
}
Target Platforms: Windows 11, Windows 10, Windows 8.1
ArcGIS Pro version: 2.0 or higher.