void GetAddreObjGApi(List <string> addresses) { foreach (string address in addresses) { var splitAddress = address.Replace("\"", "").Replace("\\", "").Split(','); addressStore.Add(GeoCodingApi.GetGeoCod(splitAddress[0] + ", " + splitAddress[1])); } }
protected void btnSubmitAddress_Click(object sender, EventArgs e) { string inputAddress = txtAddress.Text; Address inputLatLong = GeoCodingApi.GetGeoCod(inputAddress); if (!string.IsNullOrEmpty(inputAddress)) { foreach (Address address in addressStore) { if (address != null) { address.Distance = DistanceCalculation.Distance(address.Latitude, address.Longitude, inputLatLong.Latitude, inputLatLong.Longitude, 'K'); //address.Distance = DistanceMatrixApi.GetDistance(address, inputLatLong); Get distance from Google Distance Matrix API } } var closestAddress = addressStore.OrderBy(x => x.Distance).Take(5); repAddress.DataSource = closestAddress; repAddress.DataBind(); } }