mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 03:56:29 +02:00
3.0.271
This commit is contained in:
parent
e0c75d5b37
commit
f38b516d25
57 changed files with 12835 additions and 9925 deletions
|
@ -353,7 +353,30 @@ namespace TINK.ViewModel.Map
|
|||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
await MoveMapToCurrentPositionOfUser(status);
|
||||
|
||||
// Get map display area
|
||||
Model.Map.IMapSpan mapSpan = null;
|
||||
if (TinkApp.CenterMapToCurrentLocation && status == Status.Granted)
|
||||
{
|
||||
// Get from smart device
|
||||
mapSpan = await GetFromLocationService(status);
|
||||
}
|
||||
|
||||
if (mapSpan == null)
|
||||
{
|
||||
// Use map display are from COPRI
|
||||
mapSpan = resultStationsAndBikes.GeneralData.InitialMapSpan;
|
||||
}
|
||||
|
||||
if (mapSpan.IsValid)
|
||||
{
|
||||
TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
|
||||
new Xamarin.Forms.GoogleMaps.Position(mapSpan.Center.Latitude, mapSpan.Center.Longitude),
|
||||
new Distance(mapSpan.Radius * 1000));
|
||||
TinkApp.Save();
|
||||
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
|
||||
}
|
||||
|
||||
m_oViewUpdateManager = CreateUpdateTask();
|
||||
|
||||
|
@ -462,41 +485,31 @@ namespace TINK.ViewModel.Map
|
|||
/// Moves the map to the current position of the user.
|
||||
/// If location permission hasn't been granted, the position is not adjusted.
|
||||
/// </summary>
|
||||
private async Task MoveMapToCurrentPositionOfUser(Status status)
|
||||
private async Task<Model.Map.IMapSpan> GetFromLocationService(Status status)
|
||||
{
|
||||
if (status == Status.Granted)
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
if (TinkApp.CenterMapToCurrentLocation)
|
||||
{
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
if (currentLocation != null)
|
||||
{
|
||||
TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
|
||||
new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
TinkApp.ActiveMapSpan.Radius);
|
||||
TinkApp.Save();
|
||||
}
|
||||
}
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
if (currentLocation == null)
|
||||
return null;
|
||||
|
||||
return Model.Map.MapSpanFactory.Create(
|
||||
PositionFactory.Create(currentLocation.Latitude, currentLocation.Longitude),
|
||||
TinkApp.ActiveMapSpan.Radius.Kilometers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests the location permission from the user.
|
||||
/// If the user declines, a dialog prompot is shown, telling the user to toggle the permission in the device settings.
|
||||
/// </summary>
|
||||
/// <returns>The permission status.</returns>
|
||||
private async Task<Status> RequestLocationPermission()
|
||||
/// <summary>
|
||||
/// Requests the location permission from the user.
|
||||
/// If the user declines, a dialog prompot is shown, telling the user to toggle the permission in the device settings.
|
||||
/// </summary>
|
||||
/// <returns>The permission status.</returns>
|
||||
private async Task<Status> RequestLocationPermission()
|
||||
{
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue