${core_PredefinedMarkerStyle_Title}

${core_PredefinedMarkerStyle_Description}

Inheritance: MarkerStyle
示例#1
0
 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 async void getWFS_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                featuresLayer.ClearFeatures();
                GetWFSCapabilities getCapabilities = new GetWFSCapabilities(url);
                List<WFSFeatureType> featureTypes = await getCapabilities.ProcessAsync();

                if (featureTypes.Count > 9)
                {
                    GetWFSDescribeFeatureType featureType = new GetWFSDescribeFeatureType(url);
                    var featureInfo=featureTypes.Where(c=>c.Title=="Capitals").FirstOrDefault();
                    featureType.TypeNames.Add(featureInfo.TypeName);
                    Dictionary<string, List<WFSFeatureDescription>> dicFeatureDesp = await featureType.ProcessAsync();

                    SuperMap.WinRT.Core.PredefinedMarkerStyle markerStyle = new PredefinedMarkerStyle() { Symbol = PredefinedMarkerStyle.MarkerSymbol.Star,Size=15};
                   
                    foreach (var item in dicFeatureDesp)
                    {
                        if (item.Key == "http://www.supermap.com/World")
                        {
                            GetWFSFeature getWFSFeature = new GetWFSFeature(url)
                            {
                                MaxFeatures = 30,
                                FeatureNS = item.Key
                            };
                            WFSFeatureDescription typeCountries = new WFSFeatureDescription
                            {
                                TypeName = item.Value[0].TypeName,
                                SpatialProperty = item.Value[0].SpatialProperty,
                            };
                            typeCountries.Properties.Add(item.Value[0].Properties[0]);
                            typeCountries.Properties.Add(item.Value[0].Properties[1]);
                            getWFSFeature.FeatureDescriptions.Add(typeCountries);
                            GetWFSFeatureResult featureRes = await getWFSFeature.ProcessAsync();

                            foreach (var key in featureRes.FeaturePair)
                            {
                                featuresLayer.AddFeatureSet(key.Value, markerStyle);
                                foreach (Feature feature in key.Value)
                                {
                                    feature.ToolTip = new TextBlock
                                    {
                                        Text = "坐标:"+ "\n" + "X: " + feature.Attributes["SMX"] + "\n" + "Y: " + feature.Attributes["SMY"],
                                        Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Colors.Black),
                                        FontSize = 16
                                    };
                                }
                            }
                        }
                    }
                }
            }
            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
        }
 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;
     }
 }