收藏 分销(赏)

GIS应用开发.pptx

上传人:精*** 文档编号:4841251 上传时间:2024-10-14 格式:PPTX 页数:154 大小:1.34MB 下载积分:20 金币
下载 相关 举报
GIS应用开发.pptx_第1页
第1页 / 共154页
GIS应用开发.pptx_第2页
第2页 / 共154页


点击查看更多>>
资源描述
江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETGIS GIS 应应 用用 开开 发发Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET 江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET教学目标教学目标lGISGIS应用开发应用开发课程是课程是GISGIS研究生重要的研究生重要的专业课程,通过课程的学习,专业课程,通过课程的学习,了解了解ArcGIS ArcGIS 软件体系结构及软件体系结构及ArcObjectsArcObjects (ArcGIS(ArcGIS Engine)Engine)组件构成,并能熟练使用组件构成,并能熟练使用ArcObjectsArcObjects(ArcGIS(ArcGIS Engine)Engine)进行进行应用型应用型GISGIS开发开发;掌握应用型掌握应用型GISGIS开发的基本思路、技术方法开发的基本思路、技术方法.江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETChap.3 Chap.3 使用使用ArcObjectsArcObjects控件编程控件编程(6 6学时)学时)l为了能够快速建构一个具有为了能够快速建构一个具有GISGIS功能的独立应用程序,功能的独立应用程序,ArcGISArcGIS EngineEngine为开发者提供了为开发者提供了多个可视化的组件即多个可视化的组件即控件控件,如如 LicenseControlLicenseControl 、MapControlMapControl、PageLayoutControlPageLayoutControl、TOCControlTOCControl、ToolbarControlToolbarControl和和SymbologyControlSymbologyControl等。等。l在在VS.NETVS.NET中使用中使用ArcObjectsArcObjects,需要使用,需要使用ESRI interopESRI interop程序集,程序集,这些程序集在托管的这些程序集在托管的.NET.NET代码和非托管的代码和非托管的COMCOM代码之间起代码之间起了桥梁作用。了桥梁作用。lESRI interopESRI interop程序集为程序集为ArcGISArcGIS控件提供了能够位于控件提供了能够位于.NET.NET窗体窗体上的控件上的控件(继承自继承自AxHostAxHost类类),这些控件名前缀为,这些控件名前缀为“AxAx”,如如AxMapControlAxMapControl、AxPageLayoutControlAxPageLayoutControl、AxTOCControlAxTOCControl和和AxToolbarControlAxToolbarControl等。等。江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETUsing ArcGIS Engine controlsUsing ArcGIS Engine controls in in Winforms Winforms Using ArcGIS Engine Using ArcGIS Engine Controls in WPFControls in WPF江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET本章内容:本章内容:1.1.MapControlMapControl控件控件 2.2.PageLayoutControlPageLayoutControl控件控件3.3.TOCControlTOCControl控件控件4.4.ToolbarControlToolbarControl及相关对象及相关对象5.5.Control CommandsControl Commands(SymbologyControl in Chapter 6)(SymbologyControl in Chapter 6)6.6.在在WPFWPF程序中使用程序中使用ArcGIS EngineArcGIS Engine控件控件江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.13.1 MapControl MapControl控件控件lMapControlMapControl对应于对应于ArcMapArcMap中的数据视图中的数据视图,其,其主要功能为主要功能为空间数据浏览、空间数据可视空间数据浏览、空间数据可视化、空间查询、空间分析、空间数据编辑化、空间查询、空间分析、空间数据编辑等。等。l在可视化环境中,可以通过控件的在可视化环境中,可以通过控件的“属性属性”页页设置控件的相关属性,也可以通过设置控件的相关属性,也可以通过编编程程来设置。来设置。江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETlMapControlMapControl是对是对MapMap对象对象的封装的封装,并提供了,并提供了额外的属性、方法、事件用于:额外的属性、方法、事件用于:1.1.管理控件的外观、显示属性和地图属性;管理控件的外观、显示属性和地图属性;2.2.添加并管理控件中的数据层(添加并管理控件中的数据层(data layersdata layers););3.3.装载装载MapMap文档(文档(mxdmxd)到控件中;)到控件中;4.4.从其它应用程序拖放数据到控件中;从其它应用程序拖放数据到控件中;5.5.使用鼠标拉绘几何形状并绘制到屏幕显示中。使用鼠标拉绘几何形状并绘制到屏幕显示中。江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.1.1 3.1.1 MapControlMapControl的的主要接口主要接口lMapControlMapControl实现的主要接口有:实现的主要接口有:IMapControlDefaultIMapControlDefaultIMapControl2IMapControl2IMapControl3IMapControl3IMapControl4(IMapControl4(new in 9.2new in 9.2)IMapControlEvents2IMapControlEvents2事件接口事件接口ITOCBuddyITOCBuddyIToolbarBuddyIToolbarBuddy江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.1.1.1 3.1.1.1 IMapControlDefault IMapControlDefault接口接口lIMapControlDefaultIMapControlDefault接口是地图控件缺省接口,多数开接口是地图控件缺省接口,多数开发环境自动使用这个接口定义的属性、方法。发环境自动使用这个接口定义的属性、方法。l由于由于MapControlMapControl是一个自动化控件,当它被放到一个是一个自动化控件,当它被放到一个容器容器-如窗体上后,它会自动产生一个被称为如窗体上后,它会自动产生一个被称为axMapControl1axMapControl1的对象,的对象,这个对象可以直接使用缺省接这个对象可以直接使用缺省接口定义的属性和方法口定义的属性和方法。这个接口也代表了控件最新版这个接口也代表了控件最新版本的接口本的接口,MapControlMapControl当前最新版本接口为当前最新版本接口为IMapControl4IMapControl4.l当需要使用这个接口的时候,可以使用下面的代码:当需要使用这个接口的时候,可以使用下面的代码:IMapControlDefaultIMapControlDefault pMapControl=pMapControl=axMapControl1.Object as axMapControl1.Object as IMapControlDefaultIMapControlDefault;江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETlIMapControl2.Extent:IMapControl2.Extent:地图的可视范围地图的可视范围;lIMapControl2.FullExtent:IMapControl2.FullExtent:地图中所有图层的覆地图中所有图层的覆盖范围盖范围.江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.1.1.2 3.1.1.2 IMapControl4IMapControl4接口接口lIMapControl4IMapControl4是任何一个与是任何一个与MapControlMapControl相关的相关的任务的出发点任务的出发点,如,如设置控件外观,设置设置控件外观,设置MapMap对象或控件的显示属性,添加或者管理图层、对象或控件的显示属性,添加或者管理图层、地图文档,在控件上绘制图形和返回地图文档,在控件上绘制图形和返回GeometryGeometry等。等。江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETIMapControl2IMapControl2江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.1.1.3 3.1.1.3 IMapControl3IMapControl3与与IMapControl4IMapControl4lIMapControl3IMapControl3接口继承接口继承IMapControl2IMapControl2,并,并增加了以下增加了以下8 8个属性和个属性和一个方法一个方法:CustomProperty CustomProperty-object-object:使用该属性关联有用信息:使用该属性关联有用信息DocumentFilenameDocumentFilename -string)-string):返回:返回MapControlMapControl装入的地图装入的地图文档的文件名文档的文件名DocumentMap DocumentMap-string-string:返回:返回MapControlMapControl最后装入的地图最后装入的地图(MapMap)名称)名称KeyIntercept KeyIntercept-int-int:返回或设置:返回或设置MapControlMapControl截取键盘按键截取键盘按键信息信息江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETObject Object-object-object:返回潜在的返回潜在的MapControlMapControl控件,控件,当在当在VB.NETVB.NET或或C#.NETC#.NET中使用中使用IMapControl2IMapControl2时,一定要使用时,一定要使用ObjectObject属性或者使用指定容器的代码。属性或者使用指定容器的代码。因为对于因为对于.NET.NET,真正的控件是被包装于宿主对象里面的。真正的控件是被包装于宿主对象里面的。ShowMapTips ShowMapTips-bool-bool:确定是否显示地图的确定是否显示地图的Map TipsMap TipsTipDelay-int TipDelay-int:设置:设置Map TipsMap Tips的延迟时间的延迟时间TipStyle TipStyle-esriTipStyle-esriTipStyle :设置:设置Map TipsMap Tips的显示样式的显示样式SuppressResizeDrawing()SuppressResizeDrawing():在控件尺寸发生变在控件尺寸发生变化过程中,阻止数据实时重绘化过程中,阻止数据实时重绘江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETl与与IMapControl3IMapControl3相比,相比,IMapControl4IMapControl4多了以下多了以下两个可两个可读写属性读写属性:public bool public bool AutoKeyboardScrollingAutoKeyboardScrolling get;set;get;set;:确定是否使确定是否使用键盘上的用键盘上的HomeHome(keyCode 36)(keyCode 36)键、键、EndEnd (keyCode 35)(keyCode 35)键、键、Page DownPage Down(keyCode 34)(keyCode 34)键、键、PageUpPageUp(keyCode 33)(keyCode 33)键和键和箭头键箭头键(keyCode 37-40)(keyCode 37-40)来来平移控件中的地图平移控件中的地图,缺省情况下该属性为缺省情况下该属性为truetrue.绝大多数开发环境使用箭头键来切换窗体或容器中的焦绝大多数开发环境使用箭头键来切换窗体或容器中的焦点控件;在这些开发环境中,缺省情况下点控件;在这些开发环境中,缺省情况下MapControl MapControl 不不会接收箭头键来平移地图的显示。会接收箭头键来平移地图的显示。为确保箭头键能够被为确保箭头键能够被MapControlMapControl接收并平移地图的显示,接收并平移地图的显示,KeyInterceptKeyIntercept属性应属性应设置为拦截箭头键设置为拦截箭头键(esriKeyInterceptArrowKeysesriKeyInterceptArrowKeys),且且AutoKeyboardScrollingAutoKeyboardScrolling设置为设置为truetrue。江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETpublic bool public bool AutoMouseWheelAutoMouseWheel get;set;get;set;:确定鼠标确定鼠标滚轮是否用于缩放地图的显示;滚轮是否用于缩放地图的显示;缺省情况下该缺省情况下该属性为属性为truetrue。江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET引用控件本身引用控件本身l当使用当使用IMapControl2IMapControl2接口时:接口时:IMapControl2IMapControl2 pMapControl=axMapControl1.pMapControl=axMapControl1.Object Object as as IMapControl2IMapControl2;或或IMapControl2IMapControl2 pMapControl=axMapControl1.pMapControl=axMapControl1.GetOcx()GetOcx()as as IMapControl2IMapControl2;l当使用当使用IMapControl3IMapControl3接口时:接口时:IMapControl3IMapControl3 pMapControl=axMapControl1.pMapControl=axMapControl1.ObjectObject as as IMapControl3IMapControl3;或或IMapControl3IMapControl3 pMapControl=axMapControl1.pMapControl=axMapControl1.GetOcx()GetOcx()as as IMapControl3IMapControl3;江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETl当使用当使用IMapControl4IMapControl4接口时:接口时:IMapControl4IMapControl4 pMapControl;pMapControl;pMapControl=axMapControl1.pMapControl=axMapControl1.ObjectObject as as IMapControl4IMapControl4;或或pMapControl=axMapControl1.pMapControl=axMapControl1.GetOcx()GetOcx()as as IMapControl4IMapControl4;江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET使用箭头键、鼠标滚轮实现地图导航使用箭头键、鼠标滚轮实现地图导航l使用箭头键平移(使用箭头键平移(PanningPanning)地图)地图axMapControl1.KeyIntercept=(int)axMapControl1.KeyIntercept=(int)esriKeyInterceptesriKeyIntercept.esriKeyInterceptArrowKeys;.esriKeyInterceptArrowKeys;axMapControl1.AutoKeyboardScrolling=trueaxMapControl1.AutoKeyboardScrolling=true;l使用鼠标滚轮缩放地图使用鼠标滚轮缩放地图axMapControl1.AutoMouseWheel=true;axMapControl1.AutoMouseWheel=true;江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETaxMapControl1.KeyIntercept=(int)axMapControl1.KeyIntercept=(int)esriKeyInterceptesriKeyIntercept.esriKeyInterceptArrowKeys;.esriKeyInterceptArrowKeys;AutoKeyboardScrolling=true;AutoKeyboardScrolling=true;ConstantValueDescriptionesriKeyInterceptNone0No keys are intercepted.esriKeyInterceptArrowKeys1Intercepts the arrow keys,normally handled by the container to change control focus.esriKeyInterceptAlt2Intercepts the Alt key,normally handled by a container to change focus.esriKeyInterceptTab4Intercepts the Tab key,normally handled by the container to change control focus.esriKeyInterceptEnter8Intercepts the Enter key,normally handled by the container to click the default button.江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.1.1.4 3.1.1.4 IMapControlEvents2 IMapControlEvents2接口接口lIMapControlEvents2IMapControlEvents2是一个事件接口,是一个事件接口,它定义了它定义了 MapControlMapControl能够处理的全能够处理的全部事件,如部事件,如 OnExtentUpdatedOnExtentUpdated是地图是地图的的 Extent(Extent(可视范围可视范围)属性发生变化时属性发生变化时触发的事件触发的事件,OnAfterscreenDrawOnAfterscreenDraw是是绘屏结束后触发的事件等。绘屏结束后触发的事件等。当地图当地图的覆盖范围变化时,触发的覆盖范围变化时,触发OnFullExtentUpdated OnFullExtentUpdated 事件,事件,例如,往例如,往地图中新增加一个图层,其覆盖范地图中新增加一个图层,其覆盖范围大于原图的范围。围大于原图的范围。?江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETl在绝大多数开发环境中,没有必要手工编写在绝大多数开发环境中,没有必要手工编写代码进行事件的注册,而代码进行事件的注册,而只需在控件的属性只需在控件的属性窗口中双击某事件自动进行事件与其处理方窗口中双击某事件自动进行事件与其处理方法的关联。法的关联。江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.1.1.53.1.1.5 ITOCBuddyITOCBuddyl该接口定义了以下该接口定义了以下2 2个方法个方法:GetActiveViewGetActiveView Returns the underlying object Returns the underlying object implementing basic map and ActiveView.This is implementing basic map and ActiveView.This is used to populate the TOC.used to populate the TOC.GetScaleGetScale Returns the scale of the supplied Returns the scale of the supplied BasicMap,this BasicMap,this allows for allows for objects that do not support objects that do not support IMapIMap.江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.1.1.63.1.1.6 IToolbarBuddy IToolbarBuddy lObjects that implement the Objects that implement the IToolbarBuddyIToolbarBuddy interface can interface can be passed to the be passed to the IToolbarControl.SetBuddyControl IToolbarControl.SetBuddyControl method.method.lThe The CurrentToolCurrentTool is the tool used to interact with the is the tool used to interact with the display area of the display area of the IToolbarControl.BuddyIToolbarControl.Buddy.江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETlSamplesSamples:1.1.MapAndPageLayoutSynchAppMapAndPageLayoutSynchApp2.2.MapControlMapTipsMapControlMapTips3.3.MapControlGeoEventsMapControlGeoEvents4.4.MapControlDrawTextMapControlDrawText5.5.MapControlCADViewerMapControlCADViewer6.6.MapControlSaveLayerFileMapControlSaveLayerFile江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETlGuid.ToString(string format)Guid.ToString(string format)命名空间命名空间:System:System;程序集;程序集:mscorlib:mscorlibformat format 一个单格式说明符,它指示如何格式化此一个单格式说明符,它指示如何格式化此 Guid Guid 的的值。值。format format 参数可以是参数可以是“N”N”、“D”D”、“B”B”或或“P”P”。说明符说明符 返回值的格式返回值的格式 N32 位:位:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx D由连字符分隔的由连字符分隔的 32 位数字:位数字:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx B括在大括号中、由连字符分隔的括在大括号中、由连字符分隔的 32 位数字:位数字:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx P括在圆括号中、由连字符分隔的括在圆括号中、由连字符分隔的 32 位数字:位数字:(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET3.1.2 MapControl3.1.2 MapControl控件与控件与MXDMXD文件文件lMapControlMapControl控件可以控件可以“链接链接”或或“包含包含”地图文档。地图文档。l对于文档文件,对于文档文件,MapControlMapControl控件可以直接控件可以直接使用使用LoadMxFileLoadMxFile方法来载入,这是最简单的方法来载入,这是最简单的方法。方法。除此之外,可以使用除此之外,可以使用IMapDocumentIMapDocument接口定义的属性和方法来加载一个接口定义的属性和方法来加载一个MXDMXD文文件。件。江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NET下面是一个载入文档的例子下面是一个载入文档的例子-axMapControl1.axMapControl1.LoadMxFileLoadMxFileprivate void LoadMapDocument()private void LoadMapDocument()System.Windows.Forms.System.Windows.Forms.OpenFileDialogOpenFileDialog openFileDialog2;openFileDialog2;openFileDialog2=new OpenFileDialog();openFileDialog2=new OpenFileDialog();openFileDialog2.Title=Open Map Document;openFileDialog2.Title=Open Map Document;openFileDialog2.Filter=Map Documents(*.mxd)|*.mxd;openFileDialog2.Filter=Map Documents(*.mxd)|*.mxd;openFileDialog2.ShowDialog();openFileDialog2.ShowDialog();string sFilePath=openFileDialog2.FileName;string sFilePath=openFileDialog2.FileName;if if(axMapControl1.(axMapControl1.CheckMxFileCheckMxFile(sFilePath)(sFilePath)axMapControl1.axMapControl1.LoadMxFileLoadMxFile(sFilePath,0,Type.Missing);(sFilePath,0,Type.Missing);elseelse MessageBox.Show(sFilePath+is not a valid ArcMap document);MessageBox.Show(sFilePath+is not a valid ArcMap document);return;return;江西理工大学江西理工大学 Developing GIS Applications with ArcObjects using C#.NETDeveloping GIS Applications with ArcObjects using C#.NETl在在ArcMapArcMap中使用的地图文档对象为中使用的地图文档对象为MxDocumentMxDocument,其主要接口是其主要接口是IMxDocumentIMxDocument;在使用控件开发的独在使用控件开发的独立应用程序中,使用的地图文档对象为立应用程序中,使用的地图文档对象为MapDocumentMapDocument ,其主要接口是其主要接口是IMapDocumentIMapDocument。lIMapDocumentIMapDocument接口定义了操作和管
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服