コード例 #1
0
ファイル: Program.cs プロジェクト: TiriaAndersen/vroom
        public MapPointCall(DistEvaluator distEvaluator)
        {
            this.mDistEvaluator = distEvaluator;
            this.mMapPoint      = new MapPoint.ApplicationClass();
            this.mMapPoint.Application.Units = MapPoint.GeoUnits.geoKm;
            this.mMapPoint.Visible           = false;
            this.mMapPoint.UserControl       = true;

            //Configure l'application
            mMap   = this.mMapPoint.ActiveMap;
            mRoute = mMap.ActiveRoute;

            mMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner;
        }
コード例 #2
0
        public void GetDistanceAndTime(string origin, string destination, string estimatedTime)
        {
            try
            {
                string orignpostcode       = General.GetPostCodeMatch(origin);
                string destinationpostcode = General.GetPostCodeMatch(destination);



                MapPoint.Route objRoute = axMappointControl1.ActiveMap.ActiveRoute;



                objRoute.Waypoints.Add(GetLocation(orignpostcode), "A");
                object item = 1;

                objRoute.Waypoints.get_Item(ref item).SegmentPreferences = MapPoint.GeoSegmentPreferences.geoSegmentShortest;



                // }
                string[] arrayvia = (string[])obj[1];

                object viaItem = 2;
                int    viaVal  = 2;
                if (arrayvia != null)
                {
                    foreach (var itemvia in arrayvia)
                    {
                        objRoute.Waypoints.Add(GetLocation(General.GetPostCodeMatch(itemvia)), "B");
                        objRoute.Waypoints.get_Item(ref viaItem).SegmentPreferences = MapPoint.GeoSegmentPreferences.geoSegmentShortest;

                        viaVal++;
                        viaItem = (object)viaVal;
                    }
                }



                object item2 = viaItem;

                objRoute.Waypoints.Add(GetLocation(destinationpostcode), "B");
                //     objRoute.Waypoints.Optimize();

                objRoute.Waypoints.get_Item(ref item2).SegmentPreferences = MapPoint.GeoSegmentPreferences.geoSegmentShortest;


                objRoute.ZoomTo();

                objRoute.Calculate();



                distance = Convert.ToDecimal(objRoute.Distance);
                gettime  = (objRoute.DrivingTime * 24 * 60).ToInt().ToStr() + " mins";

                axMappointControl1.ItineraryVisible = false;
            }
            catch (Exception ex)
            {
                string[] via   = (string[])obj[1];
                string   error = string.Empty;


                if (via != null && via.Count() > 0)
                {
                    error = ex.Message;

                    foreach (var itemVia in via)
                    {
                        error += Environment.NewLine + itemVia;
                    }
                }


                File.WriteAllText(System.Windows.Forms.Application.StartupPath + "\\errorLog.txt", error);
                // MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: vpillac/vroom
        public MapPointCall(DistEvaluator distEvaluator)
        {
            this.mDistEvaluator = distEvaluator;
            this.mMapPoint = new MapPoint.ApplicationClass();
            this.mMapPoint.Application.Units = MapPoint.GeoUnits.geoKm;
            this.mMapPoint.Visible = false;
            this.mMapPoint.UserControl = true;

            //Configure l'application
            mMap = this.mMapPoint.ActiveMap;
            mRoute = mMap.ActiveRoute;

            mMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner;
        }