async Task GetActualUserLocation() { try { await Task.Yield(); var request = new GeolocationRequest(GeolocationAccuracy.High, TimeSpan.FromSeconds(5000)); var location = await Geolocation.GetLocationAsync(request); if (location != null) { OriginCoordinates = location; CenterMapCommand.Execute(location); GetLocationNameCommand.Execute(new Position(location.Latitude, location.Longitude)); } } catch (Exception ex) { await UserDialogs.Instance.AlertAsync("Error", "Unable to get actual location", "Ok"); } }
async Task GetActualUserLocation() { try { // await Task.Yield(); var request = new GeolocationRequest(GeolocationAccuracy.High, TimeSpan.FromSeconds(5000)); Location location = await Geolocation.GetLocationAsync(request); //TODO //This needs to be checked as here, a race condition seems to be happening as a result of which sometimes //the location isn't centered while (location == null) { } if (location != null) { _originLatitude = location.Latitude + ""; _originLongitude = location.Longitude + ""; CenterMapCommand.Execute(location); GetLocationNameCommand.Execute(location); } } catch (FeatureNotSupportedException fnsEx) { // Handle not supported on device exception } catch (FeatureNotEnabledException fneEx) { // Handle not enabled on device exception } catch (PermissionException pEx) { // Handle permission exception } catch (Exception ex) { //await UserDialogs.Instance.AlertAsync("Error", "Unable to get actual location", "Ok"); } }