ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping.DeviceLocation Namespace / IMapDeviceLocationService Interface / IsDeviceLocationEnabled Property
Example

In This Topic
    IsDeviceLocationEnabled Property (IMapDeviceLocationService)
    In This Topic
    Gets the enabled state of the current DeviceLocationSource.
    Syntax
    bool IsDeviceLocationEnabled {get;}
    ReadOnly Property IsDeviceLocationEnabled As Boolean
    Example
    Enable/Disable Current Device Location Source For the Map
    {
      bool enabled = MapDeviceLocationService.Instance.IsDeviceLocationEnabled;
      await QueuedTask.Run(() =>
      {
        MapDeviceLocationService.Instance.SetDeviceLocationEnabled(!enabled);
      });
    }
    Check if The Current Device Location Is Enabled On The Map
    {
      //Checks if the current device location source is enabled on the map
      if (MapDeviceLocationService.Instance.IsDeviceLocationEnabled)
      {
        //The Device Location Source is Enabled
      }
    }
    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
          });
      });
    }
    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