public async void LocationAutoSuggest_QuerySubmitted(AutoSuggestBoxQuerySubmittedEventArgs arg) { if (arg.ChosenSuggestion != null && arg.ChosenSuggestion.ToString() != "No suggestions...") { LocationSuggestBox.Value = arg.ChosenSuggestion.ToString(); LocObj location = locs.Find(l => l.LocationNameLong == arg.ChosenSuggestion.ToString()); var chosenLocImage = await HttpServiceSingleton.GetInstance.GetImageAsync($"https://api.unsplash.com/search/photos?query={location.LocationNameShort}&client_id=TiZc8-TmzwTTAO3vLdLw4PNX6nzwtFnF7UKotCLsumU&per_page=1"); Image.Value = new BitmapImage(new Uri(chosenLocImage)); } else { //LocationSuggestBox.Value = sender.Text; } }
public async Task <List <LocObj> > GetLocationAsync(string uri) { var json = await baselessClient.GetStringAsync(uri); dynamic model = await Task.Run(() => JsonConvert.DeserializeObject(json)); List <LocObj> locations = new List <LocObj>(); foreach (dynamic location in model["features"]) { string x = location["place_name"]; string y = location["text"]; float lon = location["center"][0]; float lat = location["center"][1]; LocObj ob = new LocObj(x, y, lon, lat); locations.Add(ob); } return(locations); }