ArcGIS Engine 开发(一)对地图放大、缩

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

二:运行效果:

三:源代码如下:

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 开发(一)对地图放大、缩

相关文章:

你感兴趣的文章:

标签云: