C#arcengine实现地图飞行到指定点
时间: 2024-01-17 13:04:40 浏览: 32
你可以使用 ArcEngine 中的 `IMapControl4` 接口来实现地图飞行到指定点。具体步骤如下:
1. 创建一个 `IMapControl4` 对象,并将其绑定到一个窗口控件上。
2. 获取地图中的 `IActiveView` 对象。
3. 创建一个 `IPoint` 对象,用来表示要飞行到的目标点的位置。
4. 使用 `IMapControl4` 接口中的 `Extent` 属性获取当前地图的范围。
5. 使用 `IEnvelope` 接口中的 `CenterAt` 方法,将地图范围移动到目标点,同时保持地图比例尺不变。
6. 使用 `IMapControl4` 接口中的 `Refresh` 方法,刷新地图显示。
以下是示例代码:
```c#
// 获取地图控件对象
IMapControl4 mapControl = axMapControl1.Object as IMapControl4;
// 获取地图的活动视图
IActiveView activeView = mapControl.ActiveView;
// 创建一个目标点对象
IPoint targetPoint = new PointClass();
targetPoint.PutCoords(114.26667, 30.58333); // 这里假设目标点的经纬度为(114.26667, 30.58333)
// 获取当前地图的范围
IEnvelope envelope = activeView.Extent;
// 将地图范围移动到目标点
envelope.CenterAt(targetPoint);
activeView.Extent = envelope;
activeView.Refresh();
```
这样,地图就会飞行到指定点的位置。