DotSpatial入门教程(PDF)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

DotSpatial入门教程 整理者:Exlimit 一、下载安装与配置 (一)下载对于开发桌面版本的地图程序,在windows平台下Dotspatial是mapwingis控件的升级版本,它将作为mapwindow6的开发基础。Dotspatial现在还处于Beta阶段,但是已经可以使用。首先到下载最新版本的dotspatial。现在网站上提供了.net4.0和.net3.5两个版本。DotNet4.0版本的dotspatial下载地址。=DotSpatial&DownloadId=187098&FileTime=129369436213000000&Build=17450(二)创建工程启动vs2010创建一个window窗体应用程序在工具栏新建选项卡Dotspatial在选项卡处,鼠标右键选择项,点击浏览,找到下载的DotSpatial-x86Framework4.0选择DotSpatial.Controls.dll将Map,legend,spatialtoolstrip,和spatialstatusstrip拉入到form中,调整好布局。(三)设置空间属性设置toolstrip的map属性为map1(你所添加的map控件)。设置map1的legend为legend1,progresshandler为spatialStatusStrip1。(四)添加引用在解决方案,引用处添加几个引用,DotSpatial.Data.dllDotSpatial.Data.Forms.dllDotSpatial.Symbology.dllDotSpatial.Controls.dll设置好后,保存工程。启动调试,启动程序。(五)注意事项项目属性必须使用.netFramework4不要用那个clientprofile版本的。二. DotSpatial空间使用教程(英汉对照) Thisassignmenthas4importantsteps.这个练习包含4个重要步骤。Step1:DownloadtheDotSpatialclasslibraryandcreatetheDotSpatialtools.第一步:下载DotSpatial类库并创建DotSpatial工具Step2:AddtheDotSpatialreferenceandchangethecompileoption.第二步:添加DotSpatial引用,修改编译选项Step3:DesigntheGUI.(GUI–GraphicalUserInterface).第三步:设计图形用户接口(GUI-图形用户接口)Step4:Writethecodeforimplementingthemapoperations.第四步:编写程序实现地图操作Step1:DownloadtheDotSpatialclasslibraryandcreatetheDotSpatialtools.第一步:下载DotSpatial类库并创建DotSpatial工具1.DownloadtheDotSpatialclasslibrary(x86Framework4.0.zip)fromthefollowingURL.从下面地址下载DotSpatial类库(x86Framework4.0.zip)在VisualStudio2010的工具栏创建一个新的Tab,添加DotSpatial类库。CreateanewprojectinVisualBasicandselecttheToolBoxonthestandardmenubar.RightclickontheToolBoxwindowandchoose“AddTab”fromthecontextmenu.fig.1EnterthenewtabnameasDotSpatial.OntheDotSpatialtabrightclickandselectthechooseitemsfromthecontextmenu.在visualstudio2010中创建一个新的visualbasic工程,选择工具栏,鼠标右键点击工具选择“AddTab”,如图1所示,将Tab命名为DotSpatial。ThenclicktheBrowsebuttonontheChooseToolBoxItemswindow.fig.2.然后点击浏览按钮,选择工具窗口,如图2所示。SelecttheDotSpatial.Controls.dllfromthedownloadedfolder.(fig.3)从下载的目录选择DotSpatial.Controls.dll。(如图3)MakesuretheAppManagerischeckedontheChooseToolboxItemswindow.fig.4确认已将选择了AppManager。如图4。Step2:AddtheDotSpatialreferenceandchangethecompileoption.第二步:添加DotSpatial引用,修改编译选项2.1)AddtheDotSpatialreference2.1)添加DotSpatial引用1.Rightclickovertheprojectonthesolutionexplorerandselecttheaddreferencefromthecontextmenu.在工程项目浏览的项目上,点击鼠标右键,选择添加引用。2.Addthefollowing4referencesfromthedownloadedfolder.fig.52.添加如下图5所示的4个应用。DotSpatial.Controls.dll,DotSpatial.Data.dll,DotSpatial.Data.Forms.dll,DotSpatial.Symbology.dll3.1)Changethecompileoptionfrom.NetFrameWork4ClientProfileto.NetFrameWork43.1)修改编译选项NetFrameWork4ClientProfile改为.NetFrameWork41.Rightclickovertheprojectonthesolutionexplorerandselectthepropertiesfromthecontextmenu.1.鼠标右键单击解决方案,从选项中选择属性。选择高级选项,如上图6所示。ChoosetheAdvancedCompileOptionsontheabovewindow.fig.6Selectthe.NetFramework4andsavetheproject.选择.NetFramework4然后点击保存。Step3:DesigntheGUI.(GUI–GraphicalUserInterface).第三步:设计图形用户接口DesigntheGUIasfollows:按照下图所示设计图形用户接口。Interfacedesignconsiderations.接口设计注意事项。1.Add2panelcontrolsontheform.1.添加两个pannel控件到窗口pnlOperationsandsetthedockpropertyasTop.erations并且将dock属性设置成Top1.2)NamethesecondpanelaspnlMapandsetthedockpropertyasFill.1.2)将第一个pannel命名为pnlMap并且将dock属性设置成Fill2.DragthemapcontrolontothepnlMapfromthetoolbox,undertheDotSpatialtab.SetthedockpropertyofmaptoFill.2.从工具栏里拖动一个map控件到pnlMap,将其dock属性设置成Fill。3.AddagroupboxontothepnlOperationsandnameitasgrbOperations.3.添加一个groupbox控件到pnlOperations,并命名为grbOperations。4.Createfourbuttonsinsidethegroupbox.4.创建4个按钮,放到groupbox里。4.1)Usetheappropriatenameforbuttons.Nameofthebuttonsshouldbeasfollows:LoadMapbuttonname=btnLoad,ClearMap=btnClear,ZoomIn=btnZoomIn,ZoomOut=btnZoomOutandZoomtoExtend=btnZoomtoExtend.4.2)Useshortcutkeysforthebuttonclickevent.Ex:LoadMapbutton’sshortcutkeyisShift+L.Toimplementthisfeature,onthepropertieswindowofthebuttonselecttheTextpropertyandusethe&signinfrontofanyletter.Intheloadbuttoncase,Textpropertyshouldbe&LoadMap.Theremainingbuttons’Textpropertyshouldbeasfollows:ClearMapbutton=&ClearMap,Zoomin=Zoom&In,ZoomOut=Zoom&OutandZoomtoExtend=Zoomto&Extend.5.Addatitlelabelabovethegroupbox.NameofthelabelshouldbelblTitleandthetextpropertyofthelabelisBasicMapOperations.Step4:Writethecodeforimplementingthemapoperations.1.1)Namethefirstpanelas1.1)将第一个pannel命名为pnlOp第四步:编写代码,实现地图操作1.Doubleclickoverthebuttonontheformtogettheselectedbutton’sclickeventcodeview.1.双击按钮获得按钮的点击操作。AsSystem.EventArgs)HandlesbtnLoad.ClickEndSubPrivateSubbtnRemove_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)'Clear()methodisusedtocleartheshapelayersfrommapcontrolEndSubrAsSystem.Object,ByValeAsSystem.EventArgs)soomIn.ClickPrivateSubbtnZoomToExtend_Click(ByValsenderAsSystem.Object,ByValeshapefileMap1.ZoomToMaxExtent()nderAsSystem.Object,ByValeAsSystem.EventArgs)'Measurefunctionisusedtomeasuret

1 / 17
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功