Пример #1
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;
        }
Пример #2
0
        // adds route
        private void btnAddRoute_Click(object sender, RoutedEventArgs e)
        {
            RoutingProvider rp = MainMap.MapProvider as RoutingProvider;
            if (rp == null)
            {
                rp = GMapProviders.GoogleMap; // use google 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);
            }
        }
Пример #3
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;
            }
        }
Пример #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);
            }
        }
Пример #6
0
        private static void OnBuildingDescriptionPropertyChanged(DependencyObject source,
            DependencyPropertyChangedEventArgs e)
        {
            SmartGMapControl smartGMapControl = source as SmartGMapControl;
              if (smartGMapControl != null)
              {
            if (smartGMapControl.MapProvider == null || smartGMapControl.MapProvider == GMapProviders.EmptyProvider)
            {
              smartGMapControl.MapProvider = smartGMapControl.GetMapProvider;//.OpenStreetMap;
              smartGMapControl.Manager.Mode = AccessMode.ServerAndCache;
              smartGMapControl.Position = new PointLatLng(51.3458053, 19.3458053);
            }
            if (smartGMapControl.MapProvider != null && smartGMapControl.MapProvider != GMapProviders.EmptyProvider)
            {
            GeoCoderStatusCode status = GeoCoderStatusCode.Unknow;

            PointLatLng? city = GMapProviders.GoogleMap.GetPoint(e.NewValue.ToString(), out status);
            if(city != null && status == GeoCoderStatusCode.G_GEO_SUCCESS)
            {
              RoutingProvider rp = smartGMapControl.MapProvider as RoutingProvider;
              if (rp == null)
              {
                rp = GMapProviders.GoogleMap; // use google if provider does not implement routing
              }

              PointLatLng start = new PointLatLng(51.3458053, 19.3458053);
              PointLatLng end = city.Value;
              MapRoute route = rp.GetRoute(start, end, false, false, (int)smartGMapControl.Zoom);
              if (route != null)
              {
                smartGMapControl.RouteDistance = route.Distance;
                GMapMarker m1 = new GMapMarker(start);
                m1.Shape = new CustomMarkerRed(smartGMapControl, m1, "Start: " + route.Name);
                m1.ZIndex = 10;

                GMapMarker m2 = new GMapMarker(end);
                m2.Shape = new CustomMarkerRed(smartGMapControl, m2, "End: " + start.ToString());
                m2.ZIndex = 10;

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

                  mRoute.ZIndex = 10;
                }

                smartGMapControl.Markers.Clear();
                smartGMapControl.Markers.Add(m1);
                smartGMapControl.Markers.Add(m2);
                smartGMapControl.Markers.Add(mRoute);

                //RectLatLng? rectLatLng = smartGMapControl.GetRectOfAllMarkers(null);
                //if (rectLatLng.HasValue)
                //{
                //  smartGMapControl.Position = new PointLatLng(rectLatLng.Value.Lat + rectLatLng.Value.HeightLat / 2,
                //                                              rectLatLng.Value.Lng + rectLatLng.Value.WidthLng / 2);
                //}
                //smartGMapControl.ZoomAndCenterMarkers(null);

              }

              //List<PointLatLng> rt = new List<PointLatLng>(); // is a List<PointLatLng>
              //rt.Add(new PointLatLng(51.3458053, 19.3458053));
              //rt.Add(city.Value);
              //MapRoute routes = new MapRoute(rt, "MyRoute");

              //if (routes != null)
              //{
              //  //GMapRoute r = new GMapRoute(routes.Points, routes.Name);
              //  //r.Stroke.Color = Color.Red;
              //  //routes.Routes.Add(r);

              //  GMapMarker it1 = new GMapMarker((PointLatLng)routes.From.Value);
              //  it1.Shape = new CustomMarkerRed(smartGMapControl, it1, "from");
              // // m1.ToolTipText = "From";
              //  GMapMarker it2 = new GMapMarker((PointLatLng)routes.To.Value);
              //  it2.Shape = new CustomMarkerRed(smartGMapControl, it2, "to");
              ////  m2.ToolTipText = "To";

              //  smartGMapControl.Markers.Add(it1);
              //  smartGMapControl.Markers.Add(it2);

              //  GMapRoute r = new GMapRoute(route.Points, "test");
              //  smartGMapControl.ZoomAndCenterMarkers(null);
              //}

              //GMapMarker it = new GMapMarker(city.Value);
              //{
              //  it.ZIndex = 55;
              //  it.Shape = new CustomMarkerRed(smartGMapControl, it, "Welcome to Lithuania! ;}");
              //}
              //smartGMapControl.Markers.Add(it);
              //smartGMapControl.ReloadMap();
            }
            }
              }
        }
Пример #7
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);
             }
        }