DotSpatial change map selection set highlight style

In DotSpatial, after the elements of a collection of layers into the map or select elements, color highlights, but the default color is Color.Cyan, its RGB is (0,255,255), the map is not very prominent, this is the next map colour. Actual needs, it may need more like the color red, by highlighting elements, but also elements of the highlighted line width compared to the normal mode is more coarse, easy to distinguish. End of the article comes codes Portal.

Here are two pictures after the modification in the absence of base map, the default highlighting the effect of contrast, the effect can be found in the revised even better in the case of small scale. If superimposed on the base map, the default highlighting the effect should be more prominent elements of difficulty.

 In DotSpatial, each layer has its own symbolic properties, contains two, one of Symbolizer (not symbolize for this style of the selected user-defined state), one of SelectionSymbolizer (for selected elements symbolic pattern elements in the state).

By setting SelectionSymbolizer property to change the selection highlight style layers, but because of the type of elements are roughly divided into three types of surface dotted line, which is drawn in different ways, layers SelectionSymbolizer inherited IFeatureSymbolizer, seen through the help documentation, its subclasses have LineSymbolizer, PointSymbolizer, PolygonSymbolizer several. IFeatureSymbolizer disposed in a corresponding feature type corresponding to the layer, to complete the setting of highlight. code show as below:

  /// <summary>
        /// 设置图层的高亮显示效果
        /// </summary>
        /// <param name="tempLayer"></param>
        private void setHighLightColor(FeatureLayer tempLayer) {
            try
            {
                switch (tempLayer.FeatureSet.FeatureType)
                {
                    case FeatureType.Line:

                        tempLayer.SelectionSymbolizer = new LineSymbolizer(Color.Red, Color.DarkRed, 2, System.Drawing.Drawing2D.DashStyle.Solid
                            , System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round);

                        break;

                    case FeatureType.MultiPoint:
                    case FeatureType.Point:

                        tempLayer.SelectionSymbolizer = new PointSymbolizer(Color.Red, DotSpatial.Symbology.PointShape.Star, 2);

                        break;

                    case FeatureType.Polygon:
                         
                        tempLayer.SelectionSymbolizer = new PolygonSymbolizer(Color.Red, Color.DarkRed, 2);


                        break;
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {

                throw;
            }
        }

A more detailed code portal  https://github.com/Spe1993/SpeRemarks/blob/master/DotSpatial/ChangeDefaultHighLightSymbol 

 

发布了16 篇原创文章 · 获赞 2 · 访问量 3505

Guess you like

Origin blog.csdn.net/weixin_41012454/article/details/88741303