Ejemplo n.º 1
0
        /// <summary>
        /// Updates position on map
        /// </summary>
        private void txtLat_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((Keys)e.KeyChar == Keys.Enter)
            {
                this.txtFind.Text        = "";
                this.listBox1.DataSource = null;
                double lat, lng;
                try
                {
                    double.TryParse(txtLat.Text, out lat);
                    double.TryParse(txtLong.Text, out lng);

                    List <Placemark>   list   = new List <Placemark>();
                    GeoCoderStatusCode status = GeoCoder.GetPlacemarks(new Point2D(lat, lng), out list);

                    if (status == GeoCoderStatusCode.G_GEO_SUCCESS)
                    {
                        this.listBox1.DataSource = list;
                    }

                    this.UpdateMapPosition(lat, lng);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid format");
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs geocoding task based upon user input
        /// </summary>
        private void txtFind_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((Keys)e.KeyChar == Keys.Enter)
            {
                this.listBox1.DataSource = null;
                List <Point2D>     points = new List <Point2D>();
                GeoCoderStatusCode status = GeoCoder.GetPoints(txtFind.Text, out points);
                if (status == GeoCoderStatusCode.G_GEO_SUCCESS && points.Count > 0)
                {
                    this.txtLat.Text  = points[0].Lat.ToString();
                    this.txtLong.Text = points[0].Lng.ToString();
                    this.UpdateMapPosition(points[0].Lat, points[0].Lng);

                    if (this.chkShowAll.Checked)
                    {
                        ParameterizedThreadStart start = ShowAll;
                        Thread thread = new Thread(start);
                        thread.Priority     = ThreadPriority.BelowNormal;
                        thread.IsBackground = true;
                        thread.Start(points);
                    }
                    else
                    {
                        this.listBox1.DataSource = points;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void ShowAll(object obj)
        {
            List <Point2D> points = obj as List <Point2D>;

            if (points == null)
            {
                return;
            }

            GeoCoderStatusCode status = GeoCoderStatusCode.Unknow;
            List <Placemark>   list   = new List <Placemark>();

            foreach (Point2D pnt in points)
            {
                Placemark place = GeoCoder.GetPlacemark(pnt, out status);
                place.Location = pnt;
                list.Add(place);
            }
            this.listBox1.DataSource = list;
        }