- 积分
- 55960
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
发表于 2015-10-2 12:13:35
|
显示全部楼层
参考Demo程序代码,在MapView_MouseMove事件中加入判断鼠标在那个站点标注上面的代码,详细代码如下。只是简单的示例,可以根据自己的需求在此基础上修改。
private void MapView_MouseMove(object sender, MouseEventArgs e)
{
double ProjX, ProjY;
ProjX = 0;
ProjY = 0;
layersLegend1.ActiveMapFrame.MapView.ScreenToProj(ref ProjX, ref ProjY, e.X, e.Y);
if (layersLegend1.ActiveMapFrame.MapView.Projection.IsLonLatMap)
{
this.TSSL_Coord.Text = "Lon: " + ProjX.ToString("0.00") + "; Lat: " + ProjY.ToString("0.00");
}
else
{
string theText = this.TSSL_Coord.Text = "X: " + ProjX.ToString("0.0") + "; Y: " + ProjY.ToString("0.0");
if (layersLegend1.ActiveMapFrame.MapView.Projection.ProjInfo.Transform.ProjectionName == ProjectionNames.Robinson)
return;
ProjectionInfo toProj = KnownCoordinateSystems.Geographic.World.WGS1984;
ProjectionInfo fromProj = layersLegend1.ActiveMapFrame.MapView.Projection.ProjInfo;
double[][] points = new double[1][];
points[0] = new double[] { ProjX, ProjY };
//double[] Z = new double[1];
try
{
Reproject.ReprojectPoints(points, fromProj, toProj, 0, 1);
this.TSSL_Coord.Text = theText + " (Lon: " + points[0][0].ToString("0.00") + "; Lat: " +
points[0][1].ToString("0.00") + ")";
}
catch
{
//this.TSSL_Coord.Text = "X: " + ProjX.ToString("0.0") + "; Y: " + ProjY.ToString("0.0");
}
}
//Mouse on station labels
if (mapView1.MouseTool == MouseTools.SelectElements)
{
GraphicCollection tempGraphics = new GraphicCollection();
double lonShift = 0;
if (mapView1.SelectGraphics(new PointF(e.X, e.Y), ref tempGraphics, ref lonShift))
{
Graphic graphic = tempGraphics.GraphicList[0];
if (graphic.Legend.BreakType == BreakTypes.LabelBreak)
{
MessageBox.Show(((LabelBreak)graphic.Legend).Text);
}
}
}
}
|
|