Пример #1
0
        public MapRoute(MapRoute Route)
        {
            if (Route != null)
            {
                FieldInfo[] myObjectFields = Route.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

                foreach (FieldInfo fi in myObjectFields)
                {
                    fi.SetValue(this, fi.GetValue(Route));
                }
            }
        }
Пример #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            GMap.NET.WindowsForms.Markers.GMarkerGoogle curPos = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(initialPoint, GMap.NET.WindowsForms.Markers.GMarkerGoogleType.blue_pushpin);
            path = GMap.NET.MapProviders.GoogleMapProvider.Instance.GetRoute(initialPoint, finalPoint, false, false, 15);
            GMapRoute route = new GMapRoute(path.Points, "My route");
            overlayRoute.Routes.Clear();
            overlayRoute.Routes.Add(route);
            areaMap.Overlays.Add(overlayRoute);
            label10.Text = (path.Distance * 1000).ToString();
            areaMap.Refresh();
            

        }
Пример #3
0
        public virtual void CalculateDistance()
        {
            if (TrackPoints.Count == 0)
            {
                Distance = null;
                return;
            }

            var points = TrackPoints.Select(p => new PointLatLng(p.Latitude, p.Longitude));

            Distance = new MapRoute(points, "").Distance;
        }
Пример #4
0
        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
            }
        }
Пример #5
0
        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);
            }
        }