${core_PredefineLineStyle_Title}
${core_PredefineLineStyle_Description}
//服务器返回结果,将最佳路径显示在客户端 private void findPathService_ProcessCompleted(object sender, FindPathEventArgs e) { //路径样式 PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle(); simpleLineStyle.Stroke = new SolidColorBrush(Colors.Blue); simpleLineStyle.StrokeThickness = 2; if (e.Result != null) { if (e.Result.PathList != null) { foreach (ServerPath p in e.Result.PathList) { //将要素添加到图层 featuresLayer.Features.Add(new Feature { Geometry = p.Route, Style = simpleLineStyle }); this.length.Text = "路线长度:" + p.Route.Length.ToString(System.Globalization.CultureInfo.InvariantCulture); this.cost.Text = "花费:" + p.Weight.ToString(System.Globalization.CultureInfo.InvariantCulture); } resultPanel.Visibility = Visibility.Visible; } else { MessageBox.Show("此设置下无可用路径"); } } }
void ser_ProcessCompleted(object sender, GetFeaturesEventArgs e) { _routeLayer.Features.Clear(); foreach (var f in e.Result.Features) { PredefinedLineStyle style = new PredefinedLineStyle(); style.StrokeThickness = 5; style.Stroke = new SolidColorBrush(Colors.Red); style.Symbol = PredefinedLineStyle.LineSymbol.Dash; f.Style = style; _routeLayer.AddFeature(f); } }
private void findclosestFacilitiesService_ProcessCompleted(object sender, FindClosestFacilitiesEventArgs e) { //路径样式 PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle(); simpleLineStyle.Stroke = new SolidColorBrush(Colors.Blue); simpleLineStyle.StrokeThickness = 2; if (e.Result != null && e.Result.FacilityPathList != null) { foreach (ServerPath path in e.Result.FacilityPathList) { featuresLayer.Features.Add(new Feature { Geometry = path.Route, Style = simpleLineStyle }); } } }
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); }
//距离量算 private void line_DrawCompleted(object sender, DrawEventArgs e) { //将线标绘在客户端要素图层 PredefinedLineStyle lineStyle = new PredefinedLineStyle { Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 3 }; Feature feature = new Feature { Geometry = e.Geometry, Style = lineStyle }; featuresLayer.Features.Add(feature); MeasureParameters parameters = new MeasureParameters { Geometry = e.Geometry, MapName = "changchun" }; MeasureService measureDistance = new MeasureService("http://localhost/IS/AjaxDemo"); measureDistance.ProcessAsync(parameters); measureDistance.ProcessCompleted += new EventHandler<MeasureEventArgs>(measureDistance_ProcessCompleted); measureDistance.Failed += new EventHandler<ServiceFailedEventArgs>(measure_Failed); }
private Point2D startPoint = Point2D.Empty; //用于移动整个线-面要素 #endregion Fields #region Constructors /// <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.MouseLeftButtonDown += editLayer_MouseLeftButtonDown; editLayer.MouseLeftButtonUp += editLayer_MouseLeftButtonUp; 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.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 }
void service_ProcessCompleted(object sender, RouteLocatorEventArgs e) { if (e.Result.ResultGeometry is GeoLine) { Feature f = new Feature(); PredefinedLineStyle style = new PredefinedLineStyle(); style.Symbol = PredefinedLineStyle.LineSymbol.Solid; style.Stroke = new SolidColorBrush(Colors.Blue); style.StrokeThickness = 5; f.Geometry = e.Result.ResultGeometry; f.Style = style; _routeLayer.AddFeature(f); } }
void drawFreeHand_DrawComplete(object sender, DrawEventArgs e) { //this.arbitraryLayer.Children.Add(e.Element as PolylineBase); PredefinedLineStyle lineStyle = new PredefinedLineStyle(); lineStyle.Stroke = new SolidColorBrush(Colors.Red); lineStyle.StrokeThickness = 5; lineStyle.Symbol = SuperMap.Web.Core.PredefinedLineStyle.LineSymbol.Dash; Feature feature = new Feature() { Geometry = e.Geometry as GeoLine, Style = lineStyle }; this.featuresLayer.Features.Add(feature);//ok }
//public FeatureElement(Feature f, IRenderer renderer, bool _ignoreMouseEvent) //{ // this.ClipBox = Rectangle2D.Empty; // this.pathIsInvalid = true; // if (f == null) // { // throw new ArgumentNullException("f"); // } // this.feature = new WeakReference(f); // if (renderer != null && (f.GetValue(Clusterer.ClusterProperty) == null)) // { // this.GeoStyle = renderer.GetStyle(f) ?? generateDefaultSyle(f); // }//renderer的优先级高于Feature自我的 // else // { // this.GeoStyle = f.Style ?? generateDefaultSyle(f); // } // f.SetBoundedStyle(this.GeoStyle); // if (this.GeoStyle != null) // { // base.Template = this.GeoStyle.ControlTemplate; // } // this.ignoreMouseEvents = _ignoreMouseEvent; // this.Geometry = f.Geometry; //} //internal static FeatureElement DrawShape(Feature feature, IRenderer renderer) //{ // SuperMap.Web.Core.Geometry geometry = feature.Geometry; // FeatureElement element = new FeatureElement(feature, renderer); // if (geometry is GeoPoint && element.GeoStyle is MarkerStyle) // { // MarkerStyle style = (MarkerStyle)(element.GeoStyle); // element.RenderTransform = new TranslateTransform { X = -style.OffsetX, Y = -style.OffsetY }; // } // else if (geometry is GeoLine && element.GeoStyle is LineStyle) // { // element.SetPath(); // } // else if (geometry is GeoRegion && element.GeoStyle is FillStyle) // { // element.SetPath(); // } // else // { // throw new ArgumentException(ExceptionStrings.InvalidSupportGeometry); // } // return element; //} 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; } }
//服务器返回结果,将最佳路径显示在客户端 private void service_ProcessCompleted(object sender, NetworkAnalystEventArgs e) { foreach (ServerGeometry p in e.Result.Paths) { PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle(); simpleLineStyle.Stroke = new SolidColorBrush(Colors.Blue); simpleLineStyle.StrokeThickness = 2; //显示返回的路径 Feature path = new Feature(); path.Geometry = p.ToGeometry(); path.Style = simpleLineStyle; featuresLayer.AddFeature(path); } }
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) { Feature feature = new Feature(); //设置预定义样式 PredefinedLineStyle style = new PredefinedLineStyle(); style.Stroke = new SolidColorBrush(Colors.Blue); style.StrokeThickness = 3; //将绘制的线转化为具有预定义样式的线要素 feature.Style = style; feature.Geometry = e.Geometry as GeoLine; //将线要素加载到矢量要素图层中 this.featuresLayer.Features.Add(feature); }
//绘制自由线结束后将所绘制的自由线转化为矢量要素并加载到矢量要素图层中,在加载前先设置该要素样式 private void freehand_DrawCompleted(object sender, DrawEventArgs e) { Feature feature = new Feature(); //设置预定义样式 PredefinedLineStyle style = new PredefinedLineStyle(); style.StrokeThickness = 3; style.Symbol = PredefinedLineStyle.LineSymbol.DashDotDot; style.Stroke = new SolidColorBrush(Colors.Purple); //将绘制的自由线转化为具有预定义样式的线要素 feature.Style = style; feature.Geometry = e.Geometry as GeoLine; //将线要素加载到矢量要素图层中 this.featuresLayer.Features.Add(feature); }
private void service_ProcessCompleted(object sender, RouteEventArgs e) { //预定义线样式 PredefinedLineStyle style = new PredefinedLineStyle { Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 3 }; //对结果进行判断,增强程序健壮性 if (e.Result == null) { MessageBox.Show("查询无结果"); return; } if (e.Result.NodePositions == null) { MessageBox.Show("查询无结果"); return; } if (e.Result.NodePositions.Count == 0) { MessageBox.Show("查询无结果"); return; } GeoLine line = new GeoLine(); line.Parts.Add(e.Result.NodePositions); //将feature 添加到图层中 Feature feature = new Feature { Geometry = line, Style = style }; featuresLayer.AddFeature(feature); }