• 热门专题

ArcGISEngine开发(一)对地图放大 缩小 漫游 全局等功能

作者:  发布日期:2015-04-02 20:19:23
Tag标签:全局  功能  地图  
  • 一:实现功能:地图放大、缩小、漫游、全局

    二:运行效果:

    三:源代码如下:

     

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.Carto;
    using ESRI.ArcGIS.Controls;
    using ESRI.ArcGIS.SystemUI;
    using ESRI.ArcGIS.Geometry;
    
    
    namespace lesson4
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                loadMapDocument();
            }
            int flag = 0;
            //放大
            private void button1_Click(object sender, EventArgs e)
            {
                axMapControl1.MousePointer = esriControlsMousePointer.esriPointerZoomIn;
                flag = 2;
            }
            //缩小
            private void button2_Click(object sender, EventArgs e)
            {
                
                axMapControl1.MousePointer = esriControlsMousePointer.esriPointerZoomOut;
                flag = 1;
            }
            //漫游
            private void button3_Click(object sender, EventArgs e)
            {
                axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPan;
                flag = 3;
            }
            //全图
            private void button4_Click(object sender, EventArgs e)
            {
                axMapControl1.Extent  = axMapControl1.FullExtent ;
            }
            //加载地图文档
            private void loadMapDocument()
            {
                System.Windows.Forms.OpenFileDialog openFileDialog;
                openFileDialog = new OpenFileDialog();
                openFileDialog.Title = "打开地图文档";
                openFileDialog.Filter = "map documents(*.mxd)|*.mxd";
                openFileDialog.ShowDialog();
                string filePath = openFileDialog.FileName;
                if (axMapControl1.CheckMxFile(filePath))
                {
                    axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;
                    axMapControl1.LoadMxFile(filePath, 0, Type.Missing);
                    axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
                }
                else
                {
                    MessageBox.Show(filePath + "不是有效的地图文档");
                }
            }
    
           
    
            private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
            {
                ESRI.ArcGIS.Geometry.IEnvelope ipEnv;
                if (flag == 2)
                {
                    ipEnv = axMapControl1.TrackRectangle();
                    axMapControl1.Extent = ipEnv;
                }
                else if (flag == 1)
                {
                    //ipEnv = axMapControl1.TrackRectangle();
                    ipEnv = axMapControl1.Extent;
                    ipEnv.Expand(2,2, true);
                    axMapControl1.Extent = ipEnv;
                }
                else if (flag == 3)
                {
                    ipEnv = axMapControl1.Extent;
                    axMapControl1.Pan();
                }
    
            }
        }
    }

    完整的demo可以从我上传的资料下载,也可在线咨询qq937292955

     

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规