Пример #1
0
        public static GMapRoute DrawRoute(GMapOverlay overlay, RouteList routeList, RouteGeometryCalculator geometryCalc = null)
        {
            List <PointLatLng> points;
            var baseLat = (double)routeList.GeographicGroups.FirstOrDefault().BaseLatitude.Value;
            var baseLon = (double)routeList.GeographicGroups.FirstOrDefault().BaseLongitude.Value;

            if (geometryCalc != null)
            {
                var address = routeList.GenerateHashPointsOfRoute();
                StartProgress(address.Length);
                points = geometryCalc.GetGeometryOfRoute(address, UpdateProgress);
                CloseProgress();
            }
            else
            {
                points = new List <PointLatLng>();
                points.Add(new PointLatLng(baseLat, baseLon));
                points.AddRange(routeList.Addresses.Select(x => x.Order.DeliveryPoint.GmapPoint));
                points.Add(new PointLatLng(baseLat, baseLon));
            }

            var route = new GMapRoute(points, routeList.Id.ToString())
            {
                Stroke = new System.Drawing.Pen(System.Drawing.Color.Blue)
                {
                    Width     = 2,
                    DashStyle = System.Drawing.Drawing2D.DashStyle.Solid
                }
            };

            overlay.Routes.Add(route);
            return(route);
        }
Пример #2
0
        public static GMapRoute DrawRoute(GMapOverlay overlay, RouteList routeList, RouteGeometryCalculator geometryCalc = null)
        {
            List <PointLatLng> points;

            if (geometryCalc != null)
            {
                var address = routeList.GenerateHashPiontsOfRoute();
                MainClass.progressBarWin.ProgressStart(address.Length);
                points = geometryCalc.GetGeometryOfRoute(address, (val, max) => MainClass.progressBarWin.ProgressUpdate(val));
                MainClass.progressBarWin.ProgressClose();
            }
            else
            {
                points = new List <PointLatLng>();
                points.Add(DistanceCalculator.BasePoint);
                points.AddRange(routeList.Addresses.Select(x => x.Order.DeliveryPoint.GmapPoint));
                points.Add(DistanceCalculator.BasePoint);
            }

            var route = new GMapRoute(points, routeList.Id.ToString());

            route.Stroke           = new System.Drawing.Pen(System.Drawing.Color.Blue);
            route.Stroke.Width     = 2;
            route.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;

            overlay.Routes.Add(route);
            return(route);
        }