GIS实验报告课件Word文档格式.docx
《GIS实验报告课件Word文档格式.docx》由会员分享,可在线阅读,更多相关《GIS实验报告课件Word文档格式.docx(11页珍藏版)》请在冰豆网上搜索。
三、源程序代码...............................................................................................................................7
四、心得体会.................................................................................................................................14
一、程序运行演示
1.新建项目文件,并实现file中的基本功能,显示地图基本要素。
如图1
图1
2.在工具栏加载按钮,按钮功能是对当前视图缩小3倍;
在工具栏加载工具,工
具功能在地图上标注当前日期。
如图2
2
图2
按钮实现缩小3倍功能操作,如图3
图3
3.点击地图节点,弹出如图4,图5菜单并实现菜单中的内容:
图4
3
图5
4.点击图层节点,弹出如图6菜单并需要实现菜单中的内容
图6
5.点击LegendClass,弹出符号选择对话框,该对话框供用户按需要选择符号
并进行更改。
如图7
4
图7
6.打开图层属性表,用户选择某条记录,可弹出如图8,9所示的右键菜单,并实
现右键菜单中的内容
5
图8
图9
二、问题及解决方案
问题1.VS2008与2010之间要进行格式转换,按照所导向的步骤进行,否则程序
将无法正常运行,出现错误
问题2.构建好基本框架后,地图文档中要素显示出现问题。
此问题要添加licence控件,否则无法显示地图要素。
问题3.使用Toolbar和Toc功能时无法进行操作
此问题应在属性设置时建立关联功能。
问题4.程序Program文件中要添加相应功能键语句,否则将无法实现功能。
问题5.引用接口,方法,例如ADF,要添加相应的引用,否则程序出现错误。
问题6.在实现两个自定义按钮与工具时,遇到的问题:
先直接引用现有项未实
现,发现缺少一些东西,后自己直接创建的Basetool和Basecomman类d;
在代码
中报错,重新生成解决方案后顺利解决这个问题。
问题7.在实现地图和图层节点的右键功能时,遇到琐碎的问题,在这个过程中
直接引用老师所给的几个类,但是报错,是因为命名空间未做修改;
缺少引用,
需要根据错误提示添加相应的引用
6
三、源程序代码
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.IO;
usingSystem.Runtime.InteropServices;
usingESRI.ArcGIS.esriSystem;
usingESRI.ArcGIS.Carto;
usingESRI.ArcGIS.Controls;
usingESRI.ArcGIS.ADF;
usingESRI.ArcGIS.SystemUI;
usingESRI.ArcGIS.Display;
namespaceWindowsFormsApplication2
{
publicpartialclassMainForm:
Form
#regionclassprivatemembers
privateIMapControl3m_mapControl=null;
privatestringm_mapDocumentName=string.Empty;
#endregion
IMapDocumentm_MapDocument=newMapDocument();
#regionclassconstructor
privateITOCControl2m_tocControl;
privateIToolbarMenum_menuMap;
privateIToolbarMenum_menuLayer;
privateZoomIn3XCMD1test=newZoomIn3XCMD1();
publicMainForm()
InitializeComponent();
}
privatevoidnewDocumentToolStripMenuItem_Click(objectsender,EventArgse)
7
ICommandcommand=newCreateNewDocument();
command.OnCreate(m_mapControl.Object);
command.OnClick();
privatevoidopenDocumentToolStripMenuItem_Click(objectsender,EventArgse)
openFileDialog1.Title="
SaveMapDocumentAs"
;
openFileDialog1.Filter="
MapDocuments(*.mxd)|*.mxd"
openFileDialog1.ShowDialog();
stringsFilePath=openFileDialog1.FileName;
if(axMapControl1.CheckMxFile(sFilePath))
axMapControl1.MousePointer=
esriControlsMousePointer.esriPointerHourglass;
axMapControl1.LoadMxFile(sFilePath,0,Type.Missing);
esriControlsMousePointer.esriPointerDefault;
else
MessageBox.Show(sFilePath+"
isnotavalidArcMapdocument"
);
return;
privatevoidMainForm_Load(objectsender,EventArgse)
//gettheMapControl
m_mapControl=(IMapControl3)axMapControl1.Object;
//disabletheSavemenu(sincethereisnodocumentyet)
this.menuSaveDoc.Enabled=false;
//定义地图右键菜单,图层右键菜单
m_tocControl=(ITOCControl2)axTOCControl1.Object;
//添加菜单到地图节点
m_menuMap=newToolbarMenu();
8
m_menuMap.AddItem("
esriControls.ControlsAdddataCommand"
-1,0,false,
esriCommandStyles.esriCommandStyleTextOnly);
m_menuMap.AddItem(newLayerVisibility(),1,1,false,
m_menuMap.AddItem(newLayerVisibility(),2,2,false,
//添加菜单到图层节点
m_menuLayer=newToolbarMenu();
m_menuLayer.AddItem(newOpenAttributeTableCmd(),-1,0,false,
esriCommandStyles.esriCommandStyleIconAndText);
//右键添加属性表
m_menuLayer.AddItem(newRemoveLayer(),1,1,false,
m_menuLayer.AddItem(newRemoveLayer(),1,2,true,
m_menuLayer.AddItem(newScaleThresholds(),2,3,false,
m_menuLayer.AddItem(newScaleThresholds(),3,4,false,
m_menuLayer.AddItem(newLayerSelectable(),1,5,true,
m_menuLayer.AddItem(newLayerSelectable(),2,6,false,
m_menuLayer.AddItem(newZoomToLayer(),-1,7,true,
//Setthehookofeachmenu
m_menuLayer.SetHook(m_mapControl);
m_menuMap.SetHook(m_mapControl);
axToolbarControl1.AddItem(test,-1,-1,true,0,
esriCommandStyles.esriCommandStyleI