ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping.DeviceLocation Namespace / MapDeviceLocationService Class / SetDeviceLocationOptions Method
A MapDeviceLocationOptions
Example

In This Topic
    SetDeviceLocationOptions Method (MapDeviceLocationService)
    In This Topic
    Sets a MapDeviceLocationOptions to update the current MapDeviceLocationService settings. This method must be called on the MCT. Use QueuedTask.Run. Use QueuedTask.Run.
    Syntax
    Public Sub SetDeviceLocationOptions( _
       ByVal options As MapDeviceLocationOptions _
    ) 
    public void SetDeviceLocationOptions( 
       MapDeviceLocationOptions options
    )

    Parameters

    options
    A MapDeviceLocationOptions
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Value cannot be null: options
    The active map view cannot be null
    A DeviceLocationSource must be open
    Remarks
    A valid DeviceLocationSource must be open or a System.InvalidOperationException will be thrown. Refer to ArcGIS.Desktop.Core.DeviceLocation.IDeviceLocationService.Open.
    There must be an active map view with an associated map.
    Example
    Set Current Map Device Location Options
    {
        //Note: Run within a QueuedTask
        //Check there is a source first...
        if (DeviceLocationService.Instance.GetSource() == null)
            //Setting DeviceLocationOptions w/ no Device Location Source
            //Will throw an InvalidOperationException
            return;
    
        if (!MapDeviceLocationService.Instance.IsDeviceLocationEnabled)
            //Setting DeviceLocationOptions w/ no Device Location Enabled
            //Will throw an InvalidOperationException
            return;
    
        MapDeviceLocationService.Instance.SetDeviceLocationOptions(
          new MapDeviceLocationOptions()
          {
              DeviceLocationVisibility = true,
              NavigationMode = MappingDeviceLocationNavigationMode.KeepAtCenter,
              TrackUpNavigation = true
          });
    }
    Set map view to always be centered on the device location
    {
        // Get the MapDeviceLocationOptions currently used by the MapDeviceLocationService
    
        var currentOptions = MapDeviceLocationService.Instance.GetDeviceLocationOptions();
        if (currentOptions == null)
            return;
        // Set the device location visibility on the map to true
        currentOptions.DeviceLocationVisibility = true;
        //Set the navigation mode to keep the device location at the center of the map
        currentOptions.NavigationMode = MappingDeviceLocationNavigationMode.KeepAtCenter;
        //Note: Run within a QueuedTask
        //Sets the MapDeviceLocationOptions to be updates with these values
        MapDeviceLocationService.Instance.SetDeviceLocationOptions(currentOptions);
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also