IMapControl3 和IMapControl2 的区别

本文对比了IMapControl2和IMapControl3接口的功能特性。IMapControl2提供了地图控制的基本功能,如设置外观、管理图层等;而IMapControl3在此基础上增加了设置自定义属性及在调整地图大小时抑制数据重绘等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

IMapControl3 与IMapControl2

IMapControl2:

Provides access to members that control the MapControl.

Description

The IMapControl2 interface is a starting point for any tasks related to the MapControl, such as setting general appearance, setting map and display properties, adding and managing data layers and map documents, and drawing and tracking shapes.
 

IMapControl3 Interface:

Provides access to members that control the MapControl.

Product Availability
Available with ArcGIS Engine.
Description

The IMapControl3 interface provides additional members for tasks related to the MapControl, such as setting a custom property and suppressing data redraw whilst the MapControl is being resized.

转载于:https://www.cnblogs.com/tianpinganer/p/4982443.html

第一部分: 1.供水管线数据的处理:根据某厂区供水管线图(Shapefile格式,见附件1)、供水管道探测数据(见附件2)组织好供水管线的空间与属性数据,建立基于ArcGIS个人地理数据库的供水管网的几何网络模型(有兴趣的同学可以考虑建立基于SQL Server的空间数据库),即网络数据集;将管线图形数据与探测属性数据关联起来;编制相应的MXD地图文档;为后续功能实现打基础。 2.供水管网地理信息系统的功能模块设计与界面设计:根据供水管网地理信息系统功能需求划分好系统的功能模块,并进行系统界面设计,包括菜单、工具条、状态栏等设计。在设计各功能模块界面时,要考虑各窗体间的相互关系。功能需求如下: a)基本GIS操作功能:地图显示、放大、缩小、平移(放大、缩小、平移等工具的图标后面需要显示中文字符)、滚轮缩放、鹰眼导航、地图按某一给定的角度旋转,鼠标位置坐标的状态栏实时显示,地图缩放比例状态栏显示。 b)地图加载功能:加载Mxd地图文档、添加Shapefile图层文件。 c)图层控制功能:图层显示与否,图层对应图形的居中显示,打开图层属性表,属性表中切换记录时当前记录的图形高亮定位、闪烁与居中显示3个功能。 d)空间选择功能:可以绘制矩形、圆形、多边形、折线进行地理要素的选择。 e)空间量测功能:可进行多边形面积与周长量测、折线周长量测、点的坐标量测。 f)空间查询功能:图形与其属性的综合查询,包括构建表达式查询图形及属性、按管线节点类型(如三通、四通、弯头等,参见附件2)查询节点属性及相应图形、点击图形查其对应的属性信息、根据管径大小查询其空间位置及属性信息、按照材质查询相应的管线节点位置及其属性、按照附属物类型查询管线节点空间位置及属性信息。 g)图形编辑功能:管线节点编辑(节点的添加、删除、移动、保存),管线编辑(管线的添加、删除、移动、保存)。 h)管线可视化分析功能:不同类型(如三通、四通、弯头等,参见附件2)的管线节点用不同的颜色符号表示,不同材质(如钢、铸铁等,参见附件2)的管线段用不同颜色表示,此功能的实现需要很好地组织管线探测数据及其与管线的关联关系。 i)对管线、管线节点进行缓冲区构建,分析参数要求界面交互设定。 j)基于建立的供水几何网络,进行简单的最短路径分析。此功能为选作功能项,学有余力的同学可研究如何实现。 k)开发的实验系统要求有登录界面,且输入正确的用户名密码后,才能看到主界面。用户名登录认证要求基于数据库方式实现,需要在个人地理数据库中要建立一张用户表,表中包含用户名密码字段。 3.利用C#ArcEngine实现上述功能:每个学生利用大三上学期课程“GIS应用开发”所学内容独立完成上述功能的开发这是实习编程要求。以下是form1界面的代码using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Display; namespace WaterPipelineGIS2 { public partial class Form1 : Form { private IFeatureLayer _selectedFeatureLayer; private System.Drawing.Point _lastRightClickPosition; private enum SelectionMode { None, Rectangle, Circle, Polygon, Polyline } private SelectionMode currentMode = SelectionMode.None; private IPolygon tempPolygon; private IElement tempElement; public Form1() { InitializeComponent(); axMapControl1.OnMouseMove += new IMapControlEvents2_Ax_OnMouseMoveEventHandler(axMapControl1_OnMouseMove); } private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { // 获取地图坐标 double mapX = e.mapX; double mapY = e.mapY; // 格式化坐标显示(保留3位小数) lblCoordinate.Text = string.Format("X: {0:F3} Y: {1:F3}", mapX, mapY); // 立即刷新状态栏 statusStrip1.Refresh(); } private void toolStripMenuItem2_Click(object sender, EventArgs e) { using (var rotateForm = new RotateForm()) { if (rotateForm.ShowDialog() == DialogResult.OK) { try { axMapControl1.Rotation = rotateForm.RotationAngle; axMapControl1.ActiveView.Refresh(); // 可选:更新状态栏 lblCoordinate.Text += " 旋转角度:{rotateForm.RotationAngle}°"; } catch (Exception ex) { MessageBox.Show("旋转失败:{ex.Message}"); } } } } private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 2) // 右键 { // 保存点击位置(控件坐标系) _lastRightClickPosition = new System.Drawing.Point(e.x, e.y); ITOCControl2 tocControl = (ITOCControl2)axTOCControl1.Object; // 修改点1:声明为接口类型并初始化为null IBasicMap basicMap = null; ILayer layer = null; // 修改点2:使用Type.Missing代替new object() object other = Type.Missing; object index = Type.Missing; esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; // 修改点3:正确传递ref参数 tocControl.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref other, ref index); if (itemType == esriTOCControlItem.esriTOCControlItemLayer && layer != null) { contextMenuStripTOC.Show(axTOCControl1, e.x, e.y); } } } // 修改后(使用 MouseEventArgs) private void openAttributeTableToolStripMenuItem_Click(object sender, EventArgs e) { ITOCControl2 tocControl = (ITOCControl2)axTOCControl1.Object; IBasicMap basicMap = null; ILayer layer = null; object other = Type.Missing; object index = Type.Missing; esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; // 使用保存的控件坐标系位置 tocControl.HitTest( _lastRightClickPosition.X, _lastRightClickPosition.Y, ref itemType, ref basicMap, ref layer, ref other, ref index ); IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer != null) { _selectedFeatureLayer = featureLayer; // 确保使用正确的构造函数 AttributeTableForm attrForm = new AttributeTableForm( _selectedFeatureLayer, axMapControl1.Object as IMapControl2 ); attrForm.Show(); } else { MessageBox.Show("请选择有效的要素图层!"); } } private void SetSelectionSymbol() { // 使用接口创建符号 ISimpleFillSymbol fillSymbol = new SimpleFillSymbol() as ISimpleFillSymbol; fillSymbol.Color = GetRgbColor(255, 0, 0); fillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; ISimpleLineSymbol lineSymbol = new SimpleLineSymbol() as ISimpleLineSymbol; lineSymbol.Color = GetRgbColor(255, 255, 0); lineSymbol.Width = 2; fillSymbol.Outline = lineSymbol; // 设置渲染器 if (_selectedFeatureLayer != null) { IGeoFeatureLayer geoLayer = (IGeoFeatureLayer)_selectedFeatureLayer; ISimpleRenderer renderer = new SimpleRenderer() as ISimpleRenderer; renderer.Symbol = (ISymbol)fillSymbol; geoLayer.Renderer = (IFeatureRenderer)renderer; axMapControl1.ActiveView.Refresh(); } } private IRgbColor GetRgbColor(int r, int g, int b) { IRgbColor color = new RgbColor() as IRgbColor; // 正确方式 color.Red = r; color.Green = g; color.Blue = b; return color; } } }现在我想实现d)空间选择功能:可以绘制矩形、圆形、多边形、折线进行地理要素的选择。我目前在功能菜单添加了“空间选择”,里面有五个选项:“绘制矩形选择”“绘制圆形选择”“绘制多边形选择”“绘制折线选择”“清除选择“。我想的是点击这五个选择,右边的mapcontrol(名为axMapControl1)控件显示的地图图层可以开始绘制进行选择,给出完整的代码
07-12
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Display; namespace WaterPipelineGIS2 { public partial class Form1 : Form { private IFeatureLayer _selectedFeatureLayer; private System.Drawing.Point _lastRightClickPosition; public Form1() { InitializeComponent(); axMapControl1.OnMouseMove += new IMapControlEvents2_Ax_OnMouseMoveEventHandler(axMapControl1_OnMouseMove); } private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { // 获取地图坐标 double mapX = e.mapX; double mapY = e.mapY; // 格式化坐标显示(保留3位小数) lblCoordinate.Text = string.Format("X: {0:F3} Y: {1:F3}", mapX, mapY); // 立即刷新状态栏 statusStrip1.Refresh(); } private void toolStripMenuItem2_Click(object sender, EventArgs e) { using (var rotateForm = new RotateForm()) { if (rotateForm.ShowDialog() == DialogResult.OK) { try { axMapControl1.Rotation = rotateForm.RotationAngle; axMapControl1.ActiveView.Refresh(); // 可选:更新状态栏 lblCoordinate.Text += " 旋转角度:{rotateForm.RotationAngle}°"; } catch (Exception ex) { MessageBox.Show("旋转失败:{ex.Message}"); } } } } private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 2) // 右键 { // 保存点击位置(控件坐标系) _lastRightClickPosition = new System.Drawing.Point(e.x, e.y); ITOCControl2 tocControl = (ITOCControl2)axTOCControl1.Object; // 修改点1:声明为接口类型并初始化为null IBasicMap basicMap = null; ILayer layer = null; // 修改点2:使用Type.Missing代替new object() object other = Type.Missing; object index = Type.Missing; esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; // 修改点3:正确传递ref参数 tocControl.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref other, ref index); if (itemType == esriTOCControlItem.esriTOCControlItemLayer && layer != null) { contextMenuStripTOC.Show(axTOCControl1, e.x, e.y); } } } // 修改后(使用 MouseEventArgs) private void openAttributeTableToolStripMenuItem_Click(object sender, EventArgs e) { ITOCControl2 tocControl = (ITOCControl2)axTOCControl1.Object; IBasicMap basicMap = null; ILayer layer = null; object other = Type.Missing; object index = Type.Missing; esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; // 使用保存的控件坐标系位置 tocControl.HitTest( _lastRightClickPosition.X, _lastRightClickPosition.Y, ref itemType, ref basicMap, ref layer, ref other, ref index ); IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer != null) { _selectedFeatureLayer = featureLayer; // 确保使用正确的构造函数 AttributeTableForm attrForm = new AttributeTableForm( _selectedFeatureLayer, axMapControl1.Object as IMapControl2 ); attrForm.Show(); } else { MessageBox.Show("请选择有效的要素图层!"); } } private void SetSelectionSymbol() { // 使用接口创建符号 ISimpleFillSymbol fillSymbol = new SimpleFillSymbol() as ISimpleFillSymbol; fillSymbol.Color = GetRgbColor(255, 0, 0); fillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; ISimpleLineSymbol lineSymbol = new SimpleLineSymbol() as ISimpleLineSymbol; lineSymbol.Color = GetRgbColor(255, 255, 0); lineSymbol.Width = 2; fillSymbol.Outline = lineSymbol; // 设置渲染器 if (_selectedFeatureLayer != null) { IGeoFeatureLayer geoLayer = (IGeoFeatureLayer)_selectedFeatureLayer; ISimpleRenderer renderer = new SimpleRenderer() as ISimpleRenderer; renderer.Symbol = (ISymbol)fillSymbol; geoLayer.Renderer = (IFeatureRenderer)renderer; axMapControl1.ActiveView.Refresh(); } } private IRgbColor GetRgbColor(int r, int g, int b) { IRgbColor color = new RgbColor() as IRgbColor; // 正确方式 color.Red = r; color.Green = g; color.Blue = b; return color; } public object _featureLayer { get; set; } } }三、实习内容 第一部分: 1.供水管线数据的处理:根据某厂区供水管线图(Shapefile格式,见附件1)、供水管道探测数据(见附件2)组织好供水管线的空间与属性数据,建立基于ArcGIS个人地理数据库的供水管网的几何网络模型(有兴趣的同学可以考虑建立基于SQL Server的空间数据库),即网络数据集;将管线图形数据与探测属性数据关联起来;编制相应的MXD地图文档;为后续功能实现打基础。 2.供水管网地理信息系统的功能模块设计与界面设计:根据供水管网地理信息系统功能需求划分好系统的功能模块,并进行系统界面设计,包括菜单、工具条、状态栏等设计。在设计各功能模块界面时,要考虑各窗体间的相互关系。功能需求如下: a)基本GIS操作功能:地图显示、放大、缩小、平移(放大、缩小、平移等工具的图标后面需要显示中文字符)、滚轮缩放、鹰眼导航、地图按某一给定的角度旋转,鼠标位置坐标的状态栏实时显示,地图缩放比例状态栏显示。 b)地图加载功能:加载Mxd地图文档、添加Shapefile图层文件。 c)图层控制功能:图层显示与否,图层对应图形的居中显示,打开图层属性表,属性表中切换记录时当前记录的图形高亮定位、闪烁与居中显示3个功能。 d)空间选择功能:可以绘制矩形、圆形、多边形、折线进行地理要素的选择。 e)空间量测功能:可进行多边形面积与周长量测、折线周长量测、点的坐标量测。 f)空间查询功能:图形与其属性的综合查询,包括构建表达式查询图形及属性、按管线节点类型(如三通、四通、弯头等,参见附件2)查询节点属性及相应图形、点击图形查其对应的属性信息、根据管径大小查询其空间位置及属性信息、按照材质查询相应的管线节点位置及其属性、按照附属物类型查询管线节点空间位置及属性信息。 g)图形编辑功能:管线节点编辑(节点的添加、删除、移动、保存),管线编辑(管线的添加、删除、移动、保存)。 h)管线可视化分析功能:不同类型(如三通、四通、弯头等,参见附件2)的管线节点用不同的颜色符号表示,不同材质(如钢、铸铁等,参见附件2)的管线段用不同颜色表示,此功能的实现需要很好地组织管线探测数据及其与管线的关联关系。 i)对管线、管线节点进行缓冲区构建,分析参数要求界面交互设定。 j)基于建立的供水几何网络,进行简单的最短路径分析。此功能为选作功能项,学有余力的同学可研究如何实现。 k)开发的实验系统要求有登录界面,且输入正确的用户名密码后,才能看到主界面。用户名登录认证要求基于数据库方式实现,需要在个人地理数据库中要建立一张用户表,表中包含用户名密码字段。 3.利用C#ArcEngine实现上述功能:每个学生利用大三上学期课程“GIS应用开发”所学内容独立完成上述功能的开发我现在想要实现d)空间选择功能:可以绘制矩形、圆形、多边形、折线进行地理要素的选择。我现在就是功能菜单打开,点击空间选择,点击绘制矩形选择、绘制圆形选择、绘制多边形选择、绘制折线选择。从而进行选择,给出完整代码以及操作流程
07-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值