Beispiel #1
0
        private void submitBtn_Click(object sender, EventArgs e)
        {
            GoogleMaps client = new GoogleMaps("AIzaSyAScSP2zdmi7mzAqW9Ow3Fi434Y45YqriI");


            string targetName    = nameTxt.Text;
            string targetBranch  = branchTxt.Text;
            string targetRank    = rankTxt.Text;
            string targetCountry = countryTxt.Text;
            string targetCity    = cityLbl.Text;

            //here is the connection string for our DB
            //Database={your_database}; Data Source=socpacxasu.mysql.database.azure.com; User Id=capstoneAdmin@socpacxasu; Password={your_password}

            Address addr = client.QueryAddress($"{targetCity} {targetCountry}");



            //Geolocation.Coordinate coordinate = new Geolocation.Coordinate();
            //string targetLat = coordinate.Latitude.ToString();
            //string targetLong = coordinate.Longitude.ToString();

            latLbl.Text  = addr.State.ToString();
            longLbl.Text = addr.Longitude.ToString();

            //need to find an API that returns coordinates to search with in DB
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            while (String.IsNullOrEmpty(_ApiKey))
            {
                Console.Write("API key: ");
                _ApiKey = Console.ReadLine();
            }

            _GoogleMaps        = new GoogleMaps(_ApiKey);
            _GoogleMaps.Logger = Console.WriteLine;

            while (_RunForever)
            {
                Console.Write("Command [? for help]: ");
                string userInput = Console.ReadLine();
                if (String.IsNullOrEmpty(userInput))
                {
                    continue;
                }

                if (userInput.Equals("q"))
                {
                    _RunForever = false;
                }
                else if (userInput.Equals("cls") || userInput.Equals("c"))
                {
                    Console.Clear();
                }
                else if (userInput.Equals("?"))
                {
                    Menu();
                }
                else if (userInput.StartsWith("ts "))
                {
                    string   timestampStr = userInput.Substring(2);
                    DateTime ts           = DateTime.Now;
                    string   tz           = null;

                    if (timestampStr.Contains(","))
                    {
                        string[] parts     = timestampStr.Split(new char[] { ',' }, 2);
                        double   latitude  = Convert.ToDouble(parts[0]);
                        double   longitude = Convert.ToDouble(parts[1]);
                        ts = _GoogleMaps.LocalTimestamp(latitude, longitude, DateTime.Now, out tz);
                    }
                    else
                    {
                        ts = _GoogleMaps.LocalTimestamp(timestampStr, DateTime.Now, out tz);
                    }

                    Console.WriteLine(tz + ": " + ts.ToString("s"));
                }
                else
                {
                    Address addr = null;

                    if (userInput.Contains(","))
                    {
                        string[] parts     = userInput.Split(new char[] { ',' }, 2);
                        double   latitude  = Convert.ToDouble(parts[0]);
                        double   longitude = Convert.ToDouble(parts[1]);
                        addr = _GoogleMaps.QueryCoordinates(latitude, longitude);
                    }
                    else
                    {
                        addr = _GoogleMaps.QueryAddress(userInput);
                    }

                    Console.WriteLine(SerializeJson(addr));
                }
            }
        }