${core_PredefinedMarkerStyle_Title}
${core_PredefinedMarkerStyle_Description}
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 CustomClustererTest_Loaded(object sender, RoutedEventArgs e) { FeaturesLayer featuresLayer = this.MyMap.Layers["MyFeaturesLayer"] as FeaturesLayer; featuresLayer.Clusterer = new CustomClusterer() { AggregateColumn = "id", StyleScale = 0.01 }; for (int i = 0; i < 1000; i++) { Feature feature = new Feature(); feature.Geometry = new GeoPoint(random.NextDouble() * (ChinaRight - ChinaLeft) + ChinaLeft, random.NextDouble() * (ChinaTop - ChinaBottom) + ChinaBottom); PredefinedMarkerStyle ps = new PredefinedMarkerStyle(); ps.Color = new SolidColorBrush(Colors.Red); ps.Size = 10; feature.Style = ps; feature.ToolTip = new TextBlock() { Text = i.ToString(System.Globalization.CultureInfo.InvariantCulture) }; feature.Attributes.Add("id", i); featuresLayer.Features.Add(feature); } }
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 }
//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 point_DrawCompleted(object sender, DrawEventArgs e) { //设置预定义样式 PredefinedMarkerStyle style = new PredefinedMarkerStyle(); style.Color = new SolidColorBrush(Colors.Red); style.Size = 30; style.Symbol = PredefinedMarkerStyle.MarkerSymbol.Star; //将绘制的点转化为具有预定义样式的点要素并加载到矢量要素图层中 Feature feature = new Feature() { Geometry = e.Geometry as GeoPoint, Style = style }; this.featuresLayer.Features.Add(feature); }