C#调用ArcEngine定位三维点

 1.根据鼠标移动,获取地图上的三维点坐标

定义鼠标移动事件:其中axSceneControl是三维的AxSceneControl对象。

this.axSceneControl.OnMouseMove += new AxESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseMoveEventHandler(this.axSceneControl_OnMouseMove);

2. 定义鼠标移动事件对应执行的方法    

   private void axSceneControl_OnMouseMove(object sender, AxESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseMoveEvent e)
{

           //方法1

            IPoint po;
            object owner, obj;
            axMapFull.SceneGraph.Locate(axSceneControl.SceneViewer, e.x, e.y, esriScenePickMode.esriScenePickGeography, true, out po, out owner, out obj);//po就是得到的点

           //方法2
            IHit3DSet pHit3dSet = null;
            axSceneControl.SceneGraph.LocateMultiple(axSceneControl.SceneGraph.ActiveViewer, e.x, e.y, esriScenePickMode.esriScenePickAll, true, out pHit3dSet);

           po=pHit3D.Point;//po就是得到的点    

           //如果想得到某图层元素,可以看看下面代码

           int index=2;
           if (pHit3dSet == null)
                return;
            IHit3D pHit3D = (IHit3D)pHit3dSet.Hits.get_Element(0);
            IFeature pFeature = (IFeature)pHit3D.Object;
            if (pFeature == null)
                return;
            string siteName = pFeature.get_Value(index).ToString();   

}

 

你可能感兴趣的:(ArcEngine)