SetDeviceLocationOptions Method (MapDeviceLocationService)
Sets a
MapDeviceLocationOptions to update the current MapDeviceLocationService settings. This method must be called on the MCT. Use QueuedTask.Run. Use QueuedTask.Run.
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);
});
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.