Beispiel #1
0
        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();
            }
        }