public async void OnLocationChanged(Location location) { _currentLocation = location; if (_currentLocation == null) { state.Text = "Location is not available"; } else { Log.Debug (TAG, string.Format ("{0:f6},{1:f6}", _currentLocation.Latitude, _currentLocation.Longitude)); //Please use Emulator API23. Geocoder is not available on Emulator API19, got bug address = await ReverseGeocodeCurrentLocation (); if (address == null) { state.Text = "String: No Address"; } else { state.Text = address.GetAddressLine (address.MaxAddressLineIndex - 1); int complete = await ccm.HTMLDownload (address.GetAddressLine (address.MaxAddressLineIndex - 1)); if (complete == 1) { int locationIndex = GetNearestLocationIndex (); UpdateUI (locationIndex); } else { UpdateUI (999); } } } }
private static Address Convert(Android.Locations.Address address) { string addressLine = address.GetAddressLine(0); return(new Address { Latitude = address.Latitude, Longitude = address.Longitude, Name = address.FeatureName, Country = address.CountryName, PostalCode = address.PostalCode, Locality = address.Locality, SubLocality = address.SubLocality, Thoroughfare = address.Thoroughfare, SubThoroughfare = address.SubThoroughfare, AdministrativeArea = address.AdminArea, SubAdministrativeArea = address.SubAdminArea, AddressLine = addressLine, }); }
private void SaveAddress(Address address) { if (address != null) { string deviceAddress = ""; for (int i = 0; i < address.MaxAddressLineIndex; i++) { deviceAddress += address.GetAddressLine(i) + ", "; } deviceAddress = deviceAddress.Trim(); deviceAddress = deviceAddress.TrimEnd(','); _addressText = deviceAddress; var crashLocationResult = new CrashLocationResult { Address = new DTO.Location { HouseNameOrNumber = address.FeatureName, Country = address.CountryName, PostCode = address.PostalCode, Town = address.Locality, StreetName = address.Thoroughfare }, Lat = _currentLocation.Latitude, Lng = _currentLocation.Longitude, AddressAsString = _addressText }; MessagingCenter.Send<IGetLocation, CrashLocationResult>(this, "addressExists", crashLocationResult); } else { _addressText = ""; } //push the data to the message centre!!! }
void DisplayAddress (Address address) { if (address != null) { StringBuilder deviceAddress = new StringBuilder (); for (int i = 0; i < address.MaxAddressLineIndex; i++) { deviceAddress.AppendLine (address.GetAddressLine (i)); } // Remove the last comma from the end of the address. _addressText.Text = deviceAddress.ToString (); } else { Insights.Track ("UnableToDetermineAddress"); _addressText.Text = "Unable to determine the address. Try again in a few minutes."; } }
void DisplayAddress(Address address) { var label = ((WalkAround.MainContent)WalkAround.App.Current.MainPage).AddressLabel; if (address != null) { StringBuilder deviceAddress = new StringBuilder(); for (int i = 0; i < address.MaxAddressLineIndex; i++) { deviceAddress.AppendLine(address.GetAddressLine(i)); } // Remove the last comma from the end of the address. label.Text = deviceAddress.ToString(); } else { label.Text = "Unable to determine the address. Try again in a few minutes."; } }
public async void OnLocationChanged(Location location) { _currentLocation = location; sec++; if (_currentLocation != null) { Log.Debug (TAG, string.Format ("{0:f6},{1:f6}", _currentLocation.Latitude, _currentLocation.Longitude)); address = await ReverseGeocodeCurrentLocation(); int complete = 0; if (address != null) { string state = address.GetAddressLine (address.MaxAddressLineIndex - 1); while (complete != 1) { complete = await ccm.HTMLDownload (state); } if (complete == 1) { int locationIndex = GetNearestLocationIndex (); string currentRegion = regionEntry [locationIndex].ToString (); string APIString = latestAPI [locationIndex].ToString (); string currentAPI = APIString.Remove (APIString.Length - 1); string currentLegend = string.Empty; char legends = APIString [APIString.Length - 1]; if (legends == '*') { currentLegend = "PM10"; } else if (legends == 'a') { currentLegend = "SO2"; } else if (legends == 'b') { currentLegend = "NO2"; } else if (legends == 'c') { currentLegend = "Ozone"; } else if (legends == 'd') { currentLegend = "CO"; } else if (legends == '&') { currentLegend = "Multiple"; } else { currentLegend = "Unknown"; } notiTitle = "Malaysia API"; notiContent = String.Format ("API: {0}\nHighest Concentration: {1}", currentAPI, currentLegend); notiMinContent = String.Format ("API: {0}", APIString); } else { notiTitle = "Malaysia API"; notiContent = String.Format ("Can't get HTMLCompletion"); notiMinContent = String.Format ("Can't get HTMLCompletion"); } } else { notiTitle = "Malaysia API"; notiContent = String.Format ("Can't get address"); notiMinContent = String.Format ("Can't get address"); } } else { notiTitle = "Malaysia API"; notiContent = String.Format ("Can't get location"); notiMinContent = String.Format ("Can't get HTMLCompletion"); } SendNotification (notiTitle, notiContent, notiMinContent); }
private static string ConvertToString(Android.Locations.Address address) { return(address.GetAddressLine(0) + ", " + address.Locality); }
private void DisplayAddress(Address alamat) { if (alamat != null) { var deviceAddress = new StringBuilder(); for (var i = 0; i < alamat.MaxAddressLineIndex; i++) { deviceAddress.AppendLine(alamat.GetAddressLine(i)); } _alamatText.Text = deviceAddress.ToString(); } else { _alamatText.Text = "Selamat! Kamu nyasar."; } }
protected void UpdateAddressFields(Address addr) { if (String.IsNullOrEmpty(_nameEditText.Text)) _nameEditText.Text = addr.FeatureName; if (String.IsNullOrEmpty(_addrEditText.Text)) { for (int i = 0; i < addr.MaxAddressLineIndex; i++) { if (!String.IsNullOrEmpty(_addrEditText.Text)) _addrEditText.Text += System.Environment.NewLine; _addrEditText.Text += addr.GetAddressLine(i); } } }