${core_PredefineFillStyle_Title}
${core_PredefineFillStyle_Description}
private void findServiceAreaService_ProcessCompleted(object sender, FindServiceAreasEventArgs e) { if (e.Result != null && e.Result.ServiceAreaList != null) { foreach (SuperMap.Web.iServerJava6R.NetworkAnalyst.ServiceArea p in e.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); } } }
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.Web.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 }
//查询成功高亮显示选中地物,并显示相关属性信息 private void query_ProcessCompleted(object sender, QueryEventArgs e) { //点击处没有地物的情况 if (e.ResultSet == null) { MessageBox.Show("查询结果为空!"); dgVegetable.Visibility = Visibility.Collapsed; return; } //点击处存在地物时,用蓝色边显示该地物 PredefinedFillStyle selectStyle = new PredefinedFillStyle(); selectStyle.Stroke = new SolidColorBrush(Colors.Blue); FeatureCollection fc = e.ResultSet.RecordSets[0].ToFeatureSet(); Feature f = new Feature { Geometry = fc[0].Geometry, Style = selectStyle }; drawLayer.Features.Add(f); //记录地物ID号,为设置GetEntityParameters做准备 entityID = e.ResultSet.RecordSets[0].Records[0].Shape.Id; GetEntityParameters parameters = new GetEntityParameters { ID = entityID, MapName = "Changchun", LayerName = "Vegetable@changchun" }; GetEntityService getEntityService = new GetEntityService("http://localhost:7080/demo"); getEntityService.ProcessAsync(parameters); getEntityService.ProcessCompleted += new EventHandler<GetEntityEventArgs>(getEntityService_ProcessCompleted); }
private void selectQuery_ProcessCompleted(object sender, QueryEventArgs e) { //点击处没有地物的情况 if (e.ResultSet == null) { MessageBox.Show("查询结果为空!"); // dgVegetable.Visibility = Visibility.Collapsed; return; } //点击处存在地物时,用蓝色边显示该地物 PredefinedFillStyle selectStyle = new PredefinedFillStyle(); selectStyle.Stroke = new SolidColorBrush(Colors.Blue); FeatureCollection fc = e.ResultSet.RecordSets[0].ToFeatureSet(); Feature f = new Feature { Geometry = fc[0].Geometry, Style = selectStyle }; drawLayer.Features.Add(f); //记录所选地物的id号,为删除地物准备 ids.Add(e.ResultSet.RecordSets[0].Records[0].Shape.Id); //记录所选地物的几何形状,为合并地物准备 unionGeometry.Add(e.ResultSet.RecordSets[0].Records[0].Shape); }
//绘制多边形结束后将所绘制的多边形转化为矢量要素并加载到矢量要素图层中,在加载前先设置该要素样式 private void region_DrawCompleted(object sender, DrawEventArgs e) { Feature feature = new Feature(); //设置预定义样式 PredefinedFillStyle style = new PredefinedFillStyle(); style.Stroke = new SolidColorBrush(Colors.Orange); style.StrokeThickness = 1; style.Fill = new SolidColorBrush(Colors.Green); //将绘制的多边形转化为具有预定义样式的面要素 feature.Style = style; feature.Geometry = e.Geometry as GeoRegion; //将面要素加载到矢量要素图层中 this.featuresLayer.Features.Add(feature); }