ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping.DeviceLocation Namespace / IMapDeviceLocationService Interface / SetDeviceLocationOptions Method
MapDeviceLocationOptions
Example

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

    Parameters

    options
    MapDeviceLocationOptions
    Example
    Set Current Map Device Location Options
    {
      await QueuedTask.Run(() =>
      {
        //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;
      //Sets the MapDeviceLocationOptions to be updates with these values
      await QueuedTask.Run(() =>
        MapDeviceLocationService.Instance.SetDeviceLocationOptions(currentOptions));
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also