ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping.DeviceLocation Namespace / MapDeviceLocationService Class / SetDeviceLocationEnabled Method
Set to true to enable the current DeviceLocationSource. False to disable.
Example

In This Topic
    SetDeviceLocationEnabled Method (MapDeviceLocationService)
    In This Topic
    Enables (or disables) the current DeviceLocationSource. Use ArcGIS.Desktop.Core.DeviceLocation.IDeviceLocationService.Open prior to enabling the DeviceLocationSource. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetDeviceLocationEnabled( 
       bool enable
    )
    Public Sub SetDeviceLocationEnabled( _
       ByVal enable As Boolean _
    ) 

    Parameters

    enable
    Set to true to enable the current DeviceLocationSource. False to disable.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    The active map view is null.
    A DeviceLocationSource must be open.
    Remarks
    There must be an active map view with an associated map or an System.InvalidOperationException will be thrown.

    Set MapDeviceLocationOptions.DeviceLocationVisibility = true to display the location on the map view when the device location source is enabled. Refer to SetDeviceLocationOptions.

    Example
    Enable/Disable Current Device Location Source For the Map
    bool enabled = MapDeviceLocationService.Instance.IsDeviceLocationEnabled;
    
    await QueuedTask.Run(() =>
    {
      MapDeviceLocationService.Instance.SetDeviceLocationEnabled(!enabled);
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also