예제 #1
0
 private void MainMap_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         mouseCounter += 1;
         Double lat       = MainMap.FromLocalToLatLng(e.X, e.Y).Lat;
         Double lng       = MainMap.FromLocalToLatLng(e.X, e.Y).Lng;
         var    newMarker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
             new PointLatLng(lat, lng),
             GMarkerGoogleType.yellow_dot);
         MainMap.Overlays.Add(newMarkerOverlay);
         newMarkerOverlay.Markers.Add(newMarker);
         if (mouseCounter == 4)
         {
             try
             {
                 drawPolygon();
                 ss.SpeakAsync("objective changed");
                 updateMap(pointTarget);
                 ss.SpeakAsync("navigating to new area");
                 sp.lockTarget();
                 sp2.lockTarget();
             }
             catch (Exception)
             {
             }
         }
     }
     // mapclick
 }
        // This will work to get directions from one point to another routeDirection will contain the steps which we can use to display position. Also will include the time for the trip. Can use this to compare and find the optimal prospect.
        private void example2()
        {
            GMapProviders.GoogleMap.ApiKey = "AIzaSyBsS4_zQy-svXOtLrS32XPphEsSX-EMY8M";
                PointLatLng start = new PointLatLng(46.289106, -119.292999);
                PointLatLng end = new PointLatLng(46.276860, -119.291511);

                var temp = GMapProviders.GoogleMap.GetDirections(out routeDirection, start, end, false, false, false, false, false);
                GMapRoute mapRoute2 = new GMapRoute(routeDirection.Route, "This Trip");
            GMapOverlay overlayTest = new GMapOverlay("Test Route");
            overlayTest.Routes.Add(mapRoute2);
            gMapControl1.Overlays.Add(overlayTest);
            GMap.NET.WindowsForms.Markers.GMarkerGoogle startP = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(start, GMarkerGoogleType.red_pushpin);// Adds the markers to start and end points.
            GMap.NET.WindowsForms.Markers.GMarkerGoogle endP = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(end, GMarkerGoogleType.red_pushpin);
            var carMark = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(mapRoute2.Points[10], new Bitmap("C:\\Users\\Jason\\Desktop\\323\\Milestone2\\CptS-323-main (1)\\CptS-323-main\\Home_Visits_Vaccination\\Home_Visits_Vaccination\\Car_Icon.png"));
            objects.Markers.Add(startP); // Adds to markers list
            objects.Markers.Add(endP);  // adds to markers list
            objects.Markers.Add(carMark); // Add the car marker to overlay.

            gMapControl1.Overlays.Add(objects); // Adds the markers to actual overlay.
            gMapControl1.ZoomAndCenterRoute(mapRoute2); // zooms to the route.

            Console.WriteLine(routeDirection);
            for (int i = 0; i < mapRoute2.Points.Count; i++)
            {
                carMark.Position = mapRoute2.Points[i];
                gMapControl1.Refresh();
                Thread.Sleep(1000);
                Console.WriteLine("Point {0} coords are: {1}", i, mapRoute2.Points[i]);
            }
        }
예제 #3
0
            void display_current_position(double lat, double lon, GMap.NET.WindowsForms.GMapControl karte, GMapOverlay own_positions)
            {
                karte.Invoke(new Action(() => own_positions.Markers.Clear()));
                GMapMarker marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
                    new PointLatLng(lat, lon),
                    GMarkerGoogleType.red_small);

                karte.Invoke(new Action(() => karte.Overlays.Add(own_positions)));
                own_positions.Markers.Add(marker);
            }
예제 #4
0
        private void gMapServicio_Click_1(object sender, EventArgs e)
        {
            markersOverlay.Clear();
            GMapControl    gm = (GMapControl)sender;
            MouseEventArgs hj = (MouseEventArgs)e;

            lat = gm.FromLocalToLatLng(hj.X, hj.Y).Lat;
            lon = gm.FromLocalToLatLng(hj.X, hj.Y).Lng;
            GMapMarker marker =
                new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
                    new GMap.NET.PointLatLng(lat, lon),
                    GMap.NET.WindowsForms.Markers.GMarkerGoogleType.blue_pushpin);

            markersOverlay.Markers.Add(marker);
            gMapServicio.Overlays.Add(markersOverlay);
            btConfirmar.Enabled = true;
        }
예제 #5
0
        public void  animate(int index, GMapMarkerVan vanMark)

        {
            GMapProviders.GoogleMap.ApiKey = "AIzaSyBsS4_zQy-svXOtLrS32XPphEsSX-EMY8M";
            PointLatLng start, end;

            start = new PointLatLng(46.280452, -119.279381);
            end   = new PointLatLng(myappointments[index].destination.lat, myappointments[index].destination.lng);
            var         temp        = GMapProviders.GoogleMap.GetDirections(out routeDirection, start, end, false, false, false, false, false); // API call to get the directions
            GMapRoute   mapRoute2   = new GMapRoute(routeDirection.Route, "This Trip");                                                         // Creates the route
            GMapOverlay overlayTest = new GMapOverlay("Test Route");

            overlayTest.Routes.Add(mapRoute2);
            gMapControl1.Overlays.Add(overlayTest);
            GMap.NET.WindowsForms.Markers.GMarkerGoogle startP = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(start, GMarkerGoogleType.green_dot);                            // Adds the markers to start and end points.
            GMap.NET.WindowsForms.Markers.GMarkerGoogle endP   = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(end, GMarkerGoogleType.red_dot);
            Bitmap icon = new Bitmap("C:\\Users\\Jason\\Desktop\\323\\Milestone2\\CptS-323-main (1)\\CptS-323-main\\Home_Visits_Vaccination\\Home_Visits_Vaccination\\Car_Icon4.png");

            //var carMark = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(mapRoute2.Points[11], new Bitmap("C:\\Users\\Jason\\Desktop\\323\\Milestone2\\CptS-323-main (1)\\CptS-323-main\\Home_Visits_Vaccination\\Home_Visits_Vaccination\\Car_Icon2.png")); // Sets the car marker variable and assigns it the bitmap (Icon)
            //var carMark = new GMapMarkerVan(mapRoute2.Points[mapRoute2.Points.Count - 1], icon);
            //vanMarkers.Add(carMark);
            vanMarkers.Add(vanMark);
            //vanMarkers[j].Position = startP.Position;
            vanMark.Position = start;
            objects.Markers.Add(startP);                            // Adds to markers list
            objects.Markers.Add(endP);                              // adds to markers list
            //objects.Markers.Add(vanMarkers[j]); // Add the car marker to overlay.
            objects.Markers.Add(vanMark);
            gMapControl1.Overlays.Add(objects);                             // Adds the markers to actual overlay.
            gMapControl1.ZoomAndCenterRoute(mapRoute2);                     // zooms to the route.
            Thread t = new Thread(() =>

            {
                var timedelay  = 0.016;
                var acumsecond = 0.0;
                for (int i = 1; i < mapRoute2.Points.Count; i++)
                {
                    var degree = Bearing(mapRoute2.Points[i - 1], mapRoute2.Points[i]);
                    var deltaX = Distance(mapRoute2.Points[i - 1], mapRoute2.Points[i]);
                    degree     = (degree * 180 / Math.PI + 360) % 360;
                    vanMark.Rotate((float)degree);
                    var distance     = 0.00972222222;                                 //35mph to miles per second
                    var deltaSeconds = deltaX / distance;
                    deltaSeconds     = deltaSeconds / 16;
                    status0(myappointments[index]);
                    for (double s = 0; s < deltaSeconds; s = s + timedelay)
                    {
                        var r       = s / deltaSeconds;
                        var dlat    = r * (mapRoute2.Points[i].Lat) + (1 - r) * (mapRoute2.Points[i - 1].Lat);
                        var dlng    = r * (mapRoute2.Points[i].Lng) + (1 - r) * (mapRoute2.Points[i - 1].Lng);
                        var M_point = new PointLatLng(dlat, dlng);
                        Thread.Sleep((int)(deltaSeconds * timedelay * 1000));
                        vanMark.Position = M_point;
                        if (acumsecond > 2)
                        {
                            updatePosition(myappointments[index], vanMark);
                            acumsecond = 0;
                        }
                        acumsecond = acumsecond + timedelay;
                    }
                }
                status1(myappointments[index]);
                Thread.Sleep((int)(56 * 1000));                                 // change to 1000
                status2(myappointments[index]);
                finish(myappointments[index], vanMark);
                vanMark.inUse = false;
                //firebase to upfate the status 1 (key),


                //firebase to upfate the status 2 ,

                //call firebase finishAppointment

                //}
                //=>
            }
                                  );

            t.Start();
        }
예제 #6
0
파일: Form1.cs 프로젝트: antmurph/ICMP_PING
        private void MapTraceroute(string domain)
        {
            ThreadHelper.SetGmapZoom(this, gmapcontrol, 2);
            GMap.NET.WindowsForms.GMapOverlay markers = new GMap.NET.WindowsForms.GMapOverlay("markers");
            GMapOverlay        routes = new GMapOverlay("routes");
            List <PointLatLng> points = new List <PointLatLng>();

            ThreadHelper.SetText(this, trace_status_label, "tracing");


            trace_status_label.BackColor = Color.Yellow;
            var trace = tracert.GetTraceRoute(tracert_Textbox.Text);

            ThreadHelper.SetText(this, trace_status_label, "done...mapping points");
            foreach (var element in trace)
            {
                double lattitude;
                double longitude;

                var ipdetails = tracert.IPGEOINFO(element);
                if (ipdetails[0] == null)
                {
                    continue;
                }
                else
                {
                    lattitude = Convert.ToDouble(ipdetails[0].ToString());
                    longitude = Convert.ToDouble(ipdetails[1].ToString());

                    string coordinates = (ipdetails[0].ToString()) + (",") + (ipdetails[1].ToString());


                    GMap.NET.WindowsForms.GMapMarker marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(new GMap.NET.PointLatLng(lattitude, longitude), GMap.NET.WindowsForms.Markers.GMarkerGoogleType.blue_pushpin);
                    marker.Dispose();
                    marker.ToolTipText         = ("Loc: " + coordinates + "\n" + ipdetails[2] + "\n" + ipdetails[3] + "\n" + ipdetails[4]);
                    marker.ToolTip.Fill        = Brushes.Black;
                    marker.ToolTip.Foreground  = Brushes.White;
                    marker.ToolTip.Stroke      = Pens.Black;
                    marker.ToolTip.TextPadding = new Size(20, 20);

                    points.Add(new PointLatLng(lattitude, longitude));

                    markers.Markers.Add(marker);
                    gmapcontrol.Overlays.Clear();
                    gmapcontrol.Overlays.Add(markers);
                }
            }
            try
            {
                GMapRoute route = new GMapRoute(points, "test");
                routes.Routes.Add(route);
                ThreadHelper.SetText(this, trace_status_label, "adding routes...");
                gmapcontrol.Overlays.Add(routes);
            }
            catch
            {
            }
            ThreadHelper.SetGmapZoom(this, gmapcontrol, 3);
            ThreadHelper.SetText(this, trace_status_label, "idle");
            trace_status_label.BackColor = Color.Silver;
        }
예제 #7
0
        private async void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            switch (e.Result.Text.ToString())
            {
            case "update satellites":
                // making the query to count the number of satellites above me
                String         satResult;
                SatelliteModel sm = new SatelliteModel
                {
                    latitude  = pointTarget.Lat,
                    longitude = pointTarget.Lng,
                    elevation = 70.0     // by default
                };
                var satPayload = await Task.Run(() => JsonConvert.SerializeObject(sm));

                HttpContent content = new StringContent(satPayload, Encoding.UTF8, "application/json");
                var         url     = " YOUR RESTFUL API";


                using (HttpClient weatherClient = new HttpClient())
                {
                    using (HttpResponseMessage weatherResponse = await weatherClient.PostAsync(url, content))
                    {
                        using (HttpContent returnedRes = weatherResponse.Content)
                        {
                            satResult = await returnedRes.ReadAsStringAsync();
                        }
                    }
                }
                numSatellites = int.Parse(satResult);
                ss.SpeakAsync($"There are {satResult} operational GPS satellites above you");
                break;

            case "launch rocket":
                if (num_missiles > 0)
                {
                    soundPlayer.Play();
                    num_missiles -= 2;
                    ss.SpeakAsync("missle launched");
                    var tempOverlay = new GMapOverlay("temporary");
                    MainMap.Overlays.Add(tempOverlay);

                    sp.launch();
                    sp2.launch();
                    var missileMarker  = sp.getMissileMarker();
                    var missileMarker2 = sp2.getMissileMarker();

                    // missile launch coordinates
                    Double missile_lat = sp.missileLat;
                    Double missile_lng = sp.missileLon;

                    Double missile_lat2 = sp2.missileLat;
                    Double missile_lng2 = sp2.missileLon;

                    for (Double k = 0; k < 1; k += 0.05)
                    {
                        if (k > 0.95)
                        {
                            Bitmap label     = Blimp_GCS.Properties.Resources.explosion;
                            Bitmap resized   = new Bitmap(label, new Size(50, 50));
                            var    newMarker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
                                new PointLatLng(pointTarget.Lat, pointTarget.Lng),
                                resized
                                );

                            tempOverlay.Markers.Add(newMarker);

                            // display image for a duration of one second
                            await Task.Delay(1000);

                            soundPlayer.Stop();
                            tempOverlay.Markers.Remove(newMarker);
                        }
                        else
                        {
                            Double missileActualLat = missile_lat + k * (pointTarget.Lat - missile_lat);
                            Double missileActualLon = missile_lng + k * (pointTarget.Lng - missile_lng);

                            Double missileActualLat2 = missile_lat2 + k * (pointTarget.Lat - missile_lat2);
                            Double missileActualLon2 = missile_lng2 + k * (pointTarget.Lng - missile_lng2);

                            missileMarker  = sp.updateMissileMarker(missileActualLat, missileActualLon);
                            missileMarker2 = sp2.updateMissileMarker(missileActualLat2, missileActualLon2);

                            try
                            {
                                tempOverlay.Markers.Add(missileMarker);
                                tempOverlay.Markers.Add(missileMarker2);
                                await Task.Delay(250);

                                tempOverlay.Markers.Remove(missileMarker);
                                tempOverlay.Markers.Remove(missileMarker2);
                            } catch (Exception)
                            {
                            }
                        }
                    }

                    sp.unlockTarget();
                    sp2.unlockTarget();
                    polygons.Polygons.Remove(polygon);
                    newMarkerOverlay.Markers.Clear();
                    markers.Markers.Remove(gm_fire);
                    isOnFire = false;
                }
                else
                {
                    ss.SpeakAsync("no medicine left");
                }
                break;
            }
        }
예제 #8
0
        private void map_Load(object sender, EventArgs e)
        {
            SqlDataAdapter da;

            da = new SqlDataAdapter("select lat,lng,city FROM [test].[dbo].[wordcites] where city in ('Tirana','Andorra la Vella','Yerevan','Vienna','Baku','Minsk','Brussels','Sarajevo','Sofia','Zagreb','Nicosia','Prague','Copenhagen','Tallinn','Helsinki','Paris','Tbilisi','Berlin','Athens','Budapest','Reykjavik','Dublin','Rome','Pristina','Riga','Vaduz','Vilnius','Luxembourg','Valletta','Chisinau','Monaco','Podgorica','Amsterdam','Macedonia','Skopje','Oslo','Warsaw','Lisbon','Bucharest','Moscow','San Marino','Belgrade','Bratislava','Ljubljana','Madrid','Stockholm','Bern','Ankara','Kyiv','London','Vatican')", con);

            var dt = new DataTable();

            da.Fill(dt);
            dataGridView1.DataSource = dt;

            //    MySqlDataAdapter da = new MySqlDataAdapter("select * from sinkhole where sinkhole_status = '" + "Active" + "'", Conn);
            //    MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(da);

            // DataTable dataTable = new DataTable();
            // DataSet ds = new DataSet();
            // da.Fill(dataTable);

            for (int i = dataGridView1.Rows.Count - 1; i >= 0; i--)
            {
                double lng   = Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value);
                double lat   = Convert.ToDouble(dataGridView1.Rows[i].Cells[0].Value);
                string misto = Convert.ToString(dataGridView1.Rows[i].Cells[2].Value);

                // double lng = double.Parse(dataGridView1.Rows[i][4].ToString());
                //  double lat = double.Parse(dataGridView1.Rows[i][3].ToString());
                //string location = dataTable.Rows[i][2].ToString();
                // string name = dataTable.Rows[i][1].ToString();
                // string desciption = dataTable.Rows[i][5].ToString();



                ////ok
                //GMap.NET.WindowsForms.GMapOverlay markers = new GMap.NET.WindowsForms.GMapOverlay("markers");
                //GMap.NET.WindowsForms.GMapMarker marker =
                //   new GMap.NET.WindowsForms.Markers.GMarkerGoogle(

                //new GMap.NET.PointLatLng(lat, lng),
                //new Bitmap("C:\\Users\\Admin\\Desktop\\1logo-większe.jpg"));
                //marker.ToolTipText = misto;
                //markers.Markers.Add(marker);
                //map.Overlays.Add(markers);


                //ok
                GMap.NET.WindowsForms.GMapOverlay markers = new GMap.NET.WindowsForms.GMapOverlay("markers");
                GMap.NET.WindowsForms.GMapMarker  marker  =
                    new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
                        new GMap.NET.PointLatLng(lat, lng), GMarkerGoogleType.green);
                marker.ToolTipText = misto + " POJEMNIKÓW NA STANIE: 2000, W UŻYCIU: 1500, WOLNYCH: 500";
                markers.Markers.Add(marker);
                map.Overlays.Add(markers);



                ////ok
                GMap.NET.WindowsForms.GMapOverlay markerSs = new GMap.NET.WindowsForms.GMapOverlay("markers");
                GMap.NET.WindowsForms.GMapMarker  markerR  =
                    new GMap.NET.WindowsForms.Markers.GMarkerGoogle(

                        new GMap.NET.PointLatLng(50.9493132, 21.3966463),
                        new Bitmap("C:\\Users\\Admin\\Desktop\\1logo-większe.jpg"));
                markerR.ToolTipText = "ELKOM TRADE S.A.";
                markerSs.Markers.Add(markerR);
                map.Overlays.Add(markerSs);



                GMap.NET.WindowsForms.GMapOverlay markersSS = new GMap.NET.WindowsForms.GMapOverlay("markers");
                GMap.NET.WindowsForms.GMapMarker  markerRR  =
                    new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
                        new GMap.NET.PointLatLng(41.3833, 2.1834), GMarkerGoogleType.red_big_stop);
                markerRR.ToolTipText = "BARCELONA PRZEKROCZONY CZAS ZWROTU O 15 DNI, DO ZWROTU 1200 POJEMNIKÓW ";
                markersSS.Markers.Add(markerRR);
                map.Overlays.Add(markersSS);



                //GMapOverlay markersOverlay = new GMapOverlay("markers");
                //GMarkerGoogle markerr = new GMarkerGoogle(new PointLatLng(50.9493132 ,21.3966463),
                //   new Bitmap("C:\\Users\\Admin\\Desktop\\1logo-większe.jpg"));
                //markersOverlay.Markers.Add(marker);
                //marker.ToolTipText = "WYSŁANO 2500 POJEMNIKÓW " +
                //    "OBECNIE NA STANIE 1500 POJEMNIKÓW ";
                //map.Overlays.Add(markersOverlay);



                //GMapOverlay markersOverlay = new GMapOverlay("markers");
                //GMarkerGoogle markerr = new GMarkerGoogle(new PointLatLng(50.334778, 19.256055), GMarkerGoogleType.red);
                //markersOverlay.Markers.Add(markerr);
                //markerr.ToolTipText = "HANEX 2536 POJEMNIKÓW";
                //map.Overlays.Add(markersOverlay);



                //GMapOverlay markersOverlay = new GMapOverlay("marker");
                //GMapMarkerGoogleGreen marker = new GMapMarkerGoogleGreen(new PointLatLng(lat, lng));
                //markersOverlay.Markers.Add(marker);
                ////marker.ToolTipMode = MarkerTooltipMode.Always;
                //marker.ToolTip = new GMapRoundedToolTip(marker);
                //marker.ToolTipText = "Coordinates: (" + Convert.ToString(lat) + "," + Convert.ToString(lng);
                //map.Overlays.Add(markersOverlay);
            }



            map.MapProvider = GMap.NET.MapProviders.BingHybridMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            map.SetPositionByKeywords("Poland, Ostrowiec");
            map.ShowCenter = false;

            //GMap.NET.WindowsForms.GMapOverlay markers = new GMap.NET.WindowsForms.GMapOverlay("markers");
            //GMap.NET.WindowsForms.GMapMarker marker =
            //   new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
            //        new GMap.NET.PointLatLng(50.9493144, 21.3960227),
            //        new Bitmap("C:\\Users\\Admin\\Desktop\\1logo-większe.jpg"));
            //marker.ToolTipText = "Nasza Firma";
            //markers.Markers.Add(marker);
            //map.Overlays.Add(markers);



            //GMapOverlay markers = new GMapOverlay("markers");
            //GMapMarker marker = new GMarkerGoogle(
            //    new PointLatLng(doubleValue, doubleValue2),
            //    new Bitmap("C:\\Users\\Admin\\Desktop\\1logo-większe.jpg"));
            //markers.Markers.Add(marker);
            //map.Overlays.Add(markers);


            //gmap.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
            //GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            //gmap.Position = new PointLatLng(37.9667, 23.7167);

            //gmap.MouseClick += new MouseEventHandler(map_MouseClick);

            // Initialize map:
            //gmap.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
            //GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            //gmap.Position = new PointLatLng(37.9667, 23.7167);

            //gmap.MouseClick += new MouseEventHandler(Map_MouseClick);



            //open map and create marker and its label
            map.MapProvider = GMapProviders.GoogleMap;
            map.Position    = new PointLatLng(0, 0);
            map.MinZoom     = 2;
            map.MaxZoom     = 24;
            map.Zoom        = 2;



            //GMapOverlay markersOverlay = new GMapOverlay("markers");
            //GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(50.334778, 19.256055), GMarkerGoogleType.red);
            //markersOverlay.Markers.Add(marker);
            //marker.ToolTipText = "HANEX 2536 POJEMNIKÓW";
            //gmap.Overlays.Add(markersOverlay);


            // remove marker
            // gmap.Overlays.Remove(marker);
        }
예제 #9
0
        private void OnLoadOrder(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title      = "Select the order list file";
            dlg.DefaultExt = "txt";
            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string listfilename = dlg.FileName;

            progressBar.Value = 0;
            if (!manager.ReadOrdersFromFile(listfilename))
            {
                MessageBox.Show("can not load the order list file!");
                return;
            }
            progressBar.Value = 10;
            for (int i = 0; i < DeliverManager.maxordercnt; i++)
            {
                for (int j = 0; j < DeliverManager.maxordercnt; j++)
                {
                    manager.distanceMatrix[i, j] = 0;
                }
            }

            int ordercnt = DeliverManager.orderlist.Count;

            for (int i = 0; i < ordercnt; i++)
            {
                progressBar.Value = 10 + Convert.ToInt32(90.0 / (double)ordercnt * (double)i);
                string           json = string.Empty;
                string           url = @"https://maps.googleapis.com/maps/api/geocode/json?address=";
                string           address = "Canada, " + DeliverManager.orderlist[i].city + ", " + DeliverManager.orderlist[i].streetname;
                string           addressforsql = "'" + address + "'";
                string           sql = "select * from geocode where address = " + addressforsql;
                SQLiteCommand    command = new SQLiteCommand(sql, dbConnection);
                SQLiteDataReader sqlreader = command.ExecuteReader();
                double           lat, lng;
                if (sqlreader.Read())
                {
                    lat = Convert.ToDouble(sqlreader["lat"].ToString());
                    lng = Convert.ToDouble(sqlreader["lng"].ToString());
                }
                else
                {
                    url = url + address + "&key=" + apikey;
                    url.Replace(' ', '+');
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    request.AutomaticDecompression = DecompressionMethods.GZip;
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                        using (Stream stream = response.GetResponseStream())
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                json = reader.ReadToEnd();
                            }

                    int latstart = json.IndexOf("\"lat\""); if (latstart < 0)
                    {
                        continue;
                    }
                    json = json.Substring(latstart + 7); int latend = json.IndexOf(','); string slat = json.Substring(0, latend); json = json.Substring(latend);
                    int lngstart = json.IndexOf("\"lng\""); if (lngstart < 0)
                    {
                        continue;
                    }
                    json = json.Substring(lngstart + 7); int lngend = json.IndexOf('\n'); string slng = json.Substring(0, lngend);

                    lng = Convert.ToDouble(slng);
                    lat = Convert.ToDouble(slat);

                    sql     = "insert into geocode (address,lat,lng) values(" + addressforsql + " , " + Convert.ToString(lat) + " , " + Convert.ToString(lng) + ")";
                    command = new SQLiteCommand(sql, dbConnection);
                    command.ExecuteNonQuery();
                }

                DeliverManager.orderlist[i].lat = lat;
                DeliverManager.orderlist[i].lng = lng;
                GMap.NET.WindowsForms.GMapMarker marker =
                    new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
                        new GMap.NET.PointLatLng(lat, lng),
                        GMap.NET.WindowsForms.Markers.GMarkerGoogleType.blue_pushpin);
                markers.Markers.Add(marker);
            }

            //  manager.LoadDistance();
            manager.AutoDeploy();
            progressBar.Value = 100;
            RedrawMap();
        }