private async void FeatureLocationList_SelectionChanged(object sender, SelectionChangedEventArgs e) { GooglePlaceIdModel model = (GooglePlaceIdModel)e.AddedItems[0]; if (model != null) { GoogleMapPlaceModel returnModel = await ConvertPlaceIdToAddress(model); //Debug.WriteLine(model.result.geometry.location.lat); OutdoorModel m = new OutdoorModel() { longitude = returnModel.result.geometry.location.lng.ToString(), latitude = returnModel.result.geometry.location.lat.ToString() }; Debug.WriteLine(m.longitude); Debug.WriteLine(m.latitude); this.Frame.Navigate(typeof(ElderlyOutdoorLocationMap), m); } }
private async Task <GoogleMapPlaceModel> ConvertPlaceIdToAddress(GooglePlaceIdModel m) { progressbar.Visibility = Visibility.Visible; try { HttpClient httpClient = new HttpClient(); var response = await httpClient.GetAsync(_GOOGLE_AUTOCOMPLETE_URL + "placeid=" + m.placeid + "&key=" + GoogleMapKey); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); GoogleMapPlaceModel model = JsonConvert.DeserializeObject <GoogleMapPlaceModel>(content); //model.count = m.count; return(model); //SearchResultPlaceList.ItemsSource = foundPlaceModel.predictions; } else { progressbar.Visibility = Visibility.Collapsed; MessageDialog md = new MessageDialog("Error occur search place...try again later..."); await md.ShowAsync(); return(null); } } catch { progressbar.Visibility = Visibility.Collapsed; MessageDialog md = new MessageDialog("Error occur search place...try again later..."); await md.ShowAsync(); return(null); } }