ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping.DeviceLocation Namespace / MapDeviceLocationService Class / ZoomOrPanToCurrentLocation Method
Set to true to zoom.
Example Version

ZoomOrPanToCurrentLocation Method (MapDeviceLocationService)
Zooms or pans the active map view to the current location, keeping the current device location at the center. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void ZoomOrPanToCurrentLocation( 
   bool zoom
)

Parameters

zoom
Set to true to zoom.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
The active map view cannot be null
Remarks
There must be an active map view with an associated map or a System.InvalidOperationException will be thrown
Example
Zoom/Pan The Map To The Most Recent Location
//Must be on the QueuedTask.Run()

if (!MapDeviceLocationService.Instance.IsDeviceLocationEnabled)
  //Calling ZoomOrPanToCurrentLocation w/ no Device Location Enabled
  //Will throw an InvalidOperationException
  return;

// true for zoom, false for pan
MapDeviceLocationService.Instance.ZoomOrPanToCurrentLocation(true);
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also