/// <summary>${utility_JsonHelper_method_FromGeoPoint_D}</summary> public static string FromGeoPoint(GeoPoint point) { if (point == null) { return "{}"; } return string.Format(CultureInfo.InvariantCulture, "{{\"x\":{0},\"y\":{1}}}", point.X, point.Y); }
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 }
//添加虚拟顶点; private Feature addHoverVertex(Feature feature , GeoPoint p , int index , int partIndex) { Feature hoverVertex = new Feature() { Geometry = p , Style = HoverVertexStyle }; hoverVertex.SetZIndex(2); hoverLayer.Features.Add(hoverVertex); hoverVertex.Attributes.Add("Feature" , feature); hoverVertex.Attributes.Add("Index" , index); hoverVertex.Attributes.Add("PartIndex" , partIndex); hoverVertex.AddOnDoubleTapped((s , e) => { deleteOneVertex(s as Feature); });//双击删除某个顶点,线和面。 return hoverVertex; }
//当线对象时,显示bounds的中心点; private void addCenterFeature(Feature feature) { GeoPoint center = new GeoPoint(feature.Geometry.Bounds.Center.X , feature.Geometry.Bounds.Center.Y); hoverCenterFeature = new Feature { Geometry = center , Style = HoverCenterStyle }; hoverCenterFeature.SetZIndex(3); hoverLayer.AddFeature(hoverCenterFeature); }
private GeoPoint ParsePointCoordinates(string p) { GeoPoint point = new GeoPoint(); if (!string.IsNullOrEmpty(p)) { string[] pointStr = p.Trim().Split(','); point.X = double.Parse(pointStr[0], CultureInfo.InvariantCulture); point.Y = double.Parse(pointStr[1], CultureInfo.InvariantCulture); } return point; }
//预留接口 private static GeoPoint ToGeoPoint(XElement xe) { GeoPoint point = new GeoPoint(); return point; }