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

In This Topic
    ZoomOrPanToCurrentLocation Method (MapDeviceLocationService)
    In This Topic
    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 Sub ZoomOrPanToCurrentLocation( _
       ByVal zoom As Boolean _
    ) 
    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
    {
        //Note: Run within a QueuedTask
        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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also