${core_PredefineLineStyle_Title}

${core_PredefineLineStyle_Description}

Inheritance: LineStyle
Example #1
0
 private void SetDefaultStyle( )
 {
     HoverVertexStyle = new PredefinedMarkerStyle() { Size = 10 , Symbol = PredefinedMarkerStyle.MarkerSymbol.Square , Color = new SolidColorBrush(Colors.Green) };
     SnapStyle = new PredefinedMarkerStyle() { Size = 12 , Symbol = PredefinedMarkerStyle.MarkerSymbol.Circle , Color = new SolidColorBrush(Colors.LightGray) };
     HoverCenterStyle = new PredefinedMarkerStyle() { Size = 20 , Symbol = PredefinedMarkerStyle.MarkerSymbol.Star , Color = new SolidColorBrush(Colors.Red) };
     hoverLineStyle = new PredefinedLineStyle() { Stroke = new SolidColorBrush(Colors.Transparent) , StrokeThickness = 10 };//Colors.Transparent
 }
        private void line_DrawCompleted(object sender, DrawEventArgs e)
        {
            if (e.Geometry == null)
            {
                return;
            }

            //将线标绘在客户端要素图层
            PredefinedLineStyle lineStyle = new PredefinedLineStyle { Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 3 };
            Feature feature = new Feature
            {
                Geometry = e.Geometry,
                Style = lineStyle
            };
            featuresLayer.Features.Add(feature);

            Measure(e.Geometry);
        }
Example #3
0
 /// <summary>${ui_action_Edit_constructor_D}</summary>
 /// <param name="map">${ui_action_Edit_constructor_param_map}</param>
 /// <param name="layer">${ui_action_Edit_constructor_param_layer}</param>
 public Edit(Map map , FeaturesLayer layer)
 {
     if (map != null && layer != null)
     {
         Name = "Edit";
         Map = map;
         editLayer = layer;
         editLayer.PointerPressed += editLayer_PointerPressed;
         editLayer.PointerReleased += editLayer_PointerReleased;
         if (map.Theme == null)
         {
             SetDefaultStyle();
         }
         else
         {
             HoverVertexStyle = map.Theme.HoverVertexStyle;
             SnapStyle = map.Theme.SnapStyle;
             HoverCenterStyle = map.Theme.HoverCenterStyle;
             hoverLineStyle = new PredefinedLineStyle() { Stroke = new SolidColorBrush(Colors.Transparent) , StrokeThickness = 10 };//Colors.Transparent
         }
     }
 }
        private void MyMap_Loaded(object sender, RoutedEventArgs e)
        {
            #region 使用预定义点符号
            Feature featurePoint = new Feature();
            GeoPoint point = new GeoPoint();
            point.X = 116.2;
            point.Y = 39.6;
            PredefinedMarkerStyle simpleMarkerStyle = new PredefinedMarkerStyle();
            simpleMarkerStyle.Color = new SolidColorBrush(Colors.Red);
            simpleMarkerStyle.Size = 20;
            simpleMarkerStyle.Symbol = SuperMap.WinRT.Core.PredefinedMarkerStyle.MarkerSymbol.Star;
            featurePoint.Style = simpleMarkerStyle;
            featurePoint.Geometry = point;
            featuresLayer.Features.Add(featurePoint);
            #endregion

            #region 使用预定义线符号
            Feature featureLine = new Feature();
            Point2DCollection points = new Point2DCollection();
            points.Add(new Point2D(116.2, 39.6));
            points.Add(new Point2D(90, 50));
            points.Add(new Point2D(50, 25));
            points.Add(new Point2D(-80, 45));
            points.Add(new Point2D(-100, 38));
            ObservableCollection<Point2DCollection> path = new ObservableCollection<Point2DCollection>();
            path.Add(points);
            GeoLine geoLine = new GeoLine();
            geoLine.Parts = path;

            PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle();
            simpleLineStyle.Stroke = new SolidColorBrush(Colors.Black);
            simpleLineStyle.StrokeThickness = 1;
            simpleLineStyle.StrokeDashArray = new DoubleCollection { 3, 1 };

            featureLine.Geometry = geoLine;
            featureLine.Style = simpleLineStyle;
            featuresLayer.Features.Add(featureLine);
            #endregion

            #region 使用预定义面符号
            Feature featureRegion = new Feature();
            Point2DCollection pointsRegion = new Point2DCollection();
            pointsRegion.Add(new Point2D(-8, 61));
            pointsRegion.Add(new Point2D(-6, 55));
            pointsRegion.Add(new Point2D(-8, 50));
            pointsRegion.Add(new Point2D(2, 50));
            pointsRegion.Add(new Point2D(1, 61));
            pointsRegion.Add(new Point2D(-8, 61));
            ObservableCollection<Point2DCollection> pRegion = new ObservableCollection<Point2DCollection>();
            pRegion.Add(pointsRegion);
            GeoRegion geoRegion = new GeoRegion();
            geoRegion.Parts = pRegion;

            PredefinedFillStyle simpleFillStyle = new PredefinedFillStyle();
            simpleFillStyle.StrokeThickness = 1;
            simpleFillStyle.Stroke = new SolidColorBrush(Colors.Black);
            simpleFillStyle.Fill = new SolidColorBrush(Colors.Yellow);

            featureRegion.Geometry = geoRegion;
            featureRegion.Style = simpleFillStyle;
            featuresLayer.Features.Add(featureRegion);
            #endregion

            #region 添加文本
            Feature featureText = new Feature();
            GeoPoint text = new GeoPoint();
            text.X = 5;
            text.Y = 10;

            TextStyle textStyle = new TextStyle();
            textStyle.Text = "Africa";
            textStyle.FontSize = 40;
            textStyle.Foreground = new SolidColorBrush(Colors.Blue);

            featureText.Geometry = text;
            featureText.Style = textStyle;
            featuresLayer.Features.Add(featureText);
            #endregion
        }
        //最佳路径分析
        async private void PathAnalyst_Click(object sender, RoutedEventArgs e)
        {
            if (points.Count < 2)
            {
                await MessageBox.Show("请指定途经点");
                return;
            }

            if (featuresLayer.Features.Count > 0)
            {
                featuresLayer.Features.Clear();
            }
            //定义 Point2D 类型的参数
            FindPathParameters<Point2D> paramPoint2D = new FindPathParameters<Point2D>
            {
                Nodes = points,
                HasLeastEdgeCount = true,
                Parameter = new TransportationAnalystParameter
                {
                    ResultSetting = new TransportationAnalystResultSetting
                    {
                        ReturnEdgeFeatures = true,
                        ReturnEdgeGeometry = true,
                        ReturnEdgeIDs = true,
                        ReturnNodeFeatures = true,
                        ReturnNodeGeometry = true,
                        ReturnNodeIDs = true,
                        ReturnPathGuides = true,
                        ReturnRoutes = true
                    },
                    WeightFieldName = "length",
                    TurnWeightField = "TurnCost",
                    BarrierPoints = barrierPoints,
                }
            };

            //与服务器交互
            try
            {
                FindPathService findPathService = new FindPathService(url);
                var result = await findPathService.ProcessAsync(paramPoint2D);

                //路径样式
                PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle();
                simpleLineStyle.Stroke = new SolidColorBrush(Colors.Blue);
                simpleLineStyle.StrokeThickness = 2;
                //服务器返回结果,将最佳路径显示在客户端
                if (result != null)
                {
                    if (result.PathList != null)
                    {
                        foreach (ServerPath p in result.PathList)
                        {
                            //将要素添加到图层
                            featuresLayer.Features.Add(new Feature { Geometry = p.Route.Line, Style = simpleLineStyle });
                            this.length.Text = "路线长度:" + p.Route.Length.ToString();
                            this.cost.Text = "花费:" + p.Weight.ToString();
                        }
                        resultPanel.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        await MessageBox.Show("此设置下无可用路径");
                    }
                }

            }
            //服务器计算失败提示失败信息
            catch(Exception ex) 
            {
                MessageBox.Show(ex.Message);
            }
        }
        async private void PathAnalyst_Click(object sender, RoutedEventArgs e)
        {
            if (points.Count == 0)
            {
                await MessageBox.Show("请指定途经点");
                return;
            }

            FindTSPPathsParameters<Point2D> paramPoint2D = new FindTSPPathsParameters<Point2D>
            {
                EndNodeAssigned = (bool)terminal.IsChecked,
                Nodes = points,
                Parameter = new TransportationAnalystParameter
                {
                    TurnWeightField = "TurnCost",
                    WeightFieldName = "length",
                    ResultSetting = new TransportationAnalystResultSetting
                    {
                        ReturnEdgeFeatures = true,
                        ReturnEdgeGeometry = true,
                        ReturnEdgeIDs = true,
                        ReturnNodeFeatures = true,
                        ReturnNodeGeometry = true,
                        ReturnNodeIDs = true,
                        ReturnPathGuides = true,
                        ReturnRoutes = true,
                    }
                },
            };
            //与服务器交互
            try
            {
                FindTSPPathsService findTSPPathsService = new FindTSPPathsService(url);
                var result = await findTSPPathsService.ProcessAsync(paramPoint2D);

                //路径样式
                PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle();
                simpleLineStyle.Stroke = new SolidColorBrush(Colors.Blue);
                simpleLineStyle.StrokeThickness = 2;

                if (result != null && result.TSPPathList != null)
                {
                    foreach (ServerPath p in result.TSPPathList)
                    {
                        //将要素添加到图层上
                        featuresLayer.Features.Add(new Feature { Geometry = p.Route.Line, Style = simpleLineStyle });
                    }
                }
            }
            //服务器计算失败提示失败信息
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private static Style generateDefaultSyle(Feature f)
 {
     if (f.Geometry is GeoPoint)
     {
         Style pmstyle = null;
         if (f.Layer.Map.Theme == null)
         {
             pmstyle = new PredefinedMarkerStyle() { Color = new SolidColorBrush(Colors.Red), Size = 10 };
         }
         else
         {
             pmstyle = new PredefinedMarkerStyle() { Color = f.Layer.Map.Theme.Color, Size = f.Layer.Map.Theme.Size };
         }
         return pmstyle;
     }
     else if (f.Geometry is GeoLine)
     {
         Style plstyle = null;
         if (f.Layer.Map.Theme == null)
         {
             plstyle = new PredefinedLineStyle() { Stroke = new SolidColorBrush(Color.FromArgb(99, 255, 0, 0)), StrokeThickness = 2 };
         }
         else
         {
             plstyle = new PredefinedLineStyle() { Stroke = f.Layer.Map.Theme.Stroke, StrokeThickness = f.Layer.Map.Theme.StrokeThickness };
         }
         return plstyle;
     }
     else
     {
         Style pfstyle = null;
         if (f.Layer.Map.Theme == null)
         {
             pfstyle = new FillStyle() { Fill = new SolidColorBrush(Color.FromArgb(99, 255, 0, 0)) };
         }
         else
         {
             pfstyle = new FillStyle() { Fill = f.Layer.Map.Theme.Fill, Stroke = f.Layer.Map.Theme.Stroke };
         }
         return pfstyle;
     }
 }
        async private void PathAnalyst_Click(object sender, RoutedEventArgs e)
        {
            if (points.Count == 0)
            {
                await MessageBox.Show("请选择配送目标");
                return;
            }

            FindMTSPPathsParameters<Point2D> paramPoint2D = new FindMTSPPathsParameters<Point2D>
            {
                HasLeastTotalCost = false,

                //已选定的中心站点
                Centers = new List<Point2D> { new Point2D(4100, -4100), new Point2D(4500, -3000), new Point2D(5000, -3500) },
                Nodes = points,
                Parameter = new TransportationAnalystParameter
                {
                    BarrierEdgeIDs = null,
                    BarrierNodeIDs = null,
                    TurnWeightField = "TurnCost",
                    WeightFieldName = "length",
                    ResultSetting = new TransportationAnalystResultSetting
                    {
                        ReturnEdgeFeatures = true,
                        ReturnEdgeGeometry = true,
                        ReturnEdgeIDs = true,
                        ReturnNodeFeatures = true,
                        ReturnNodeGeometry = true,
                        ReturnNodeIDs = true,
                        ReturnPathGuides = true,
                        ReturnRoutes = true
                    }
                }
            };

            //与服务器交互
            try
            {
                FindMTSPPathsService findMTSPPathsService = new FindMTSPPathsService(url);
                var result = await findMTSPPathsService.ProcessAsync(paramPoint2D);
                //路径样式
                PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle();
                simpleLineStyle.Stroke = new SolidColorBrush(Colors.Blue);
                simpleLineStyle.StrokeThickness = 2;

                if (result != null && result.MTSPathList != null)
                {
                    foreach (ServerPath p in result.MTSPathList)
                    {
                        //将要素添加到图层上
                        featuresLayer.Features.Add(new Feature { Geometry = p.Route.Line, Style = simpleLineStyle });
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }         
        //最近设施查找
        async private void FindClosetFacility_Click(object sender, RoutedEventArgs e)
        {
            if (featuresLayer.Features.Count > 0)
            {
                featuresLayer.Features.Clear();
            }

            if (Point2D.IsNullOrEmpty(eventp))
            {
                await MessageBox.Show("请指定事件点");
                return;
            }

            if (points.Count == 0)
            {
               await  MessageBox.Show("请指设施点");
                return;
            }

            FindClosestFacilitiesParameters<Point2D> paramPoint2D = new FindClosestFacilitiesParameters<Point2D>
            {
                Event = eventp,
                Facilities = points,
                FromEvent = true,
                MaxWeight = 0,
                ExpectFacilityCount = 1,
                Parameter = new TransportationAnalystParameter
                {
                    ResultSetting = new TransportationAnalystResultSetting
                    {
                        ReturnEdgeFeatures = true,
                        ReturnEdgeGeometry = true,
                        ReturnEdgeIDs = true,
                        ReturnNodeFeatures = true,
                        ReturnNodeGeometry = true,
                        ReturnNodeIDs = true,
                        ReturnPathGuides = true,
                        ReturnRoutes = true
                    },
                    WeightFieldName = "length",
                    TurnWeightField = "TurnCost"
                }
            };
            try
            {
                FindClosestFacilitiesService findclosestFacilitiesService = new FindClosestFacilitiesService(url);
                var result = await findclosestFacilitiesService.ProcessAsync(paramPoint2D);
                //路径样式
                PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle();
                simpleLineStyle.Stroke = new SolidColorBrush(Colors.Blue);
                simpleLineStyle.StrokeThickness = 2;

                if (result != null && result.FacilityPathList != null)
                {
                    foreach (ServerPath path in result.FacilityPathList)
                    {
                        featuresLayer.Features.Add(new Feature { Geometry = path.Route.Line, Style = simpleLineStyle });
                    }
                }
                else { await MessageBox.Show("查询结果为空"); }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }