/// <summary>
/// 将显示坐标中的一个点转换为地图或图层坐标中的点。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mapControl1_MouseMove(object sender, MouseEventArgs e)
{
System.Drawing.PointF displayPoint = new PointF(e.X, e.Y);
MapInfo.Geometry.DPoint mapPoint = new MapInfo.Geometry.DPoint();
MapInfo.Geometry.DisplayTransform converter = this.mapControl1.Map.DisplayTransform;
converter.FromDisplay(displayPoint, out mapPoint);
this.textBox1.Text = "Cursor Location: " + mapPoint.x.ToString() + ", " + mapPoint.y.ToString();
}
/// 将显示坐标中的一个点转换为地图或图层坐标中的点。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mapControl1_MouseMove(object sender, MouseEventArgs e)
{
System.Drawing.PointF displayPoint = new PointF(e.X, e.Y);
MapInfo.Geometry.DPoint mapPoint = new MapInfo.Geometry.DPoint();
MapInfo.Geometry.DisplayTransform converter = this.mapControl1.Map.DisplayTransform;
converter.FromDisplay(displayPoint, out mapPoint);
this.textBox1.Text = "Cursor Location: " + mapPoint.x.ToString() + ", " + mapPoint.y.ToString();
}
本文介绍了一个方法,用于将显示坐标系中的点转换到地图坐标系中。通过使用MapInfo.Geometry库中的DisplayTransform类,实现了从屏幕坐标到地理坐标的转换,并在鼠标移动事件中实时更新光标位置。
4184

被折叠的 条评论
为什么被折叠?



