码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-04-02 15:13:21      阅读:384      评论:0      收藏:0      [点我收藏+]

标签:地图   放大 缩小   漫游 全局等功能   源代码   

一:实现功能:地图放大、缩小、漫游、全局

二:运行效果:

技术分享

三:源代码如下:

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


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

标签:地图   放大 缩小   漫游 全局等功能   源代码   

原文地址:http://blog.csdn.net/vector5210/article/details/44831019

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!