贡献一个sharpmap,自定义专题地图源码

来源:互联网 发布:标准差计算器软件 编辑:程序博客网 时间:2024/05/16 15:03
 专题图代码主体部分

 SharpMap.Layers.VectorLayer layerValve;
            layerValve = new SharpMap.Layers.VectorLayer("valve", new SharpMap.Data.Providers.ShapeFile("../data/valve.shp"));
            layerValve.Style.SymbolOffset = new PointF(20, -35);
            map.Layers.Add(layerValve);

  SharpMap.Rendering.Thematics.CustomTheme myThemeValve = new SharpMap.Rendering.Thematics.CustomTheme(GetThemeStyleValve);
            layerValve.Theme = myThemeValve;
////////////////////////////////////////////////////////
专题图函数为
  private static SharpMap.Styles.VectorStyle GetThemeStyleValve(SharpMap.Data.FeatureDataRow row)
        {
            string strThemeField = row["onoroff"].ToString();
            SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();
            if (strThemeField != null)
            {
                if (strThemeField != "" && int.Parse(strThemeField) == 1)
                {
                    style.SymbolScale = 0.4f;
                    style.Symbol = new Bitmap("../resourcefiles/pipeOn.PNG");
                }
                else
                {
                    style.SymbolScale = 0.42f;
                    style.Symbol = new Bitmap("../resourcefiles/pipeOff.PNG");
                }
                style.SymbolOffset = new PointF(0, -15);
            }
            style.EnableOutline = true;
            return style;
        }


原创粉丝点击