public static IMapDeviceLocationService Instance {get;}
Public Shared ReadOnly Property Instance As IMapDeviceLocationService
public static IMapDeviceLocationService Instance {get;}
Public Shared ReadOnly Property Instance As IMapDeviceLocationService
{
bool enabled = MapDeviceLocationService.Instance.IsDeviceLocationEnabled;
await QueuedTask.Run(() =>
{
MapDeviceLocationService.Instance.SetDeviceLocationEnabled(!enabled);
});
}
{
//Gets the current device location options used by the MapDeviceLocationService
var options = MapDeviceLocationService.Instance.GetDeviceLocationOptions();
//Device location visibility on the map
var visibility = options.DeviceLocationVisibility;
//MappingDeviceLocationNavigationMode
var navMode = options.NavigationMode;
//Heading of the location from the device points to the top of the screen
var trackUp = options.TrackUpNavigation;
//Show accuracy buffer on the map
var showBuffer = options.ShowAccuracyBuffer;
}
{
//Checks if the current device location source is enabled on the map
if (MapDeviceLocationService.Instance.IsDeviceLocationEnabled)
{
//The Device Location Source is Enabled
}
}
{
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
});
});
}
{
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);
});
}
{
// 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));
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)