ArcgisEngine实现对地图的放大、缩小和平移:
个人觉得是平移,不过网上的都是漫游,通俗的说就是把一个地图对象从一边拉到另一边而已。就看人说话吧.
具体实现:
一、引入命名空间
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Controls;
二、代码实现.
int flag = 0; private void 放大ToolStripMenuItem_Click(object sender, EventArgs e){ axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPageZoomIn; flag = 1; } private void 缩小ToolStripMenuItem_Click(object sender, EventArgs e){ axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPageZoomOut; flag = 2; } private void 平移ToolStripMenuItem_Click(object sender, EventArgs e){ axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPan; flag = 3; } private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e){ IEnvelope ipenv= axMapControl1.TrackRectangle(); if(flag==1){ axMapControl1.Extent = ipenv; }else if(flag==2){ ipenv = axMapControl1.Extent; ipenv.Expand(2, 2, true); axMapControl1.Extent = ipenv; }else if(flag==3){ ipenv= axMapControl1.Extent ; axMapControl1.Pan(); } } }
三、补充:
在AE中,在地图控件中添加.jpg,.bmp类型图层文件时,调用下面方法会简单很多的.
IRasterLayer rasterLayer = new RasterLayer(); rasterLayer.CreateFromFilePath(str); axMapControl1.AddLayer(rasterLayer, 0);
其中,str是文件路径.