Example #1
0
        // 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());

                GMapMarker mRoute = new GMapMarker(start);
                {
                    mRoute.Route.AddRange(route.Points);
                    mRoute.RegenerateRouteShape(MainMap);

                    mRoute.ZIndex = -1;
                }

                MainMap.Markers.Add(m1);
                MainMap.Markers.Add(m2);
                MainMap.Markers.Add(mRoute);

                MainMap.ZoomAndCenterMarkers(null);
            }
        }
Example #2
0
        // adds route
        private void button12_Click(object sender, RoutedEventArgs e)
        {
            MapRoute route = GMaps.Instance.GetRouteBetweenPoints(start, end, 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());

                GMapMarker mRoute = new GMapMarker(start);
                {
                    mRoute.Route.AddRange(route.Points);
                    mRoute.RegenerateRouteShape(MainMap);

                    mRoute.ZIndex = -1;
                }

                MainMap.Markers.Add(m1);
                MainMap.Markers.Add(m2);
                MainMap.Markers.Add(mRoute);
            }
        }
Example #3
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);
            }
        }
Example #4
0
        public void AddPolyline(List <PointLatLng> CoordinatesList, PointLatLng Position, Brush Color)
        {
            GMapMarker m = new GMapMarker(Position);

            //m.Route.AddRange(CoordinatesList);
            foreach (PointLatLng p in CoordinatesList)
            {
                m.Route.Add(p);
                m.RegenerateRouteShape(MainMap);
            }
            //m.RegenerateRouteShape(MainMap);

            (m.Shape as System.Windows.Shapes.Path).Fill   = Color;
            (m.Shape as System.Windows.Shapes.Path).Stroke = Color;
            MainMap.Markers.Add(m);
            SelectedMarker = m;
        }
Example #5
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
            }
        }
Example #6
0
        private void PostureAnalyzerOnPostureDetected(object sender, PostureEventArgs args)
        {
            switch (args.Posture)
            {
            case PosturesEnum.LeftHello:
            {
                PointLatLng pos;
                if (Marker != null)
                {
                    pos = new PointLatLng(Marker.Position.Lat, Marker.Position.Lng);
                }
                else
                {
                    pos = new PointLatLng(GMapControl.Position.Lat, GMapControl.Position.Lng);
                }

                GMapMarker flag = new GMapMarker(new PointLatLng())
                {
                    Position = pos,
                    ZIndex   = int.MaxValue
                };
                flag.Shape = new CustomMarkerDemo(flag, "FLAG");
                GMapControl.Markers.Add(flag);
            }
            break;

            case PosturesEnum.RightHandOverHead:
            {
                Configuration.maxHandLength      = 0.4;
                Configuration.activeHandDistance = 0.25;
                LogString.Log("Restoring defaults");
            }
            break;

            case PosturesEnum.LeftHandOverHead:
            {
                LogString.Log("LeftOverHead");
                if (GMapControl.Markers.Any())
                {
                    var marker = GMapControl.Markers.Last();
                    marker.Shape = null;
                    GMapControl.Markers.Remove(marker);
                }
            }
            break;


            case PosturesEnum.HandsJoined:
            {
                CursorMarkerExists = false;
                if (Marker != null)
                {
                    GMapControl.Markers.Remove(Marker);
                    Marker = null;
                    //LogString.Log(Marker.ToString());
                }


                if (GMapControl.Markers.Count == 0)
                {
                    return;
                }
                var mRoute = new GMapMarker(GMapControl.Markers[0].Position);
                {
                    mRoute.Route.AddRange(GMapControl.Markers.Select(a => new PointLatLng(a.Position.Lat - 100, a.Position.Lng)));
                    var gMapControl = GMapControl.Markers[0].Map;
                    mRoute.RegenerateRouteShape(gMapControl);
                    mRoute.ZIndex = -1;
                }
                GMapControl.Markers.Add(mRoute);
            }
            break;
            }
        }