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
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐