计算机、visual studio 软件、ArcGIS engine 开发包
(2)安装ArcGIS Engine 10.2,选择以下路径中的ESRI.exe 点击安装:
(3)打开ArcGIS管理器导向,选择ArcGIS Engine浮动:
(2)选择需要添加的ArcGIS引用项,在【License Checking】选项页中选择需要的软件许可授权和扩展模块许可授权。
(3)在【工具箱】面板中找到【ArcGIS Windows Forms】选项卡,此选项卡中包含有ArcGIS Engine中所有的可视化控件,选择需要的控件添加到【gis3.1】窗体中。
(5)选中TOCControl控件,单击鼠标右键,选择【属性】,弹出对话框,在【General】选项卡的“Buddy”下拉列表中选择与其绑定的MapControl地图控件,这样当程序运行时TOCControl控件才可以与地图控件进行联动。
(6)选中MapControl控件,单击鼠标右键,选择【属性】,弹出对话框,在对话框中选择程序运行时加载的*.mxd地图文档,点击【确定】按钮完成对*.mxd文档的关联。
(2)分别实现对应按钮的事件响应代码:
///
/// 工具条
///
///
///
/// 打开文件夹
private void buttonI_opendata_Click(object sender, EventArgs e)
{
ICommand pcommand = new ControlsAddDataCommandClass();
pcommand.OnCreate(axMapControl1.Object);
pcommand.OnClick();
updatalayernametoconbox();
}
///
/// 默认鼠标
///
///
///
private void buttonI_default_Click(object sender, EventArgs e)
{
if (m_ControlsSynchronizer.ActiveViewType == "MapControl")
{
axMapControl1.CurrentTool = null;
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
}
else
{
axPageLayoutControl1.CurrentTool = null;
axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
}
}
///
/// 漫游
///
///
///
private void buttonI_pan_Click(object sender, EventArgs e)
{
if (m_ControlsSynchronizer.ActiveViewType == "MapControl")
{
ICommand pcommand = new ControlsMapPanToolClass();
pcommand.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = pcommand as ITool;
}
else
{
ICommand pcommand = new ControlsMapPanToolClass();
pcommand.OnCreate(axPageLayoutControl1.Object);
axPageLayoutControl1.CurrentTool = pcommand as ITool;
}
}
///
/// 放大
///
///
///
private void buttonI_zoomin_Click(object sender, EventArgs e)
{
if (m_ControlsSynchronizer.ActiveViewType == "MapControl")
{
ICommand pcommand = new ControlsMapZoomInToolClass();
pcommand.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = pcommand as ITool;
}
else
{
ICommand pcommand = new ControlsMapZoomInToolClass();
pcommand.OnCreate(axPageLayoutControl1.Object);
axPageLayoutControl1.CurrentTool = pcommand as ITool;
}
}
///
/// 缩小
///
///
///
private void buttonI_zoomout_Click(object sender, EventArgs e)
{
if (m_ControlsSynchronizer.ActiveViewType == "MapControl")
{
ICommand pcommand = new ControlsMapZoomOutToolClass();
pcommand.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = pcommand as ITool;
}
else
{
ICommand pcommand = new ControlsMapZoomOutToolClass();
pcommand.OnCreate(axPageLayoutControl1.Object);
axPageLayoutControl1.CurrentTool = pcommand as ITool;
}
}
///
/// 全局
///
///
///
private void buttonI_fullscreen_Click(object sender, EventArgs e)
{
ICommand pcommand = new ControlsMapFullExtentCommandClass();
pcommand.OnCreate(axMapControl1.Object);
pcommand.OnClick();
}
///
/// 前一视图
///
///
///
private void buttonI_preview_Click(object sender, EventArgs e)
{
if (m_ControlsSynchronizer.ActiveViewType == "MapControl")
{
ICommand pcommand = new ControlsMapZoomToLastExtentForwardCommandClass();
pcommand.OnCreate(axMapControl1.Object);
pcommand.OnClick();
}
else
{
ICommand pcommand = new ControlsMapZoomToLastExtentForwardCommandClass();
pcommand.OnCreate(axPageLayoutControl1.Object);
pcommand.OnClick();
}
}
///
/// 后一视图
///
///
///
private void buttonI_aftview_Click(object sender, EventArgs e)
{
if (m_ControlsSynchronizer.ActiveViewType == "MapControl")
{
ICommand pcommand = new ControlsMapZoomToLastExtentBackCommandClass();
pcommand.OnCreate(axMapControl1.Object);
pcommand.OnClick();
}
else
{
ICommand pcommand = new ControlsMapZoomToLastExtentBackCommandClass();
pcommand.OnCreate(axPageLayoutControl1.Object);
pcommand.OnClick();
}
}
///
/// 测量
///
///
///
private void buttonI_measure_Click(object sender, EventArgs e)
{
ICommand pcommand = new ControlsMapMeasureToolClass();
pcommand.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = pcommand as ITool;
}
///
/// 鼠标移动显示坐标
///
///
///
private void axMapControl1_OnMouseMove(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e)
{
toolStripStatusLabel2.Text = "x=" + e.mapX.ToString() + ",y=" + e.mapY.ToString();
if (axMapControl1.LayerCount != 0)
{
//ShowTips显示的要素类
IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
if (pFeatureLayer is IFeatureLayer)
{
pFeatureLayer.DisplayField = "DDMM"; //ShowTips显示的字段名称
//pFeatureLayer.DisplayField = "Shape";
//pFeatureLayer.DisplayField = "OBJECTID";
//pFeatureLayer.DisplayField = "Shape_Leng";
//pFeatureLayer.DisplayField = "Shape_Area";
//将两个ShowTips属性设置为true
pFeatureLayer.ShowTips = true;
axMapControl1.ShowMapTips = true;
}
}
}
1.学会了在Visual Studio中安装部署ArcGIS engine,并且使用ArcGIS控件创建一个小程序。
2.学会了使用ArcGIS控件创建一个工具条,以及自己创建一个工具条两种方法。
3.对ArcGIS engine的理解进一步加深。