zoukankan      html  css  js  c++  java
  • 1. AE二次开发——地图的基本操作(加载地图文档,加载shape,加载mdb,地图的保存,缩放,漫游)

    1. 加载数据Icommand方法

    ICommand Butdata = new ControlsAddDataCommandClass();
    Butdata.OnCreate(axMapControl1.Object);
    Butdata.OnClick();
    axMapControl1.CurrentTool = Butdata as ITool;

    2.加载mxd地图文档

    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.CheckFileExists = true;
    openFileDialog.Title = "打开地图文档";
    openFileDialog.Filter = "地图文档(*.mxd)|*.Mxd|地图模板(*.mxt)|*.Mxt";
    openFileDialog.Multiselect = false;
    openFileDialog.RestoreDirectory = true;
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
    string sFileName = openFileDialog.FileName;
    axMapControl1.LoadMxFile(sFileName);
    }

    3.加载shape

    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.CheckFileExists = true;
    openFileDialog.Title = "打开shp";
    openFileDialog.Filter = "Shapefile(*.shp)|*.shp";
    openFileDialog.Multiselect = true;
    openFileDialog.RestoreDirectory = true;
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
    FileInfo fileinfo = new FileInfo(openFileDialog.FileName);
    string path = fileinfo.Directory.ToString();
    string filename = fileinfo.Name.Substring(0, fileinfo.Name.IndexOf("."));
    try
    {
    axMapControl1.AddShapeFile(path, filename);
    }
    catch (Exception ce)
    {
    MessageBox.Show("添加失败!" + ce.ToString());
    }

    }

    3.加载mdb

    为完成

    4.保存

    try
    {
    string sMxdFileName = axMapControl1.DocumentFilename;
    IMapDocument pMapDocument = new MapDocumentClass();
    if (sMxdFileName != null && axMapControl1.CheckMxFile(sMxdFileName))
    {
    if (pMapDocument.get_IsReadOnly(sMxdFileName))
    {
    MessageBox.Show("本地图文档是只读,不能保存");
    pMapDocument.Close();
    return;
    }
    }
    else
    {
    SaveFileDialog pSaveFileDialog = new SaveFileDialog();
    pSaveFileDialog.Title = "选择保存路径";
    pSaveFileDialog.OverwritePrompt = true;
    pSaveFileDialog.Filter = "ArcMap文档(*.mxd)|*.mxd|ArcMap模板(*.mxt)|*.mxt";
    pSaveFileDialog.RestoreDirectory = true;
    if (pSaveFileDialog.ShowDialog() == DialogResult.OK)
    {
    sMxdFileName = pSaveFileDialog.FileName;
    }
    else
    {
    return;
    }
    }
    pMapDocument.New(sMxdFileName);
    pMapDocument.ReplaceContents(axMapControl1.Map as IMxdContents);
    pMapDocument.Save(pMapDocument.UsesRelativePaths, true);
    pMapDocument.Close();
    MessageBox.Show("保存文档成功");

    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }

    5.另存为

    try
    {
    SaveFileDialog psaveFileDialog = new SaveFileDialog();
    psaveFileDialog.Title = "另存为";
    psaveFileDialog.OverwritePrompt = true;
    psaveFileDialog.Filter = "ArcMap文档(*mxd)|*.mxd|ArcMap模板(*.mxt)|*.mxt";
    psaveFileDialog.RestoreDirectory = true;
    if (psaveFileDialog.ShowDialog() == DialogResult.OK)
    {
    string sFilePath = psaveFileDialog.FileName;
    IMapDocument pMapDocument = new MapDocumentClass();
    pMapDocument.New(sFilePath);
    pMapDocument.ReplaceContents(axMapControl1.Map as IMxdContents);
    pMapDocument.Save(true, true);
    pMapDocument.Close();
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }

    6.地图缩放(放大,缩小)


    ICommand Zoomin = new ControlsMapZoomInToolClass();
    Zoomin.OnCreate(axMapControl1.Object);
    Zoomin.OnClick();
    axMapControl1.CurrentTool = (ITool)Zoomin;

    ICommand Zoomout = new ControlsMapZoomOutToolClass();
    Zoomout.OnCreate(axMapControl1.Object);
    Zoomout.OnClick();
    axMapControl1.CurrentTool = (ITool)Zoomout;

    7.地图漫游

    ICommand Pan = new ControlsMapPanToolClass();
    Pan.OnCreate(axMapControl1.Object);
    Pan.OnClick();
    axMapControl1.CurrentTool = (ITool)Pan;

    8.全图显示

    ICommand Full = new ControlsMapFullExtentCommandClass();
    Full.OnCreate(axMapControl1.Object);
    Full.OnClick();

    9.属性查询

    ICommand Identify = new ControlsMapIdentifyToolClass();
    Identify.OnCreate(axMapControl1.Object);
    Identify.OnClick();
    axMapControl1.CurrentTool = (ITool)Identify;

  • 相关阅读:
    Javascript高级编程学习笔记(32)—— 客户端检测(1)能力检测
    Javascript高级编程学习笔记(31)—— BOM(5)screen、history对象
    Javascript高级编程学习笔记(30)—— BOM(4)navigator对象
    Javascript高级编程学习笔记(29)—— BOM(3)location对象
    Javascript高级编程学习笔记(28)—— BOM(2)window对象2
    Javascript高级编程学习笔记(27)—— BOM(1)window对象1
    逆向与反汇编工具
    Silicon Labs
    sk_buff 里的len, data_len, skb_headlen
    IP分片重组的分析和常见碎片攻击 v0.2
  • 原文地址:https://www.cnblogs.com/bby2014210552/p/6226554.html
Copyright © 2011-2022 走看看