//Input Address (ex: 18 Pham Hung) //Output a json incluted detail of address 18 Pham Hung public static async Task<GoogleAPIQueryAutoCompleteObj> ConvertAutoCompleteToLLS(string address) { string URL = ConstantVariable.googleAPIQueryAutoCompleteRequestsBaseURI + ConstantVariable.googleGeolocationAPIkey + "&input=" + address; //Get Json string string addressObjString; addressObjString = await ReqAndRes.GetJsonString(URL); GoogleAPIQueryAutoCompleteObj addressObj = new GoogleAPIQueryAutoCompleteObj(); addressObj = JsonConvert.DeserializeObject<GoogleAPIQueryAutoCompleteObj>(addressObjString); return addressObj; }
private async void HomeAddressAutoComplete(string inputAddress) { GoogleAPIQueryAutoCompleteObj placesObj = new GoogleAPIQueryAutoCompleteObj(); try { placesObj = await GoogleAPIFunctions.ConvertAutoCompleteToLLS(inputAddress); //2. Create Place list ObservableCollection<AutoCompletePlaceLLSObj> autoCompleteDataSource = new ObservableCollection<AutoCompletePlaceLLSObj>(); lls_HomeAddress.ItemsSource = autoCompleteDataSource; //3. Loop to list all item in object if (placesObj.status != "ZERO_RESULTS") { ShowLLSHomeAddress(); foreach (var obj in placesObj.predictions) { autoCompleteDataSource.Add(new AutoCompletePlaceLLSObj(obj.description.ToString())); } } else { HideLLSHomeAddress(); } } catch (Exception) { txt_HomeAddress.Focus(); } }