想实现这么个功能,选择某个要素,然后弹出气泡,气泡中显示该要素的基本信息,类似identify功能,在这个功能中用到了SceneControl.ObjectSelected 及Bubble几个主要相关接口与方法,首先说说ObjectSelected的问题,感觉很多时候ObjectSelected不敏感,一会儿选的中一会儿选不中,我地图上的要素是一个模型点符号,特别是在地形不平的地方,当此模型浮在空中不贴地的情况很难选中。其次问题是气泡的选中问题,大部分时间气泡总是显示在选中的要素旁边,但有时候莫名其妙不见显示,体验太差,不知是代码有问题还是什么原因,调试没发现问题。上代码:
private void ScenceControl_ObjectSelected(object sender, ObjectSelectedEventArgs e)
{
Selection3D selection = sitelayer.Selection;
if(selection.Count > 0)
{
scenceControl.Bubbles.Clear();
Recordset rs= selection.ToRecordset();
rs.MoveFirst();
Feature feature = rs.GetFeature();
Geometry geo = feature.GetGeometry();
siteinfo.LabelSiteNO.Text = feature.GetString("SITENO");
siteinfo.picpath = String.Format("pic\\{0}.JPG", feature.GetString("SITENO"));
Bubble bubble = new Bubble();
scenceControl.Bubbles.Add(bubble);
bubble.Visible = true;
Point3D point3D = new Point3D(geo.InnerPoint.X,
geo.InnerPoint.Y, 30);
bubble.Pointer = point3D;
scenceControl.Scene.Refresh();
// bubble.Title = "站点信息";
bubble.RoundQuality = 1;
bubble.IsAutoHide = true;
bubble.FrameWidth = 10;
bubble.BackColor = Color.FromArgb(100, 185, 230, 253);
bubble.ClientWidth = siteinfo.Width;
bubble.ClientHeight = siteinfo.Height;
TextStyle textStyle = new TextStyle();
textStyle.Alignment = SuperMap.Data.TextAlignment.TopCenter;
textStyle.FontName = "黑体";
textStyle.ForeColor = Color.Black;
bubble.TitleTextStyle = textStyle;
System.Drawing.Point point = new Point(bubble.ClientLeft, bubble.ClientTop);
siteinfo.Visible = true;
siteinfo.Location = point;
rs.Close();
rs.Dispose();
}
private void ScenceControl_BubbleClose(object sender, BubbleEventArgs e)
{
siteinfo.Visible = false;
}
private void ScenceControl_BubbleResize(object sender, BubbleEventArgs e)
{
System.Drawing.Point point = new Point(e.Bubble.ClientLeft, e.Bubble.ClientTop);
siteinfo.Location = point;
siteinfo.Visible = true;
}
private void ScenceControl_BubbleInitialize(object sender, BubbleEventArgs e)
{
System.Drawing.Point point = new Point(e.Bubble.ClientLeft, e.Bubble.ClientTop);
siteinfo.Location = point;
siteinfo.Visible = true;
}
总的来说,体验好差,求大神指导,坐等