Exemplo n.º 1
0
 /// <summary>
 /// 图层定位
 /// </summary>
 /// <param name="globeControl1"></param>
 /// <param name="latLonBounds"></param>
 public static void flyToLayerOrTerrain(GSOGlobeControl globeControl1, GSORect2d latLonBounds)
 {
     if ((latLonBounds.Left.Equals(0.0) == false) &&
         (latLonBounds.Bottom.Equals(0.0) == false) &&
         (latLonBounds.Top.Equals(0.0) == false) &&
         (latLonBounds.Right.Equals(0.0) == false))
     {
         GSOPoint2d pntCenter  = latLonBounds.Center;
         GSOPoint3d pntPostion = new GSOPoint3d();
         pntPostion.X = pntCenter.X;
         pntPostion.Y = pntCenter.Y;
         double dMaxGeoLen = Math.Max(latLonBounds.Width, latLonBounds.Height);
         double dSize      = dMaxGeoLen * Math.PI * 6378137 / 90;
         pntPostion.Z = dSize > 20000000 ? dSize / 4 : dSize;
         globeControl1.Globe.FlyToPosition(pntPostion, EnumAltitudeMode.RelativeToGround);
     }
 }
Exemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();

            globeControl1 = new GSOGlobeControl();
            panel1.Controls.Add(globeControl1);
            globeControl1.Dock = DockStyle.Fill;

            //点击节点飞行到要素全貌
            treeView1.NodeMouseDoubleClick += (sender, e) =>
            {
                if (e.Node.Tag.GetType() == typeof(GSOFeature))
                {
                    GSOFeature feature = e.Node.Tag as GSOFeature;
                    if (feature.Geometry.CameraState == null)
                    {
                        GSORect2d latLonBounds = feature.Geometry.Bounds;
                        if ((latLonBounds.Left.Equals(0.0) == false) &&
                            (latLonBounds.Bottom.Equals(0.0) == false) &&
                            (latLonBounds.Top.Equals(0.0) == false) &&
                            (latLonBounds.Right.Equals(0.0) == false))
                        {
                            Utility.flyToLayerOrTerrain(globeControl1, latLonBounds);
                        }
                    }
                }
            };

            #region Balloon初始化

            featureTooltip = new GSOBalloon(globeControl1.Handle);             //实例化GSOBalloon对象
            featureTooltip.SetSize(EnumSizeIndex.ROUNDED_CX, 5);               // 设置边角的圆润度
            featureTooltip.SetSize(EnumSizeIndex.ROUNDED_CY, 5);               // 设置边角的圆润度
            featureTooltip.SetSize(EnumSizeIndex.MARGIN_CX, 3);                // 设置空白边缘宽度
            featureTooltip.SetSize(EnumSizeIndex.MARGIN_CY, 3);                // 设置空白边缘宽度
            featureTooltip.SetSize(EnumSizeIndex.ANCHOR_HEIGHT, 30);           // 设置GSOBalloon 锚的高度
            featureTooltip.EscapeSequencesEnabled = true;
            featureTooltip.HyperlinkEnabled       = true;                      // 设置是否可以点击GSOBalloon里面的超链接
            featureTooltip.Opaque   = 0;                                       // 透明度,取值范围是0~100,0为不透明,100为全透明
            featureTooltip.MaxWidth = 300;                                     // 最大宽度
            featureTooltip.SetBorder(Color.FromArgb(255, 255, 128, 64), 1, 1); // 边框
            featureTooltip.SetColorBkType(EnumBkColorType.SILVER);             //填充颜色
            // 也可以下面方法设置
            //featureTooltip.SetColorBk(Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255,240, 247, 250), Color.FromArgb(255,192, 192, 200));
            featureTooltip.SetEffectBk(EnumBkEffect.VBUMP, 10); //渐变效果
            featureTooltip.SetShadow(0, 0, 50, true, 0, 0);     // 阴影
            //featureTooltip.CloseButtonVisible = true;  //显示关闭按钮

            //鼠标进入显示气泡
            globeControl1.FeatureMouseIntoEvent += (sender, e) =>
            {
                if (!featureTooltip.IsVisible())
                {
                    String str1 = "<table><tr><td valign=vcenter><center><h2> " + e.Feature.Name + "</h2><br><hr color=blue></center></td></tr></table>";
                    String str2 = e.Feature.Description;

                    // 显示GSOBalloon
                    featureTooltip.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1 + str2);
                }
            };

            //鼠标移出时隐藏气泡
            globeControl1.FeatureMouseOutEvent += (sender, e) =>
            {
                if (featureTooltip.IsVisible())
                {
                    globeControl1.SwapBuffer(); //为了避免闪屏
                    featureTooltip.HideBalloon();
                }
            };

            #endregion

            #region BalloonEx初始化

            balloonEx = new GSOBalloonEx(globeControl1.Handle);
            //点击要素显示
            globeControl1.FeatureMouseClickEvent += (sender, e) =>
            {
                GSOBalloonParam balloonParam = balloonEx.ParseParam(e.Feature.Description);
                balloonEx.ShowBalloonEx((int)e.MousePos.X, (int)e.MousePos.Y, balloonParam);
            };

            #endregion

            //移动视角时,隐藏气泡
            globeControl1.CameraBeginMoveEvent += (sender, args) =>
            {
                balloonEx.HideBalloon();
            };
        }
Exemplo n.º 3
0
        private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node.Tag != null)
            {
                if(e.Node.Tag.GetType() == typeof(GSOFeature))
                {
                    GSOFeature feature = e.Node.Tag as GSOFeature;
                    if (feature.Geometry == null || feature.Geometry.CameraState == null)
                    {
                        globeControl1.Globe.FlyToFeature(feature);
                    }
                    else
                    {
                        globeControl1.Globe.FlyToCameraState(feature.Geometry.CameraState);
                    }
                }
                else
                {
                    GSORect2d rcBounds=new GSORect2d();
                    GSOLayer tempLayer = e.Node.Tag as GSOLayer;

                    if (tempLayer!=null)
                    {
                        rcBounds = tempLayer.LatLonBounds;
                    }
                    else if (e.Node.Tag.GetType() == typeof(GSOTerrain))
                    {
                        GSOTerrain tempTerrain = e.Node.Tag as GSOTerrain;
                        rcBounds = tempTerrain.LatLonBounds;
                    }

                    if(!rcBounds.IsEmpty())
                    {
                        GSOPoint2d pntCenter = rcBounds.Center;
                        GSOPoint3d pntPostion=new GSOPoint3d();
                        pntPostion.X = pntCenter.X;
                        pntPostion.Y = pntCenter.Y;
                        Double dMaxGeoLen = Math.Max(rcBounds.Width, rcBounds.Height);
                        Double dSize = dMaxGeoLen *Math.PI*6378137/360;

                        pntPostion.Z = dSize;
                        globeControl1.Globe.FlyToPosition(pntPostion,EnumAltitudeMode.Absolute);
                    }
                }
            }
        }