コード例 #1
0
        //private LocationCollection mulitLoc(LocationCollection locvol)
        //{

        //    LocationCollection templc1=locvol;

        //    int count = locvol.Count;
        //    for (int i = 0; i < count-1; i++)
        //    {
        //        if (0 < i && i < count-6)
        //        {
        //            double x = (templc1.ElementAt(i + 1).Longitude - templc1.ElementAt(i).Longitude) / 5;
        //            double y = (templc1.ElementAt(i + 1).Latitude - templc1.ElementAt(i).Latitude) / 5;
        //            if (Math.Abs(x)>0.00001||Math.Abs(y)>0.00001)
        //            {
        //                for (int m = 1; m < 5; m++)
        //                {
        //                    Location loc = new Location();
        //                    loc.Latitude = templc1.ElementAt(i).Latitude + m * y;
        //                    loc.Longitude = templc1.ElementAt(i).Longitude + m * x;
        //                    if ((i + (i-1) * 4 )<locvol.Count-1)
        //                    {
        //                        locvol.Insert(i + (i - 1) * 4, loc);
        //                    }

        //                }
        //            }

        //        }


        //    }



        //    return locvol;
        //}
        //定时去获取路径
        private void Dtimer_Completed(object sender, EventArgs e)
        {
            //if (cbxCar.IsChecked == true)
            //{
            CustomPushpin cp = GetCarByMSID("car", carml);

            if (cp != null)
            {
                GetBegionRoad(cp.Location.Latitude, cp.Location.Longitude, 100);
                isgetloc = true;
                timer.Stop();
            }
            //}
            //else
            //{
            //    DraggablePushpin dp = GetDCarByMSID("drapcar", carml);
            //    if (dp != null)
            //    {
            //        GetBeginPoint(dp.Location.Latitude, dp.Location.Longitude, 100);
            //    }
            //}
            //if (isrealroadupdated==true)
            //{
            Dtimer.Begin();
            //}
        }
コード例 #2
0
        private void InitCar()
        {
            double CarSize      = 50;
            string strImagePath = "/BaseMap;component/image/vehicle.png";
            //string strImagePath = "http://soulsolutions.com.au/Images/pin.png";
            var iconSpec3 = new CustomIconSpecification()
            {
                IconUri    = new Uri(strImagePath, UriKind.RelativeOrAbsolute),
                Width      = CarSize,
                Height     = CarSize,
                IconOffset = new System.Windows.Point(-CarSize / 2, -CarSize / 2),//getIconOffset(iRotateTr),
                //TextContent = ClientStatic.GetIconLblText(initData.CarNo),
                TextOffet = new System.Windows.Point(-15, -46),
                //FontSize = ClientStatic.LableFontSize,
                //TextColor = ClientStatic.CarIconLblColorSCB,
                RotateTr = 0
            };
            var pin = new CustomPushpin
            {
                IconSpecification = iconSpec3,
                Location          = new Location(31.6, 120.3),
                MapInstance       = ctlMap,
                Name = "car",
            };

            carml.AddChild(pin);

            var dp = new DraggablePushpin {
                Location = new Location(31.6, 120.3), Name = "drapcar"
            };

            carml.AddChild(dp, dp.Location);
        }
コード例 #3
0
        //定时移动小车
        private void timer_Completed(object sender, EventArgs e)
        {
            //carml.Children.Add(carph);

            CustomPushpin cp = GetCarByMSID("car", carml);

            if (carloc.Count > 0)
            {
                Location lc = carloc.ElementAt(cari);
                if (lc != null)
                {
                    MapLayer.SetPosition(cp, lc);
                    cp.Location = lc;

                    //double CarSize = 50;
                    //string strImagePath = "/BaseMap;component/image/vehicle.png";
                    //var icon = new CustomIconSpecification()
                    //{

                    //    IconUri = new Uri(strImagePath, UriKind.RelativeOrAbsolute),
                    //    Width = CarSize,
                    //    Height = CarSize,
                    //    IconOffset = new System.Windows.Point(-CarSize / 2, -CarSize / 2),//getIconOffset(iRotateTr),

                    //    TextOffet = new System.Windows.Point(-15, -46),

                    //    RotateTr = 60
                    //};


                    //cp.IconSpecification = icon;
                }
            }

            if (isgetloc == false)
            {
                timer.Begin();
            }


            if (cari < carloc.Count - 1)
            {
                cari++;
            }
        }
コード例 #4
0
        private void InitCar()
        {
            double CarSize = 50;
            string strImagePath = "/BaseMap;component/image/vehicle.png";
            //string strImagePath = "http://soulsolutions.com.au/Images/pin.png";
            var iconSpec3 = new CustomIconSpecification()
            {

                IconUri = new Uri(strImagePath, UriKind.RelativeOrAbsolute),
                Width = CarSize,
                Height = CarSize,
                IconOffset = new System.Windows.Point(-CarSize / 2, -CarSize / 2),//getIconOffset(iRotateTr),
                //TextContent = ClientStatic.GetIconLblText(initData.CarNo),
                TextOffet = new System.Windows.Point(-15, -46),
                //FontSize = ClientStatic.LableFontSize,
                //TextColor = ClientStatic.CarIconLblColorSCB,
                RotateTr = 0
            };
            var pin = new CustomPushpin
                          {
                              IconSpecification = iconSpec3,
                              Location = new Location(31.6, 120.3),
                              MapInstance = ctlMap,
                              Name = "car",
                          };
            carml.AddChild(pin);

            var dp = new DraggablePushpin {Location = new Location(31.6, 120.3), Name = "drapcar"};
            carml.AddChild(dp, dp.Location);
        }
コード例 #5
0
        void rsc_GetRoutingCompleted(object sender, GetRoutingCompletedEventArgs e)
        {
            carloc.Clear();
            cari = 0;
            MapLayer layer = (MapLayer)this.ctlMap.FindName("routing");

            layer.Children.Clear();
            var builder = new StringBuilder();

            if (e.Error == null)
            {
                Color color = Colors.Blue;
                for (int i = 0; i < e.Result.Count; i++)
                {
                    string[] strArray = e.Result[i].Split(new char[] { ';' });


                    builder.Length = 0;
                    int index = 2;
                    while (index < (strArray.Length - 1))
                    {
                        builder.Append(strArray[index] + ": ");
                        index++;
                    }
                    string[] strArray2      = strArray[strArray.Length - 1].Split(new char[] { ',' });
                    string[] strArrayPoints = strArray[strArray.Length - 2].Split(new char[] { ',' });
                    if ((strArray2.Length == 1) && (strArray2[0].Length > 1))
                    {
                        //Ellipse dependencyObject = new Ellipse();
                        //dependencyObject.Width=10.0;
                        //dependencyObject.Height=(10.0);
                        //dependencyObject.Fill=(new SolidColorBrush(color));
                        //dependencyObject.Opacity=(0.65);
                        //Location location = new Location(double.Parse(strArray2[0].Split(new char[] { ' ' })[0]), double.Parse(strArray2[0].Split(new char[] { ' ' })[1]));
                        //MapLayer.SetPosition(dependencyObject, location);
                        //ToolTipService.SetToolTip(dependencyObject, builder.ToString());
                        //layer.Children.Add(dependencyObject);
                    }
                    else
                    {
                        LocationCollection locations;
                        Location           location2;
                        Location           locPoint;
                        if (strArray2[0].Equals(strArray2[strArray2.Length - 1]))
                        {
                            var polygon = new MapPolygon
                            {
                                Stroke          = new SolidColorBrush(color),
                                StrokeThickness = 2.0,
                                Fill            = new SolidColorBrush(color),
                                Opacity         = 0.75
                            };
                            locations = new LocationCollection();
                            index     = 0;
                            while (index < strArray2.Length)
                            {
                                if (strArray2[index].IndexOf(" ") != -1)
                                {
                                    location2 = new Location(double.Parse(strArray2[index].Split(new char[] { ' ' })[0]), double.Parse(strArray2[index].Split(new char[] { ' ' })[1]));
                                    locations.Add(location2);
                                }
                                index++;
                            }
                            polygon.Locations = locations;
                            ToolTipService.SetToolTip(polygon, builder.ToString());
                            layer.Children.Add(polygon);
                        }
                        else
                        {
                            var polyline = new MapPolyline {
                                Stroke = new SolidColorBrush(color), StrokeThickness = 6.0
                            };
                            var doubles = new DoubleCollection {
                                3.0, 3.0
                            };
                            polyline.StrokeDashArray = doubles;
                            locations = new LocationCollection();

                            for (index = strArray2.Length - 1; index >= 0; index--)
                            {
                                location2 = new Location(double.Parse(strArray2[index].Split(new char[] { ' ' })[0]), double.Parse(strArray2[index].Split(new char[] { ' ' })[1]));

                                locations.Add(location2);
                                if (i == 0)
                                {
                                    carloc.Add(location2);
                                }
                            }



                            //添加坐标到小车轨迹
                            if (i > 0)
                            {
                                Location loc1 = new Location(double.Parse(strArrayPoints[0].Split(new char[] { ' ' })[0]), double.Parse(strArrayPoints[0].Split(new char[] { ' ' })[1]));
                                Location loc2 = new Location(double.Parse(strArrayPoints[strArrayPoints.Length - 1].Split(new char[] { ' ' })[0]), double.Parse(strArrayPoints[strArrayPoints.Length - 1].Split(new char[] { ' ' })[1]));
                                if (IsCloset(carloc.ElementAt(carloc.Count - 1), loc1, loc2))
                                {
                                    for (index = strArrayPoints.Length - 1; index >= 0; index--)
                                    {
                                        var tmoloc1 = new Location(double.Parse(strArrayPoints[index].Split(new char[] { ' ' })[0]), double.Parse(strArrayPoints[index].Split(new char[] { ' ' })[1]));

                                        carloc.Add(tmoloc1);
                                    }
                                }
                                else
                                {
                                    for (index = 0; index < strArrayPoints.Length - 1; index++)
                                    {
                                        var tmoloc = new Location(double.Parse(strArrayPoints[index].Split(new char[] { ' ' })[0]), double.Parse(strArrayPoints[index].Split(new char[] { ' ' })[1]));
                                        carloc.Add(tmoloc);
                                    }
                                }
                            }



                            polyline.Locations = locations;
                            ToolTipService.SetToolTip(polyline, builder.ToString());

                            layer.Children.Add(polyline);
                        }
                    }
                }
            }



            CustomPushpin otmpcp = GetCarByMSID("car", carml);

            for (int i = 0; i < carloc.Count; i++)
            {
                var item = carloc.ElementAt(i);
                if (item.Latitude == otmpcp.Location.Latitude && item.Longitude == otmpcp.Location.Longitude)
                {
                    for (int y = 0; y < i + 1; y++)
                    {
                        if (carloc.Count > y + 1)
                        {
                            carloc.RemoveAt(y);
                        }
                    }
                }
            }
            carloc.RemoveAt(0);
            isgetloc = false;

            timer.Begin();
            //RouteLoadingPanel.Stop();
        }