ArcGIS engineeC#演示点从一个坐标移动向另一个坐标的过程
时间: 2023-09-16 10:12:53 浏览: 50
好的,这个问题我可以回答。下面是一个简单的示例,演示如何将一个点从一个坐标移动到另一个坐标的过程。在这个示例中,我们使用ArcGIS Engine的AxMapControl控件来显示地图,使用AxMapControl控件的DrawPoint方法来绘制点,使用IPoint接口来表示点,使用IPointCollection接口来表示点集合,使用IPoint.Move方法来移动点。
```csharp
private ESRI.ArcGIS.Controls.AxMapControl axMapControl1;
private ESRI.ArcGIS.Geometry.IPoint point;
private void Form1_Load(object sender, EventArgs e)
{
// 初始化地图
axMapControl1.Map.ClearLayers();
axMapControl1.LoadMxFile(@"C:\path\to\your\map.mxd");
// 初始化点
point = new ESRI.ArcGIS.Geometry.PointClass();
point.PutCoords(-118.15, 34.02);
point.SpatialReference = axMapControl1.SpatialReference;
// 绘制点
axMapControl1.DrawPoint(point, null);
}
private void button1_Click(object sender, EventArgs e)
{
// 移动点
ESRI.ArcGIS.Geometry.IPoint newPoint = new ESRI.ArcGIS.Geometry.PointClass();
newPoint.PutCoords(-118.12, 34.04);
newPoint.SpatialReference = axMapControl1.SpatialReference;
point.Move(newPoint.X - point.X, newPoint.Y - point.Y);
// 清除原始点并绘制移动后的点
axMapControl1.Map.ClearSelection();
axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
axMapControl1.DrawPoint(point, null);
axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
}
```
在这个示例中,我们在窗体加载时初始化了一个点,并使用AxMapControl控件的DrawPoint方法将其绘制在地图上。在单击按钮时,我们创建了一个新的点,并使用IPoint.Move方法将原始点移动到新位置。然后,我们清除原始点并重新绘制移动后的点。
希望这个示例对你有所帮助!