ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Mapping.DeviceLocation Namespace / MappingDeviceLocationNavigationMode Enumeration
Example Example

In This Topic
    MappingDeviceLocationNavigationMode Enumeration
    In This Topic
    Specifies how the current map view is repositioned using the open device source location (i.e via GPS/GNSS).
    Syntax
    public enum MappingDeviceLocationNavigationMode : System.Enum, System.IComparable, System.IConvertible, System.IFormattable  
    Public Enum MappingDeviceLocationNavigationMode 
       Inherits System.Enum
       Implements System.IComparable, System.IConvertible, System.IFormattable 
    Members
    MemberDescription
    KeepAtCenter Keep map view centered at the device location.
    KeepWithinView Center map view at the device location only when the device location goes outside of the current extent.
    None Map view's extent does not get changed automatically.
    Example
    Get Current Map Device Location Options
    var options = MapDeviceLocationService.Instance.GetDeviceLocationOptions();
    
    var visibility = options.DeviceLocationVisibility;
    var navMode = options.NavigationMode;
    var trackUp = options.TrackUpNavigation;
    var showBuffer = options.ShowAccuracyBuffer;
    
    Set Current Map Device Location Options
    //Must be on the 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;
    
    var map = MapView.Active.Map;
    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
    var currentOptions = MapDeviceLocationService.Instance.GetDeviceLocationOptions();
    if (currentOptions == null)
      return;
    
    currentOptions.DeviceLocationVisibility = true;
    currentOptions.NavigationMode = MappingDeviceLocationNavigationMode.KeepAtCenter;
    
    await QueuedTask.Run(() =>
    {
      MapDeviceLocationService.Instance.SetDeviceLocationOptions(currentOptions);
    });
    Inheritance Hierarchy

    System.Object
       System.ValueType
          System.Enum
             ArcGIS.Desktop.Mapping.DeviceLocation.MappingDeviceLocationNavigationMode

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also