${core_PredefineFillStyle_Title}
${core_PredefineFillStyle_Description}
async private void PathAnalyst_Click(object sender, RoutedEventArgs e) { if (points.Count == 0) { await MessageBox.Show("请指定服务点"); return; } if (string.IsNullOrEmpty(MyTextBox.Text)) { await MessageBox.Show("请填写服务半径"); return; } double radius; if (double.TryParse(MyTextBox.Text, out radius)) { if (radius <= 0) { await MessageBox.Show("服务半径必须大于0"); return; } } else { await MessageBox.Show("服务半径必须为数值"); return; } //listweights用来添加服务半径,list记录点,点与半径一一对应 //每次新添加的点用新添加的服务半径进行分析,以前的几个点的服务半径不变 List<double> listweights = new List<double>(); List<Point2D> list = new List<Point2D>(); for(int count=i;count<points.Count;count++) { list.Add(points[count]); listweights.Add(radius); } //记录点的个数,下次分析从此点开始进行分析,之前的点仍用原服务半径 i=points.Count; //定义 Point2D 类型的参数 FindServiceAreasParameters<Point2D> paramPoint2D = new FindServiceAreasParameters<Point2D> { Centers = list, Weights = listweights, Parameter = new TransportationAnalystParameter { ResultSetting = new TransportationAnalystResultSetting { ReturnEdgeFeatures = true, ReturnEdgeGeometry = true, ReturnEdgeIDs = true, ReturnPathGuides = true, ReturnRoutes = true, }, WeightFieldName = "length", TurnWeightField = "TurnCost", } }; //与服务器交互 try { FindServiceAreasService findServiceAreaService = new FindServiceAreasService("http://support.supermap.com.cn:8090/iserver/services/components-rest/rest/networkanalyst/RoadNet@Changchun"); var result = await findServiceAreaService.ProcessAsync(paramPoint2D); foreach (SuperMap.WinRT.REST.NetworkAnalyst.ServiceArea p in result.ServiceAreaList) { //将要素添加到图层 PredefinedFillStyle style = new PredefinedFillStyle(); style.Fill = new SolidColorBrush(Color.FromArgb(120, 179, 235, 246)); Feature area = new Feature(); area.Geometry = p.ServiceRegion; area.Style = style; featuresLayer.AddFeature(area); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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 }