async Task DelayTime(PointLatLng _start, PointLatLng _end) { await Task.Delay(TimeSpan.FromSeconds(5)); RoutingProvider rp = MyMapControl.MainMap.MapProvider as RoutingProvider; if (rp == null) { rp = GMapProviders.BingHybridMap; // use OpenStreetMap if provider does not implement routing } MapRoute route = rp.GetRoute(_start, _end, false, false, (int)MyMapControl.MainMap.Zoom); if (route != null) { GMapMarker m2 = new GMapMarker(_end); m2.Shape = new MyMarkerRouteAnchor(MyMapControl, m2, "End: " + start.ToString()); GMapRoute mRoute = new GMapRoute(route.Points); { mRoute.ZIndex = -1; } MyMapControl.MainMap.Markers.Add(m2); MyMapControl.MainMap.Markers.Add(mRoute); MyMapControl.MainMap.ZoomAndCenterMarkers(null); } }
private void CallT_Click(object sender, RoutedEventArgs e) { CBar.Value = 0; Car nearestCar = null; RStart = Passanger.getFocus(); var Obj = mapObjects.OrderBy(mapObject => mapObject.getDistance(RStart)); foreach (MapObject obj in Obj) { if (obj is Car) { nearestCar = (Car)obj; break; } } CallT.IsEnabled = false; var route = nearestCar.MoveTo(RStart); MapObject mapObject_path = new Route_c(OName.Text, "Route", route.Points, route.Points.First()); Map.Markers.Add(mapObject_path.GetMarker()); RoutingProvider routingProvider = GMapProviders.OpenStreetMap; MapRoute rroute = routingProvider.GetRoute(RStart, RFinish, false, false, 15); MapObject mapObject_path1 = new Route_c(OName.Text, "Route", rroute.Points, rroute.Points.First()); Map.Markers.Add(mapObject_path1.GetMarker()); nearestCar.Arrived += Passanger.CarArrived; Passanger.seated += nearestCar.getintocar; nearestCar.Follow += Focus_Follow; }
PointLatLng end; //终点 private void AddMarkerCommandFunc(object obj) { start = new PointLatLng(36.7564903295052, 119.20166015625); end = new PointLatLng(34.6332079113796, 114.873046875); RoutingProvider rp = MyMapControl.MainMap.MapProvider as RoutingProvider; if (rp == null) { rp = GMapProviders.BingHybridMap; // use OpenStreetMap if provider does not implement routing } MapRoute route = rp.GetRoute(start, end, false, false, (int)MyMapControl.MainMap.Zoom); if (route != null) { GMapMarker m1 = new GMapMarker(start); m1.Shape = new MyMarkerRouteAnchor(MyMapControl, m1, "Start: " + route.Name); GMapMarker m2 = new GMapMarker(end); m2.Shape = new MyMarkerRouteAnchor(MyMapControl, m2, "End: " + start.ToString()); GMapRoute mRoute = new GMapRoute(route.Points); { mRoute.ZIndex = -1; } MyMapControl.MainMap.Markers.Add(m1); MyMapControl.MainMap.Markers.Add(m2); MyMapControl.MainMap.Markers.Add(mRoute); MyMapControl.MainMap.ZoomAndCenterMarkers(null); } }
// add test route void button3_Click(object sender, EventArgs e) { RoutingProvider rp = MainMap.MapProvider as RoutingProvider; if (rp == null) { rp = GMapProviders.OpenStreetMap; // use OpenStreetMap if provider does not implement routing } //地图路径 MapRoute route = rp.GetRoute(start, end, false, false, (int)MainMap.Zoom); if (route != null) { // add route GMapRoute r = new GMapRoute(route.Points, route.Name); r.IsHitTestVisible = true; routes.Routes.Add(r); ////////////////////////======================================================== // add route start/end marks GMapMarker m1 = new GMarkerGoogle(start, GMarkerGoogleType.green_big_go); m1.ToolTipText = "Start: " + route.Name; m1.ToolTipMode = MarkerTooltipMode.Always; GMapMarker m2 = new GMarkerGoogle(end, GMarkerGoogleType.red_big_stop); m2.ToolTipText = "End: " + end.ToString(); m2.ToolTipMode = MarkerTooltipMode.Always; objects.Markers.Add(m1); objects.Markers.Add(m2); MainMap.ZoomAndCenterRoute(r); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (markerFrom != null && markerTo != null) { try { RoutingProvider routingProvider = mapView.MapProvider as RoutingProvider ?? GMapProviders.OpenStreetMap; MapRoute route = routingProvider.GetRoute( new PointLatLng(markerFrom.LocalPositionX, markerFrom.LocalPositionY), //start new PointLatLng(markerTo.LocalPositionX, markerTo.LocalPositionY), //end true, //avoid highways true, //walking mode (int)mapView.Zoom); GMapRoute gmRoute = new GMapRoute(route.Points); mapView.Markers.Add(gmRoute); }catch (Exception ex) { MessageBox.Show(ex.Message); } } }
// adds route private void button12_Click(object sender, RoutedEventArgs e) { RoutingProvider rp = MainMap.MapProvider as RoutingProvider; if (rp == null) { rp = GMapProviders.OpenStreetMap; // use OpenStreetMap if provider does not implement routing } MapRoute route = rp.GetRoute(start, end, false, false, (int)MainMap.Zoom); if (route != null) { GMapMarker m1 = new GMapMarker(start); m1.Shape = new CustomMarkerDemo(this, m1, "Start: " + route.Name); GMapMarker m2 = new GMapMarker(end); m2.Shape = new CustomMarkerDemo(this, m2, "End: " + start.ToString()); GMapRoute mRoute = new GMapRoute(route.Points); { mRoute.ZIndex = -1; } MainMap.Markers.Add(m1); MainMap.Markers.Add(m2); MainMap.Markers.Add(mRoute); MainMap.ZoomAndCenterMarkers(null); } }
public GMapMarker CreateRouteToDestinationPoint(PointLatLng endPoint) { RoutingProvider routingProvider = GMapProviders.OpenStreetMap; MapRoute route = routingProvider.GetRoute(_point, endPoint, false, false, 15); List <PointLatLng> routePoints = route.Points; _route = new Route("Car Route", routePoints); double minDistance = 0.00001; lerpPoints.Clear(); for (int i = 0; i < routePoints.Count - 1; i++) { var vector1 = new Vector2((float)routePoints[i].Lat, (float)routePoints[i].Lng); var vector2 = new Vector2((float)routePoints[i + 1].Lat, (float)routePoints[i + 1].Lng); double distance = Vector2.Distance(vector1, vector2); if (distance > minDistance) { double aPoints = distance / minDistance; for (int j = 0; j < aPoints; j++) { var t = Vector2.Lerp(vector1, vector2, (float)(j / aPoints)); lerpPoints.Add(new PointLatLng(t.X, t.Y)); } } } return(_route.GetMarker()); }
private void BuildMapRoute(string pcoords) { string[] words = pcoords.Split(' '); PointLatLng p1 = new PointLatLng(StaticClient.Lat, StaticClient.Lng); PointLatLng p2 = new PointLatLng(Convert.ToDouble(words[0]), Convert.ToDouble(words[1])); RoutingProvider routingProvider = mapView.MapProvider as RoutingProvider ?? GMapProviders.BingMap; BingMapProvider.Instance.ClientKey = "HoLsxGmlUCb6vhRADCYj~G_TI0OHVo8QbRr87tVmgow~ArdsXtBoYnLbmJrFr6yViSyLzCvBF8g7Gmliae_nFJG6rIpdiNEUJeiy7CEraGZs"; MapRoute route = routingProvider.GetRoute( p1, p2, false, //avoid highways false, //walking mode 14); GMapRoute gmRoute = new GMapRoute(route.Points); mapView.Markers.Add(gmRoute); Ellipse marker = new Ellipse(); marker.Fill = System.Windows.Media.Brushes.Red; marker.Stroke = System.Windows.Media.Brushes.Black; mapView.Markers.Add(new GMapMarker(p1) { Shape = marker }); mapView.Markers.Add(new GMapMarker(p2) { Shape = marker }); }
//taxi private void Bcallcar_Click(object sender, RoutedEventArgs e) { endPoint = pointsofarea.Last(); if (pointsofarea.Count != 0) { progressLine.Value = 0; foreach (MapObjectBase obj in mapObjects) { if (obj is Human) { startPoint = (obj.getFocus()); } } Car taxi = null; Human pl = null; foreach (MapObjectBase obj in mapObjects) { if (obj is Human) { pl = (Human)obj; pl.destinationPoint = pointsofarea.Last(); break; } } foreach (MapObjectBase obj in mapObjects) { if (obj is Car) { taxi = (Car)obj; break; } } var t = taxi.moveTo(startPoint); addMarker(4, t.Points); // провайдер навигации RoutingProvider routingProvider = GMapProviders.OpenStreetMap; // определение маршрута MapRoute route = routingProvider.GetRoute( startPoint, // начальная точка маршрута endPoint, // конечная точка маршрута false, // поиск по шоссе (false - включен) false, // режим пешехода (false - выключен) 15); addMarker(4, route.Points); taxi.Arrived += pl.CarArrived; pl.seated += taxi.inTocar; taxi.Follow += Focus_Follow; } else { MessageBox.Show("select an endpoint"); } }
private void stuvk_Click(object sender, RoutedEventArgs e) { { waybar.Value = 0; foreach (MapObject obj in mapObjects) { if (obj is Human) { startOfRoute = (obj.getFocus()); } } endOfRoute = areapoints.Last(); var besidedObj = mapObjects.OrderBy(mapObject => mapObject.getDistance(startOfRoute)); Car nearestCar = null; Human h = null; foreach (MapObject obj in mapObjects) { if (obj is Human) { h = (Human)obj; h.destinationPoint = endOfRoute; break; } } foreach (MapObject obj in besidedObj) { if (obj is Car) { nearestCar = (Car)obj; break; } } var aaa = nearestCar.MoveTo(startOfRoute); createMarker(aaa.Points, 3); RoutingProvider routingProvider = GMapProviders.OpenStreetMap; MapRoute route = routingProvider.GetRoute( startOfRoute, endOfRoute, false, false, 15); createMarker(route.Points, 3); nearestCar.Arrived += h.CarArrived; h.seated += nearestCar.getintocar; nearestCar.Follow += Focus_Follow; // nearestCar.Arrived -= h.CarArrived; // h.seated -= nearestCar.getintocar; } }
public MapRoute MoveTo(PointLatLng endpoint) { RoutingProvider routingProvider = GMapProviders.OpenStreetMap; route = routingProvider.GetRoute(point, endpoint, false, false, 15); Thread ridingCar = new Thread(MoveByRoute); ridingCar.Start(); return(route); }
public GMapRoute RoutAdd(RoutingProvider rp) { List <PointLatLng> ps = new List <PointLatLng>(); for (int i = 0; i < Lpll.Count - 1; i++) { MapRoute r = rp.GetRoute(Lpll[i], Lpll[i + 1], false, true, 13); ps.AddRange(r.Points); } gMapRoute = new GMapRoute(ps); return(gMapRoute); }
public Route moveTo(PointLatLng endpoint) { RoutingProvider routingProvider = GMapProviders.OpenStreetMap; MapRoute route = routingProvider.GetRoute(point, endpoint, false, false, 15); List <PointLatLng> routePoints = route.Points; this.route = new Route("", routePoints); Thread newThread = new Thread(new ThreadStart(moveByRoute)); newThread.Start(); return(this.route); }
public GMapMarker moveTo(PointLatLng LastP) { RoutingProvider routingProvider = GMapProviders.OpenStreetMap; MapRoute route = routingProvider.GetRoute(Point, LastP, false, false, (int)15); // (начало, конец, дорога, пешеход) List <PointLatLng> routePoints = route.Points; this.route = new Route("", routePoints); newThread = new Thread(new ThreadStart(Movement)); newThread.Start(); return(this.route.GetMarker()); }
private void Create_Map_Click(object sender, RoutedEventArgs e) { RoutingProvider rp = gmap.MapProvider as RoutingProvider; List <PointLatLng> ps = new List <PointLatLng>(); for (int i = 0; i < Lpll.Count - 1; i++) { MapRoute r = rp.GetRoute(Lpll[i], Lpll[i + 1], false, true, 13); ps.AddRange(r.Points); } GMapRoute mapRoute = new GMapRoute(ps); gmap.Markers.Add(mapRoute); gmap.ZoomAndCenterMarkers(13); }
private void btnRoute_Click(object sender, EventArgs e) { if (countPoint < 2) { MessageBox.Show("Нужно добавить хотя бы 2 точки на карту!"); } else { RoutingProvider rp = gMap.MapProvider as RoutingProvider; if (rp == null) { rp = GMapProviders.OpenStreetMap; } try { gMap.Overlays.Add(Routes); for (int i = 1; i < points.Count(); i++) { MapRoute r = rp.GetRoute(points[i - 1], points[i], false, false, (int)gMap.Zoom); GMapRoute route = new GMapRoute(r.Points, r.Name); route.Stroke = new Pen(Color.Red, 2); route.IsVisible = true; Routes.Routes.Add(route); distance += r.Distance; duration += Convert.ToInt32(r.Duration.Substring(0, r.Duration.Length - 4)); } var start = points[0]; var end = points[points.Count() - 1]; GMapMarker m1 = new GMarkerGoogle(start, GMarkerGoogleType.green_dot); GMapMarker m2 = new GMarkerGoogle(end, GMarkerGoogleType.red_dot); gMap.Overlays.Add(Objects); Objects.Markers.Add(m1); Objects.Markers.Add(m2); gMap.ZoomAndCenterRoutes("routes"); gMap.Refresh(); textDist.Text = Math.Round(distance, 2) + " км."; textTime.Text = getTime(duration); } catch { MessageBox.Show("Не удалось построить маршрут!\nПопробуйте еще раз."); } } }
private void DrawRoute() { List <MapPoint> trivandrumRoute = this.GetNavRoute(); if (trivandrumRoute.Count > 2) { PointLatLng start, end; RoutingProvider rp = this.transporterMap.MapProvider as RoutingProvider; MapRoute route; if (rp == null) { rp = GMapProviders.GoogleMap; // use google if provider does not implement routing } for (int i = 0; i < trivandrumRoute.Count - 1; i++) { start = trivandrumRoute[i].LatLong; end = trivandrumRoute[i + 1].LatLong; //Get map route route = rp.GetRoute(start, end, false, false, (int)transporterMap.Zoom); if (travelRoute == null) { travelRoute = route; } else { travelRoute.Points.AddRange(route.Points); } if (route != null) { GMapMarker mRoute = new GMapMarker(start); { mRoute.Route.AddRange(route.Points); mRoute.RegenerateRouteShape(this.transporterMap); mRoute.ZIndex = -1; } this.transporterMap.Markers.Add(mRoute); } } } for (int i = 0; i < trivandrumRoute.Count; i++) { this.PinPointsOnMap(trivandrumRoute[i].LatLong); } }
public GMapMarker MoveTo(PointLatLng endPoint) { // провайдер навигации RoutingProvider routingProvider = GMapProviders.OpenStreetMap; // определение маршрута MapRoute route = routingProvider.GetRoute(point, endPoint, false, false, 15); // получение точек маршрута List <PointLatLng> routePoints = route.Points; this.route = new Route("go", routePoints); Thread newThread = new Thread(new ThreadStart(MoveByRoute)); newThread.Start(); return(this.route.GetMarker()); }
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 Route("", 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)); } } } Thread newThread = new Thread(new ThreadStart(MoveByRoute)); newThread.Start(); return(this.route.getMarker()); }
private void DrawrouteBetweenTowPoint(PointLatLng pointLatLng_S, PointLatLng pointLatLng_E) { RoutingProvider rp = mapControl.MapProvider as RoutingProvider; if (rp == null) { rp = GMapProviders.OpenStreetMap; } MapRoute route = rp.GetRoute(pointLatLng_S, pointLatLng_E, false, false, (int)mapControl.Zoom); if (route != null) { GMapRoute r = new GMapRoute(route.Points, route.Name); markersOverlay.Routes.Add(r); mapControl.ZoomAndCenterRoute(r); } }
//taxi public MapRoute moveTo(PointLatLng endpoint) { // провайдер навигации RoutingProvider routingProvider = GMapProviders.OpenStreetMap; // определение маршрута route = routingProvider.GetRoute( point, // начальная точка маршрута endpoint, // конечная точка маршрута false, // поиск по шоссе (false - включен) false, // режим пешехода (false - выключен) 15); // получение точек маршрута Thread newThread = new Thread(MoveByRoute); newThread.Start(); return(route); }
private void add_route_btn_Click(object sender, RoutedEventArgs e) { RoverConsole.ArcEyeAiContentThreadSafe("Trying To Find The Route Between Start Point And End Point"); RoutingProvider routingProvider = map_viw.MapProvider as RoutingProvider; if (routingProvider == null) { routingProvider = GMapProviders.OpenStreetMap; } MapRoute mapRoute = routingProvider.GetRoute(startingPosition, endingPosition, false, false, (int)map_viw.Zoom); if (mapRoute != null) { GMapMarker tempStartingPosition = new GMapMarker(startingPosition); tempStartingPosition.Shape = new Rectangle { Width = 10, Height = 10, Stroke = Brushes.Blue, StrokeThickness = 1.5 }; GMapMarker tempEndingPosition = new GMapMarker(endingPosition); tempEndingPosition.Shape = new Rectangle { Width = 10, Height = 10, Stroke = Brushes.Blue, StrokeThickness = 1.5 }; GMapRoute gMapRoute = new GMapRoute(mapRoute.Points); { gMapRoute.ZIndex = -1; } map_viw.Markers.Add(tempStartingPosition); map_viw.Markers.Add(tempEndingPosition); map_viw.Markers.Add(gMapRoute); map_viw.ZoomAndCenterMarkers(null); } RoverConsole.ArcEyeAiContentThreadSafe("Route Between Start Point And End Point Is Initialized In The Map"); }
private void ShowRoute_Click(object sender, RoutedEventArgs e) { if (RoutePoints.Count > 1) { PointLatLng start = RoutePoints[0]; PointLatLng end = RoutePoints[1]; RoutingProvider rp = MainMap.MapProvider as RoutingProvider; if (rp == null) { rp = GMapProviders.GoogleMap; // use google if provider does not implement routing } //Start timer for (int i = 0; i < this.RoutePoints.Count - 1; i++) { start = RoutePoints[i]; end = RoutePoints[i + 1]; //Get map route route = rp.GetRoute(start, end, false, false, (int)MainMap.Zoom); routePath.AddRange(route.Points);// Combining path of selected route if (route != null) { GMapMarker mRoute = new GMapMarker(start); { //for show route mRoute.Route.AddRange(route.Points); mRoute.RegenerateRouteShape(MainMap); //for show polygon //route.Points.Add(route.Points[0]); //mRoute.Polygon.AddRange(route.Points); //mRoute.RegeneratePolygonShape(MainMap); mRoute.ZIndex = -1; } MainMap.Markers.Add(mRoute); } }//end of for loop } }
public void moveTo(PointLatLng endPoint) { //построить маршрут до указанной точки и сохранить в route // провайдер навигации RoutingProvider routingProvider = GMapProviders.OpenStreetMap; // определение маршрута MapRoute route = routingProvider.GetRoute( this.point, // начальная точка маршрута endPoint, // конечная точка маршрута false, // поиск по шоссе (false - включен) false, // режим пешехода (false - выключен) 15); // получение точек маршрута this.route = route.Points; //начать движение Thread newThread = new Thread(new ThreadStart(moveByRoute)); newThread.Start(); }
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 Route("", routePoints); Thread newThread = new Thread(new ThreadStart(MoveByRoute)); newThread.Start(); return(this.route.getMarker()); }
//----------------------------------------------------------------------------- private void addRoute(ref PointLatLng startPoint, ref PointLatLng destination) { RoutingProvider routeProvider = GMapProviders.OpenStreetMap; MapRoute route = routeProvider.GetRoute(startPoint, destination, false, false, 8); if (route != null) { // add route GMapRoute mapRoute = new GMapRoute(route.Points, route.Name); mapRoute.IsHitTestVisible = true; mapRoute.Stroke = new Pen(Color.Red, 3); removeRoutes(); m_routes.Routes.Add(mapRoute); //Calculate Distance DistanceVal.Text = Math.Round(mapRoute.Distance, 2) + "Kms"; // add route start/end marks GMapMarker startPos = new GMarkerGoogle(startPoint, GMarkerGoogleType.green_big_go); startPos.ToolTipText = "Start point "; startPos.ToolTipMode = MarkerTooltipMode.Always; GMapMarker destPos = new GMarkerGoogle(destination, GMarkerGoogleType.red_big_stop); destPos.ToolTipText = "Destination"; destPos.ToolTipMode = MarkerTooltipMode.Always; removeMarkers(); m_markers.Markers.Add(startPos); m_markers.Markers.Add(destPos); goolgeMap.Overlays.Add(m_markers); goolgeMap.Overlays.Add(m_routes); goolgeMap.Zoom = 15; goolgeMap.Position = startPoint; goolgeMap.Refresh(); } }
public GMapMarker MoveTo(PointLatLng endPoint) { RoutingProvider routingProvider = GMapProviders.OpenStreetMap; route = routingProvider.GetRoute( Point, endPoint, false, false, 15); List <PointLatLng> routePoints = route.Points; this.Route1 = new Route("", routePoints); Thread ridingCar = new Thread(MoveByRoute); ridingCar.Start(); return(this.Route1.getMarker()); }
// adds route private void button12_Click(object sender, RoutedEventArgs e) { RoutingProvider rp = MainMap.MapProvider as RoutingProvider; if (rp == null) { rp = GMapProviders.OpenStreetMap; // use OpenStreetMap if provider does not implement routing } MapRoute route = rp.GetRoute(start, end, false, false, (int)MainMap.Zoom); if (route != null) { GMapMarker m1 = new GMapMarker(start); m1.Shape = new CustomMarkerDemo(this, m1, "Start: " + route.Name); GMapMarker m2 = new GMapMarker(end); m2.Shape = new CustomMarkerDemo(this, m2, "End: " + start.ToString()); List <PointLatLng> EvPoints = new List <PointLatLng>(); foreach (var item in route.Points) { EvPoints.Add(GMap.NET.Internals.EvilTransform.transform(item.Lat, item.Lng)); } GMapRoute mRoute = new GMapRoute(EvPoints); { mRoute.ZIndex = -1; } MainMap.Markers.Add(m1); MainMap.Markers.Add(m2); MainMap.Markers.Add(mRoute); MainMap.ZoomAndCenterMarkers(null); } }
private void MoveByRoute() { // test test test test test test test test test MapRoute route = routingProvider.GetRoute( areaspots.Last(), // начальная точка маршрута areaspots[0], // конечная точка маршрута false, // поиск по шоссе (false - включен) false, // режим пешехода (false - выключен) (int)15); // получение точек маршрута List <PointLatLng> routePoints = route.Points; // последовательный перебор точек маршрута foreach (var point in route.Points) { // делегат, возвращающий управление в главный поток System.Windows.Application.Current.Dispatcher.Invoke(delegate { // изменение позиции маркера Map.Position = point; }); // задержка 500 мс Thread.Sleep(500); } }
private void stuvk_Click(object sender, RoutedEventArgs e) { { waybar.Value = 0; foreach (MapObject obj in mapObjects) { if (obj is Human_class) { startOfRoute = (obj.getFocus()); } } endOfRoute = areaspots.Last(); var besidedObj = mapObjects.OrderBy(mapObject => mapObject.getDist(startOfRoute)); Car_class nearestCar = null; Human_class h = null; foreach (MapObject obj in mapObjects) { if (obj is Human_class) { h = (Human_class)obj; h.destinationPoint = endOfRoute; break; } } foreach (MapObject obj in besidedObj) { if (obj is Car_class) { nearestCar = (Car_class)obj; break; } } var localRoute = nearestCar.MoveTo(startOfRoute); if (localRoute != null) { createMarker(localRoute.Points, 4); } else { System.Windows.MessageBox.Show("маршрут не назначен"); } RoutingProvider routingProvider = GMapProviders.OpenStreetMap; MapRoute route = routingProvider.GetRoute( startOfRoute, endOfRoute, false, false, 15); createMarker(route.Points, 4); nearestCar.Arrived += h.CarArrived; h.seated += nearestCar.getintocar; nearestCar.Follow += Focus_Follow; nearestCar.Arrived += nearestCar.test; // nearestCar.Arrived -= h.CarArrived; // h.seated -= nearestCar.getintocar; } }