c#arcgis二次开发

arcgis engine&c# 学习使用

加载shp文件


  OpenFileDialog OpFileDialog=new OpenFileDialog();//OpenFileDialog:打开文件对话框
    OpFileDialog.Title="添加矢量数据";
    OpFileDialog.Filter="(*.shp)|*.shp";//filter:过滤器;"(*.shp)|*.shp":筛掉其他数据,只留下shp数据
    if (OpFileDialog.ShowDialog()==DialogResult.OK)//判断打开的当前选择数据的窗口,有没有点击“确定”按钮
    {
        string fullpath=OpFileDialog.FileName;
        string path=fullpath.Substring(0,fullpath.LastIndexOf("\\"));//从路径fullpath中检索子字符串,从开始截取到最后一个“\”
        string name=fullpath.Substring(fullpath.LastIndexOf("\\")+1);//从最后一个“\”的后一个开始,到最后(省略不写,默认到最后)
        axMapControl1.AddShapeFile(path,name);//AddShapeFile:加载shp文件的工具
        axMapControl1.Refresh();//刷新一下界面
    }

地图拉框放大功能:

ICommand command = new ControlsMapZoomInTool();
command.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = command as ITool;

地图拉框缩小功能:

ICommand command = new ControlsMapZoomOutTool();
command.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = command as ITool;

地图固定放大功能:

axMapControl1.CurrentTool = null;
IEnvelope pEnvelope = axMapControl1.Extent;
pEnvelope.Expand(0.5, 0.5, true);
axMapControl1.Extent = pEnvelope;
axMapControl1.Refresh();

地图固定缩小功能:

axMapControl1.CurrentTool = null;
IEnvelope pEnvelope = axMapControl1.Extent;
pEnvelope.Expand(2, 2, true);
axMapControl1.Extent = pEnvelope;
axMapControl1.Refresh();

地图全图功能:

axMapControl1.CurrentTool = null;
ICommand command = new ControlsMapFullExtentCommand();
command.OnCreate(axMapControl1.Object);
command.OnClick();

地图漫游功能:

ICommand command = new ControlsMapPanTool();
command.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = command as ITool;

地图选择要素功能:

ICommand command = new ControlsSelectFeaturesTool();
command.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = command as ITool;

地图取消选择要素功能:

axMapControl1.CurrentTool = null;
ICommand command = new ControlsClearSelectionCommand();
command.OnCreate(axMapControl1.Object);
command.OnClick();

地图标识要素功能:

ICommand command = new ControlsMapIdentifyTool();
command.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = command as ITool;

地图测量功能:

ICommand command = new ControlsMapMeasureTool();
command.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = command as ITool;

此外相关的小功能子类还有许多,可以查阅官网ICommand 类方法,官网ICommand类地址:

https://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//00430000001s000000
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是C# ArcGIS二次开发的一些基本知识和实现方法: 1. ArcGIS Engine是一个用于构建桌面GIS应用程序的开发平台,它提供了一系列的API和工具,可以帮助开发人员快速构建出高效、功能强大的GIS应用程序。 2. 在C#中进行ArcGIS Engine开发,需要先安装ArcObjects SDK,并在Visual Studio中创建一个ArcGIS Engine项目。 3. 在ArcGIS Engine开发中,常用的控件包括MapControl、PageLayoutControl、ToolbarControl、TOCControl等,它们可以帮助我们实现地图显示、地图操作、图层管理等功能。 4. 在ArcGIS Engine开发中,常用的功能包括地图显示、地图操作、图层管理、符号化、查询分析等,这些功能都可以通过ArcObjects API来实现。 5. 在ArcGIS Engine开发中,常用的开发语言包括C#、VB.NET等,其中C#是比较常用的一种语言。 6. 在ArcGIS Engine开发中,常用的开发工具包括Visual Studio、ArcGIS Desktop等,其中Visual Studio是比较常用的一种工具。 以下是一个简单的C# ArcGIS Engine开发实例,用于显示一个地图: ```csharp using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.Carto; public partial class Form1 : Form { private IMapControl3 m_mapControl; public Form1() { InitializeComponent(); m_mapControl = axMapControl1.Object as IMapControl3; } private void Form1_Load(object sender, EventArgs e) { string mapDocumentPath = @"C:\data\test.mxd"; if (axMapControl1.CheckMxFile(mapDocumentPath)) { axMapControl1.LoadMxFile(mapDocumentPath); axMapControl1.Refresh(); } } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

a勇学java

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值