GIS实验报告.docx
if (axMapControl1.CheckMxFile(sFilePath))
{
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;
axMapControl1.LoadMxFile(sFilePath, 0, Type.Missing);
private void MainForm_Load(object sender, EventArgs e)
{
//get the MapControl
m_mapControl = (IMapControl3)axMapControl1.Object;
//disable the Save menu (since there is no document yet)
图2
按钮实现缩小3倍功能操作,如图3
图3
3.点击地图节点,弹出如图4,图5菜单并实现菜单中的内容:
图4
图5
4.点击图层节点,弹出如图6菜单并需要实现菜单中的内容
图6
5.点击Legend Class,弹出符号选择对话框,该对话框供用户按需要选择符号并进行更改。如图7
图7
6.打开图层属性表,用户选择某条记录,可弹出如图8,9所示的右键菜单,并实现右键菜单中的内容
namespace WindowsFormsApplication2
{
public partial class MainForm : Form
{
#region class private members
private IMapControl3 m_mapControl = null;
private string m_mapDocumentName = string.Empty;
问题4.程序Program文件中要添加相应功能键语句,否则将无法实现功能。
问题5.引用接口,方法,例如ADF,要添加相应的引用,否则程序出现错误。
问题6.在实现两个自定义按钮与工具时,遇到的问题:先直接引用现有项未实现,发现缺少一些东西,后自己直接创建的Basetool和Basecommand类;在代码中报错,重新生成解决方案后顺利解决这个问题。
{
ICommand command = new CreateNewDocument();
command.OnCreate(m_mapControl.Object);
command.OnClick();
}
private ቤተ መጻሕፍቲ ባይዱoid openDocumentToolStripMenuItem_Click(object sender, EventArgs e)
#endregion
IMapDocument m_MapDocument = new MapDocument();
#region class constructor
private ITOCControl2 m_tocControl;
private IToolbarMenu m_menuMap;
private IToolbarMenu m_menuLayer;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
private ZoomIn3XCMD1 test = new ZoomIn3XCMD1();
public MainForm()
{
InitializeComponent();
}
private void newDocumentToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "Save Map Document As";
openFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";
openFileDialog1.ShowDialog();
string sFilePath = openFileDialog1.FileName;
图8
图9
二、问题及解决方案
问题1.VS2008与2010之间要进行格式转换,按照所导向的步骤进行,否则程序将无法正常运行,出现错误
问题2.构建好基本框架后,地图文档中要素显示出现问题。
此问题要添加licence控件,否则无法显示地图要素。
问题3.使用Toolbar和Toc功能时无法进行操作
此问题应在属性设置时建立关联功能。
实验报告
GIS应用软件开发
专业:测绘工程
班级:10级测绘三班
姓名:
学号:
指导教师:胡亚
撰写时间:2013年5月20日星期一
一、程序运行演示
1.新建项目文件,并实现file中的基本功能,显示地图基本要素。如图1
图1
2.在工具栏加载按钮,按钮功能是对当前视图缩小3倍;在工具栏加载工具,工具功能在地图上标注当前日期。如图2
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
}
else
{
MessageBox.Show(sFilePath + "is not a valid ArcMap document");
return;
}
}
问题7.在实现地图和图层节点的右键功能时,遇到琐碎的问题,在这个过程中直接引用老师所给的几个类,但是报错,是因为命名空间未做修改;缺少引用,需要根据错误提示添加相应的引用
三、源程序代码
using System;
using System.Collections.Generic;
using ponentModel;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.ADF;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Display;