static void findOnMap() { Console.WriteLine("Please Input the Address to find Coordinates (City, Country): "); var address = Console.ReadLine(); var locationservice = new GoogleMaps.LocationServices.GoogleLocationService(); var point = locationservice.GetLatLongFromAddress(address); var longitude = point.Longitude; var latitude = point.Latitude; Console.WriteLine("The latitude, Longitude of the given address is : " + latitude + "," + longitude); Console.ReadLine(); }
public async Task <ICollection <MapDataDto> > GetAtmLocations(ICollection <ATM> atms) { var t = new GoogleMaps.LocationServices.GoogleLocationService(); var ans = atms.Select(x => { var location = t.GetLatLongFromAddress(x.Address); return(new MapDataDto() { Atm = x, Location = new MapLocation() { Latitude = location.Latitude, Longitude = location.Longitude } }); }).ToList(); return(ans); }
public bool TrackUsers() { bool result = false; var locationService = new GoogleMaps.LocationServices.GoogleLocationService(); var ip = Request.ServerVariables["REMOTE_ADDR"];; IpInfo ipinfo = GetUserCountryByIp(ip); if (ipinfo.Loc != null) { string[] latlong = ipinfo.Loc.Split(','); ipinfo.Loc = GetAddressFromLatLong(Convert.ToDouble(latlong[0]), Convert.ToDouble(latlong[1])); } var Visitors = GetdataTable("select * from [dbo].[TrackRecord]"); var IsFound = Visitors.AsEnumerable().Where(a => a["Ip"].ToString() == ipinfo.Ip); if (IsFound.Count() == 0) { result = true; SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_InsertTrackRecord"; cmd.Connection = con; cmd.Parameters.AddWithValue("@Ip", ipinfo.Ip == null ? "" : ipinfo.Ip); cmd.Parameters.AddWithValue("@Hostname", ipinfo.Hostname == null ? "" : ipinfo.Hostname); cmd.Parameters.AddWithValue("@City", ipinfo.City == null ? "" : ipinfo.City); cmd.Parameters.AddWithValue("@Region", ipinfo.Region == null ? "" : ipinfo.Region); cmd.Parameters.AddWithValue("@Country", ipinfo.Country == null ? "" : ipinfo.Country); cmd.Parameters.AddWithValue("@Loc", ipinfo.Loc == null ? "" : ipinfo.Loc); cmd.Parameters.AddWithValue("@Org", ipinfo.Org == null ? "" : ipinfo.Org); cmd.Parameters.AddWithValue("@Postal", ipinfo.Postal == null ? "" : ipinfo.Postal); if (con.State == ConnectionState.Closed) { con.Open(); } cmd.ExecuteNonQuery(); } return(result); }
static void FindDist() { Console.WriteLine("Please Enter the 2 Cities you want to calculate the distance between [ City 1, Country; city 2, Country] ?"); string addresses = Console.ReadLine(); while (!addresses.Contains(";") && addresses.Count(c => c == ',') < 2 && addresses.Length < 10) { Console.WriteLine("Incorrect address inputted, Please Try again"); addresses = Console.ReadLine(); } string[] address1 = addresses.Split(';'); Console.WriteLine("The Address are: " + address1[0] + "; " + address1[1]); Console.ReadLine(); var locationservice = new GoogleMaps.LocationServices.GoogleLocationService(); var point1 = locationservice.GetLatLongFromAddress(address1[0]); var point2 = locationservice.GetLatLongFromAddress(address1[1]); double dist = CalculateDistance(point1.Latitude, point1.Longitude, point2.Latitude, point2.Longitude); Console.Write("The Distance between the 2 cities is: " + Math.Round(dist, 2) + "km"); Console.ReadLine(); }