Beispiel #1
0
        public GMapMarker moveTo(PointLatLng dest)
        {
            // провайдер навигации
            RoutingProvider routingProvider = GMapProviders.OpenStreetMap;
            // определение маршрута
            MapRoute route = routingProvider.GetRoute(
                point, // начальная точка маршрута
                dest,  // конечная точка маршрута
                false, // поиск по шоссе (false - включен)
                false, // режим пешехода (false - выключен)
                (int)15);
            // получение точек маршрута
            List <PointLatLng> routePoints = route.Points;

            this.route = new CRoude("", routePoints);

            double dist    = 0;
            double minDist = 0.00001;

            List <PointLatLng> points = this.route.getPoints();

            ePoints.Clear();

            for (int i = 0; i < points.Count - 1; i++)
            {
                dist = Vector2.Distance(new Vector2((float)points[i].Lat, (float)points[i].Lng), new Vector2((float)points[i + 1].Lat, (float)points[i + 1].Lng));
                if (dist > minDist)
                {
                    double aPoints = dist / minDist;
                    for (int j = 0; j < aPoints; j++)
                    {
                        Vector2 t = Vector2.Lerp(new Vector2((float)points[i].Lat, (float)points[i].Lng), new Vector2((float)points[i + 1].Lat, (float)points[i + 1].Lng), (float)(j / aPoints));
                        ePoints.Add(new PointLatLng(t.X, t.Y));
                    }
                }
            }



            newThread = new Thread(new ThreadStart(MoveByRoute));
            newThread.Start();


            return(this.route.getMarker());
        }
Beispiel #2
0
 private void button1_Click(object sender, RoutedEventArgs e)//add obj
 {
     try
     {
         if (objType.SelectedIndex > -1 && createFlag == true)
         {
             if (objType.SelectedIndex == 0 && objTitle.Text.Length > 0)
             {
                 CCar car = new CCar(objTitle.Text, pts[0], Map);
                 objs.Add(car);
                 cars.Add(car);
             }
             else if (objType.SelectedIndex == 0 && objTitle.Text.Length == 0)
             {
                 MessageBox.Show("Введите имя машины");
             }
             if (objType.SelectedIndex == 1 && objTitle.Text.Length > 0)
             {
                 human = new CHuman(objTitle.Text, pts[0]);
                 objs.Add(human);
             }
             else if (objType.SelectedIndex == 1 && objTitle.Text.Length == 0)
             {
                 MessageBox.Show("Введите имя человека");
             }
             if (objType.SelectedIndex == 2 && objTitle.Text.Length > 0)
             {
                 CLocation location = new CLocation(objTitle.Text, pts[0]);
                 objs.Add(location);
             }
             else if (objType.SelectedIndex == 2 && objTitle.Text.Length == 0)
             {
                 MessageBox.Show("Введите название место прибытия");
             }
             if (objType.SelectedIndex == 3 && pts.Count > 2 && objTitle.Text.Length > 0)
             {
                 CArea area = new CArea(objTitle.Text, pts);
                 objs.Add(area);
             }
             else if (objType.SelectedIndex == 3 && pts.Count <= 2 && objTitle.Text.Length > 0)
             {
                 MessageBox.Show("Обозначьте площадь не менее из 3 точек");
             }
             if (objType.SelectedIndex == 4 && pts.Count > 1 && objTitle.Text.Length > 0)
             {
                 CRoude roude = new CRoude(objTitle.Text, pts);
                 objs.Add(roude);
             }
             else if (objType.SelectedIndex == 4 && pts.Count <= 1 && objTitle.Text.Length > 0)
             {
                 MessageBox.Show("Введите маршрут не менее из 2 точек");
             }
         }
         else if (objType.SelectedIndex > -1 && !createFlag)
         {
         }
         pts.Clear();
         Map.Markers.Clear();
         objTitle.Clear();
         objectList.Items.Clear();
         foreach (CMapObject cm in objs)
         {
             Map.Markers.Add(cm.getMarker());
             objectList.Items.Add(cm.getTitle());
         }
         foreach (GMapMarker cm in markerTaxi)
         {
             Map.Markers.Add(cm);
         }
     }
     catch
     {
         MessageBox.Show("Выберите место");
     }
 }