除了在SDK中写死输入的点线面之外,常用的就是绘制模式,绘制模式中,点的绘制比较麻烦,线面的绘制比较简单。
1.点的绘制
由于通常的绘制习惯都是鼠标左键打点,但是在日常的时候,左键经常会使用到,因此如果直接进行绘制点的话,不能区分是拖动地图还是进入绘制的状态。
1.1设置一个全局的点
Point Location_MouseDown;
1.2判定这个点是否就是绘制的点,即判定鼠标左键放下和抬起是否在同一个位置
globeControl1.Globe.Action = EnumAction3D.NormalHit;//鼠标浏览的状态
globeControl1.MouseUp += (sender2, e2) =>
{
Location_MouseDown = e2.Location;
};
globeControl1.MouseUp += (sender2, e2) =>
{
if (Location_MouseDown != e2.Location) return;
if (e2.Button == MouseButtons.Left)
1.3若果确认为是这个点,那么获取这个点,这个点作为一个要素,添加到内存图层中。
if (globeControl1.Globe.Action == EnumAction3D.NormalHit)
{
GSOPoint3d point3d = new GSOPoint3d();
GSOFeature newFeature = new GSOFeature();
GSOGeoMarker p = new GSOGeoMarker();
GSOMarkerStyle3D style = new GSOMarkerStyle3D();
style.IconPath = Application.StartupPath + "/Resource/image/DefaultIcon.png";
p.Style = style;
p.Z = point3d.Z <= 0 ? 0 : point3d.Z;
if (point3d.Z <= 0.0)
{
point3d = globeControl1.Globe.ScreenToScene(e2.X, e2.Y);
}
p.X = point3d.X;
p.Y = point3d.Y;
p.Z = point3d.Z;
p.Text = "标注";
newFeature.Geometry = p;
newFeature.Name = "我的地标";
globeControl1.Globe.MemoryLayer.AddFeature(newFeature);
globeControl1.Globe.Action = EnumAction3D.ActionNull;
globeControl1.Globe.FlyToFeature(newFeature);
globeControl1.Refresh();
}
}
};


网友评论