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样板项目)” ...
随机推荐
- Notes About Singular Value Decomposition
A brief summary of SVD: An original matrix Amn is represented as a muliplication of three matrices: ...
- Nodejs&Express
http://www.expressjs.comhttp://github.com/lelandtseng/form-datahttp://github.com/lelandtseng/mongo-m ...
- Can only modify an image if it contains a bitmap
Can only modify an image if it contains a bitmap Image1装载了JPG文件后下面都报错,因为. Image1.Canvas.CopyRect(dre ...
- application-defined exception
dataSnap服务器,客户端调用的时候写错了一句话, SQLConnection1->CloneConnection(); 改为 SQLConnection1->Close(); 就好了 ...
- Spring与Redis的实现
前言 Redis作为缓存还是相当不错的,一定程度上缓解了数据库的IO操作,具体不多说,具体网上查找资料. 实战 不多说,直接上代码. 第一步:所需要的依赖 <!-- redis --> & ...
- bootstrap 自定义
在ror工程内 /app/assets/stylesheets/bootstrap_and_overrides.css.less 内覆盖内容 具体参数如下 https://github.com/twb ...
- promtheus 配置文件
全局配置 global 属于全局的默认配置,它主要包含 4 个属性, scrape_interval: 拉取 targets 的默认时间间隔. scrape_timeout: 拉取一个 target ...
- FFmpeg多媒体文件格式探测
FFmpeg版本:3.4 在FFmpeg中,每一种文件容器格式都对应一种AVInputFormat 结构,位于源码中libavformat文件夹中.当调用avformat_open_input的时候, ...
- 前端中this的用法
this指的是方法下的所有参数 handleDelete(record){ this.XXX.AAA (这个this.XXX指的是handleDelete这个方法的所有参数) (let self = ...
- 【hdu6148】Valley Numer【数位dp模板题】
题意 对于每组数据给出一个整数n(length(n)<=100),找出不大于n的数字中有多少是Valley Numer.对于Valley的定义是它每一位的数字要么是递增,要么是递减,要么是先递减 ...