SharpMap入门教程
SharpMap是一个基于.NET Framework 4,采用C#开发的地图渲染引擎,非常易于使用。本教程针对SharpMap入门及开发,讲述如何基于SharpMap组件渲染Shapefile数据。
一、添加SharpMap的UI组件至VS工具箱
添加后如图所示

二、加载Shapefile图层数据
1、给WinForm窗体添加MapBox组件
2、为项目添加SharpMap引用,一般来说给WinForm窗体添加MapBox组件后,会自动引用SharpMap引用,如果没有的话,手动添加SharpMap.dll引用
3、在WinForm窗体构造器方法中添加如下代码,实现加载Shapefile数据
SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("States");
vlay.DataSource = new SharpMap.Data.Providers.ShapeFile("ShpData\\Provinces_R.shp", true);
mapBox1.Map.Layers.Add(vlay);
mapBox1.Map.ZoomToExtents();
mapBox1.Refresh();
4、设置当前地图工具为Pan(漫游)
mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;
运行结果如下(默认的渲染样式比较丑)

三、根据要素属性唯一值渲染图层
该图层的id字段取值为[1,2,3,4],为每一种类型设置不同的渲染风格,指定按id字段唯一值进行渲染
VectorStyle style1 = new VectorStyle();
style1.Fill = new SolidBrush(Color.FromArgb(, , ));
style1.EnableOutline = true;
style1.Outline = new Pen(Brushes.Black, 1.2f);
VectorStyle style2 = new VectorStyle();
style2.Fill = new SolidBrush(Color.FromArgb(, , ));
style2.EnableOutline = true;
style2.Outline = new Pen(Brushes.Black, 1.2f);
VectorStyle style3 = new VectorStyle();
style3.Fill = new SolidBrush(Color.FromArgb(, , ));
style3.EnableOutline = true;
style3.Outline = new Pen(Brushes.Black, 1.2f);
VectorStyle style4 = new VectorStyle();
style4.Fill = new SolidBrush(Color.FromArgb(, , ));
style4.EnableOutline = true;
style4.Outline = new Pen(Brushes.Black, 1.2f);
Dictionary<string, SharpMap.Styles.IStyle> styles = new Dictionary<string, IStyle>();
styles.Add("", style1);
styles.Add("", style2);
styles.Add("", style3);
styles.Add("", style4);
vlay.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme<string>("id", styles, style1);
运行结果如下

渲染效果还不错吧,比默认样式好看多了 :)
SharpMap入门教程的更多相关文章
- SharpMap开发教程——图层标注
在GIS开发中,根据图层属性字段对要素进行标注(图层标注)是一项常规的.必备的功能.在基于SharpMap开发GIS应用时,也可以方便的实现该功能. 1.加载Shapefile图层数据 SharpMa ...
- esri-leaflet入门教程(1)-leaflet介绍
esri-leaflet入门教程(1)-esri leaflet介绍 by 李远祥 关于leaflet,可能很多人比较陌生,如果搭上esri几个字母,可能会有更多的人关注.如果没有留意过leaflet ...
- wepack+sass+vue 入门教程(三)
十一.安装sass文件转换为css需要的相关依赖包 npm install --save-dev sass-loader style-loader css-loader loader的作用是辅助web ...
- wepack+sass+vue 入门教程(二)
六.新建webpack配置文件 webpack.config.js 文件整体框架内容如下,后续会详细说明每个配置项的配置 webpack.config.js直接放在项目demo目录下 module.e ...
- wepack+sass+vue 入门教程(一)
一.安装node.js node.js是基础,必须先安装.而且最新版的node.js,已经集成了npm. 下载地址 node安装,一路按默认即可. 二.全局安装webpack npm install ...
- Content Security Policy 入门教程
阮一峰文章:Content Security Policy 入门教程
- gulp详细入门教程
本文链接:http://www.ydcss.com/archives/18 gulp详细入门教程 简介: gulp是前端开发过程中对代码进行构建的工具,是自动化项目的构建利器:她不仅能对网站资源进行优 ...
- UE4新手引导入门教程
请大家去这个地址下载:file:///D:/UE4%20Doc/虚幻4新手引导入门教程.pdf
- ABP(现代ASP.NET样板开发框架)系列之2、ABP入门教程
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之2.ABP入门教程 ABP是“ASP.NET Boilerplate Project (ASP.NET样板项目)” ...
随机推荐
- Asp.net 的工作原理
转:http://www.cnblogs.com/linjiancun/archive/2010/09/14/1825662.html 1.1.1 Asp.net 的工作原理 ...
- sql开启xp_cmdshell
sql开启xp_cmdshell sp_configure reconfigure go sp_configure reconfigure go
- Elasticsearch-2.4.3的下载(图文详解)
第一步:进入Elasticsearch的官网 https://www.elastic.co/ 第二步:点击downloads https://www.elastic.co/downloads 第三步: ...
- objective-C: NSString应该用initWithFormat? 还是 stringWithFormat?
今天在看书上的一段代码时,发现NSString实例化时,有时用的是initWithFormat方法,有时用的是stringWithFormat,到底应该如何选择呢? 区别: 1.initWithFor ...
- axis2 webService开发指南(2)
1 Axis2的简单WebService示例 1.1 新建一个web工程,创建一个类Greeting,用于当作webservice服务 代码如下: package amyservices; impo ...
- 在Yii Framework中利用PHPMailer发送邮件(2011-06-02 14:06:23)
转载▼ 标签: it 分类: 技术共享 官方扩展链接:http://www.yiiframework.com/extension/mailer/这个扩展配置十分方便,如果有问题的话,可以打开Debug ...
- java 蓝桥杯算法提高 字串统计
思路:这道题用HashMap来保存枚举的字串,key值保存字串-value值保存字串所出现的次数: 通过for循环并使用subString()方法枚举所有符合要求的子串maxStr记录 ...
- sax解析xml文件,封装到对象中
创建User.java类 public class User { private String id; private String name; private String age; private ...
- SpringCloud04 服务配置中心、消息总线、远程配置动态刷新
1 环境说明 JDK:1.8 MAVENT:3.5 SpringBoot:2.0.5.RELEASE SpringCloud:Finchley.SR1 2 创建服务注册中心(Eureka服务端) 说明 ...
- 49. Group Anagrams同义词合并
[抄题]: Given an array of strings, group anagrams together. Example: Input: ["eat", "te ...