//---------------------------------------------------------------------- // public async Task <Result <WCoord> > geCurrenteLocation() { var p = new WCoord { lat = "38.920853", lon = "-77.032756" }; try { var request = new GeolocationRequest(GeolocationAccuracy.Medium); var location = await Geolocation.GetLocationAsync(request); if (location != null) { p = new WCoord { lat = location.Latitude.ToString(), lon = location.Longitude.ToString() }; return(new Result <WCoord>(p)); } else { return(new Result <WCoord>(p)); } } catch (FeatureNotSupportedException fnsEx) { // Handle not supported on device exception Console.WriteLine("Error location 1"); //return new Result<Point>(Error.Generic); return(new Result <WCoord>(p)); } catch (FeatureNotEnabledException fneEx) { // Handle not enabled on device exception Console.WriteLine("Error location 2"); return(new Result <WCoord>(p)); } catch (PermissionException pEx) { // Handle permission exception Console.WriteLine("Error location 3"); return(new Result <WCoord>(p)); } catch (Exception ex) { // Unable to get location Console.WriteLine("Error location 4"); return(new Result <WCoord>(p)); } }
//---------------------------------------------------------------------- // public async Task searchByCoordenates(WCoord point) { View?.OnWaiting(); Console.WriteLine(point.lat + "lon: " + point.lon); Result <ForecastData> result = await _interactor.GetWeatherData(APIServer.RequestUriByLocation(point.lat, point.lon)); View?.OnStopWaiting(); if (result.Error == Error.None) { View?.setData(result.Data); } else if (result.Error == Error.Generic) { // View?.OnInvalidInput(Strings.Nofound); } }