void UpdateAddress (LocationData location) { if(location != null) { Address = string.Format("{0}, {1}", location.UserCountry, location.UserCity); } }
async void GetLastKnownUpdate () { var location = _locationManager.GetLastKnownLocation (LocationManager.NetworkProvider); _lastKnownLocation = await ReverseGeocodeCurrentLocation(location); OnUserLocationChangedEvent(new UserLocationChangedEventArgs(()=>_lastKnownLocation)); }
async Task<LocationData> ReverseGeocodeCurrentLocation(Location location) { return await Task.Run<LocationData>(async()=>{ var geocoder = new Geocoder(EmpleadoApp.AppContext); var addressList = await geocoder.GetFromLocationAsync(location.Latitude, location.Longitude, 10); var address = addressList.FirstOrDefault(); var locationData = new LocationData { UserCity = address.Locality, UserCountry = address.AdminArea, UserStreet = address.Thoroughfare, PostalCode = address.PostalCode }; return locationData; }); }
public async void OnLocationChanged (Location location) { _lastKnownLocation = await ReverseGeocodeCurrentLocation(location); OnUserLocationChangedEvent(new UserLocationChangedEventArgs(()=>_lastKnownLocation)); }
public UserLocationChangedEventArgs (Func<LocationData> action) { GetLastKnownUserLocation = action.Invoke(); }
public UserLocationChangedEventArgs(Func <LocationData> action) { GetLastKnownUserLocation = action.Invoke(); }
public async void OnLocationChanged(Location location) { _lastKnownLocation = await ReverseGeocodeCurrentLocation(location); OnUserLocationChangedEvent(new UserLocationChangedEventArgs(() => _lastKnownLocation)); }