示例#1
0
        protected void Save_Click(object sender, EventArgs e)
        {
            MapLocation location = geocodeClient.GetMapLocation(new Address {
                Street     = txt_AddressLine1.Text,
                Apt        = txt_AddressLine2.Text,
                City       = txt_City.Text,
                Region     = txt_State.Text,
                PostalCode = txt_Zip.Text
            });

            Response.Write($"<script>alert('Lat: {location.longitude} Lon: {location.longitude}');</script>");

            Clear_Fields();
        }
示例#2
0
        //Reads location data from an input CSV file
        //This method will be used to map pins
        public void readCSVMarker()   //for marker map only
        {
            inputPath = fileNameTextBox.Text;

            //Loops through lines in csv file, skip the header row
            foreach (var line in File.ReadAllLines(inputPath, Encoding.GetEncoding(1250)).Skip(1))
            {
                //Each rows address data gets split into the array seperated by a comma
                string[] addressInfo = line.Split(',');

                //MapLocation object is intialized with values from array
                MapLocation location = geocodeClient.GetMapLocation(new Address
                {
                    Street     = addressInfo[1],
                    Apt        = null, //null
                    City       = addressInfo[3],
                    Region     = addressInfo[4],
                    PostalCode = addressInfo[5]
                });

                //Adds the company name and the maplocation tied to it into the list
                locationData.Add(new Tuple <string, MapLocation>(addressInfo[0], location));
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            //The GeocodeClient can convert from an address to GeoCoordinates
            GeocodeClient client = new GeocodeClient(apikey);

            Console.WriteLine("Enter an Address");
            string address = Console.ReadLine();

            //Object that holds our Coordinates
            MapLocation location = client.GetMapLocation(address);

            Console.WriteLine("Latitude: " + location.latitude);
            Console.WriteLine("Longitude: " + location.longitude);
            Console.ReadKey();
        }
示例#4
0
        protected void Save_Click(object sender, EventArgs e)
        {
            //Gets the comp name from the textbox and adds it to the listbox
            CompanyListBox.Items.Add((addresses.Count + 1) + ": " + CompanyName.Text);

            //Stores MapLocation
            MapLocation location = geocodeClient.GetMapLocation(new Address {
                Street     = txt_AddressLine1.Text,
                Apt        = txt_AddressLine2.Text,
                City       = txt_City.Text,
                Region     = txt_State.Text,
                PostalCode = txt_Zip.Text
            });

            addresses.Add(location);

            Response.Write(@"
        <script>
            var map;
            function initMap()
            {
                map = new google.maps.Map(document.getElementById('map'), {
                zoom: 7.5,
                center: { lat: 44.942, lng: -122.933 }, //Oregon's coordinates (Willamette Valley)
                mapTypeId: 'roadmap' //map view vs. satellite view
            });

            " + placeMarkers() + @"
            }

            function placeMarker(coordlat, coordlong)
            {
                var marker = new google.maps.Marker({
                position: { lat: coordlat, lng: coordlong },
                map: map
            });
        }

        </script>");

            Clear_Fields();
        }
示例#5
0
        //Read a csv file and gather data from each line to make a web-request to GoogleAPI
        private void ReadCSV()
        {
            //Loops through each line in the csv -  .Skip(1) ignores the first line(Headers)
            foreach (var line in File.ReadAllLines(CSVTextBox.Text, Encoding.GetEncoding(1250)).Skip(1))
            {
                //Each string in a row gets placed into this array
                string[] addressInfo = line.Split(',');

                //Assigns values to the MapLocation object from each string in the array
                MapLocation location = geocodeClient.GetMapLocation(new Address
                {
                    Street     = addressInfo[1],
                    Apt        = addressInfo[2],
                    City       = addressInfo[3],
                    Region     = addressInfo[4],
                    PostalCode = addressInfo[5]
                });

                //Adds the company name and MapLocation tied to it into the list
                locationData.Add(new Tuple <string, MapLocation>(addressInfo[0], location));
            }
        }
示例#6
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            //Stores MapLocation
            MapLocation location = geocodeClient.GetMapLocation(new Address
            {
                Street     = AddressLine1TextBox.Text,
                Apt        = AddressLine2TextBox.Text,
                City       = CityTextBox.Text,
                Region     = StateTextBox.Text,
                PostalCode = ZipTextBox.Text
            });

            addresses.Add(location);

            //Gets the comp name from the textbox and adds it to the listbox
            LocationListBox.Items.Add((addresses.Count) + ": " + CompanyTextBox.Text);

            /* ONLY FOR TESTING*/
            /* Remove for 'final' product */
            //Prints the latitude and longitude from the location
            MessageBox.Show($"Lat: {location.latitude} Long: {location.longitude} ");
        }