MapControl对应ArcMap中的数据视图,它封装了Map对象,并提供了额外的属性、方法、事件用于:管理控件的外观、显示属性和地图属性;添加并管理控件中的数据层(da
ArcGIS的每种控件都有属性可以设置,它们可以在可视化环总重进行编译。将控件拖放到窗体上后,用户可以右键点击,选中“属性”菜单来编辑这些属性,它们可以让用户在不编写移行代码的情况下快速构建一个GIS应用程序。
MapControl 实现的主要接口有:IMapControlDefault、IMapControl2、IMapControl3 和事件接口IMapControlEvents2。
IMapControlDefault接口是地图控件缺省接口,多数开发环境自动使用这个接口定义属性、方法。这个接口也代表了控件最新版本的接口,MapControl 当前最新版本接口为 IMapControl3。
当需要使用这个接口的时候,可以使用下面的代码:IMapControlDefault pMapControl;
pMapControl = axMapControl1.Object as IMapControlDefault;
IMapControl2是任何一个与MapControl相关的任务的出发点,如设置控件外观,设置Map对象或控件的显示属性,添加或者管理数据图层、地图文档,在控件上绘制图形和返回Geometry等。IMapControl2定义了控制控件外观界面的种属性和方法,如Appearance、BorderStyle和BackColor。它定义的主要方法有TrackLine、TrackPolygon、TrackRectangle和Track Circle方法让程序员可以直接在控件上获得Geoemtry对象,它还提供了Drawshape和DrawText方法让用户直接在控件上绘制图形。
IMapContronl3接口继承IMapContronl2,并增加了以下8个属性和一个方法:CustomProperty设置自定义控件属性;DocumentFilename返回MapControl装入的地图文档的文件名;DocumentMap返回MapControluihou装入地图名称;KeyIntercept返回或设置MapControl截取键盘按键信息;Object返回潜在的MapControl控件,When querying interface to IMapControl2 in Visual Basic .NET or Visual C# .NET the Object property or container specific co
IMapControl2 pMapControl;
pMapControl = axMapControl1.Object as IMapControl2;
或
pMapControl = axMapControl1.GetOcx() as IMapControl2;
当使用IMapControl3 接口时:????
IMapControl3 pMapControl;
pMapControl = axMapControl1.Object as IMapControl3;
或
pMapControl = axMapControl1.GetOcx() as IMapControl3;};
ShowMapTips确定是否显示地图的Map Tips;TipDelay设置Map Tips的延迟时间;TipStyle设置Map Tips的显示样式;SuppressResizeDrawing ()当控制尺寸发生变化时阻止数据实时重绘。
esriKeyIntercept Constants?
Options for intercepting key presses handled by a controls container, these
values can be combined into a bit mask.
esriKeyIntercept 可能取值???
Constant Value Description
esriKeyInterceptNone 0 No keys are intercepted.
esriKeyInterceptArrowKeys 1 Intercepts the arrow keys, normally handled by the container to change control focus.
esriKeyInterceptAlt 2 Intercepts the Alt key, normally handled by a container to change focus.
esriKeyInterceptTab 4 Intercepts the Tab key, normally handled by the container to change control focus.
esriKeyInterceptEnter 8 Intercepts the Enter key, normally handled by the container to click the default button.
IMapControlEvents2是个事件接口,它定义了MapControl能够处理的全部事件,如On