{
bool enabled = MapDeviceLocationService.Instance.IsDeviceLocationEnabled;
await QueuedTask.Run(() =>
{
MapDeviceLocationService.Instance.SetDeviceLocationEnabled(!enabled);
});
}
{
//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);
});
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)