SharpMap学习笔记1

            // 添加VectorLayer
            SharpMap.Layers.VectorLayer myLayer new SharpMap.Layers.VectorLayer("myLayer");
            string myLayerFullPath @"E:\New_Shapefile.shp";
            myLayer.DataSource new SharpMap.Data.Providers.ShapeFile(myLayerFullPath);

            // 添加LabelLayer
            LabelLayer myLbLyr new LabelLayer("myLabelLayer");
            myLbLyr.DataSource myLayer.DataSource;
            myLbLyr.LabelColumn "LabelField";


            // 设定VectorLayer图层样式
            //VectorStyle style new VectorStyle();
            //style.Fill Brushes.Blue;// 注:这里的style相当于symbol,一个FeatureClass中的所有要素都是这个符号(样式)
            //myLayer.Style style;    

            // 在制图表达中,往往需要根据要素不同类型采用不同方式表达,例如一个道路要素类,有高速公路、一级道路、二级道路等不同类型
            // 需要采用不同样式(style)表达,这时SharpMap.Rendering.Thematics中的对象就派上用场
            // 使用CustomTheme--VectorLayer
            SharpMap.Rendering.Thematics.CustomTheme myTheme new SharpMap.Rendering.Thematics.CustomTheme(SetCityStyle);
            myLayer.Theme myTheme;

            // 使用GradientTheme--VectorLayer
            VectorStyle minStyle new VectorStyle();
            minStyle.Fill Brushes.Black;
            VectorStyle maxStyle new VectorStyle();
            maxStyle.Fill Brushes.Red;
            SharpMap.Rendering.Thematics.GradientTheme myTheme2 new SharpMap.Rendering.Thematics.GradientTheme("Id", 1, 4, minStyle, maxStyle);
            // 使用ColorBlend(设定此属性会覆盖minStyle、maxStyle)--VectorLayer
            myTheme2.FillColorBlend SharpMap.Rendering.Thematics.ColorBlend.Rainbow5;
            myLayer.Theme myTheme2;

            // 设定LabelLayer样式
            LabelStyle lblMin new LabelStyle();
            LabelStyle lblMax new LabelStyle();
            lblMin.ForeColor Color.Black;
            lblMin.Font new Font(FontFamily.GenericSansSerif,6);
            lblMax.ForeColor Color.Blue;
            lblMax.BackColor new SolidBrush(Color.FromArgb(128,255,255,255));
            lblMin.BackColor lblMax.BackColor;
            lblMax.Font new Font(FontFamily.GenericSansSerif,9);
            myLbLyr.Theme new SharpMap.Rendering.Thematics.GradientTheme("Id",1,4,lblMin,lblMax);

            // 添加图层
            mapBox1.Map.Layers.Add(myLayer);
            mapBox1.Map.Layers.Add(myLbLyr);
            mapBox1.Map.Zoom 1000;  // 这里的Zoom应该是MapWidth,地图的宽度(Zoom)会根据其包含的图层宽度自动调整
            mapBox1.Map.ZoomToExtents();
            mapBox1.ActiveTool SharpMap.Forms.MapBox.Tools.Pan;
            mapBox1.Refresh();

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值