ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping.DeviceLocation Namespace / IMapDeviceLocationService Interface / ZoomOrPanToCurrentLocation Method
System.Boolean
Example

In This Topic
    ZoomOrPanToCurrentLocation Method (IMapDeviceLocationService)
    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
    void ZoomOrPanToCurrentLocation( 
       bool zoom
    )
    Sub ZoomOrPanToCurrentLocation( _
       ByVal zoom As Boolean _
    ) 

    Parameters

    zoom
    System.Boolean
    Example
    Zoom/Pan The Map To The Most Recent Location
    {
      await 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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also