• 实现MapControl与GlobeControl同步


     http://anshien.blog.163.com/blog/static/16996630820107309045137/

    在GIS开发过程中,难免会遇到各种各样的需求,而作为程序员的我们就必须要想方设法把这些需求转换为功能实现,遇到奇怪的要求只能一边郁闷一边着手。。。

           抱怨到此为止,由此入正题。之前有遇到MapControl与PageLayoutControl的同步问题,这倒不是什么难题,ArcGISEngine的SDK中有实例介绍。但这次是MapControl与GlobeControl的同步。经过一段时间的研究,终是找到了解决办法,虽然有些笨拙,但为后来者提供学习还是可以的,望见谅!以下是实例代码:

                IScene scene = GlobeControl.Globe.GlobeDisplay.Scene;
                ISceneViewer sceneViewer = GlobeControl.Globe.GlobeDisplay.ActiveViewer;

                IGlobeCamera pGlobeCamera = sceneViewer.Camera as IGlobeCamera;
                IGlobeViewUtil pGlobeViewUtil = pGlobeCamera as IGlobeViewUtil;
                IEnvelope pEnvelope = new EnvelopeClass();

                pGlobeViewUtil.QueryVisibleGeographicExtent(pEnvelope);//得到GlobeControl的Extent
                
                IPoint minPoint = new PointClass();
                minPoint = GetProjectPoint(pEnvelope.XMin, pEnvelope.YMin);//获得从投影变换后的得到的平面坐标
                (minPoint as IZAware).ZAware = true;
                minPoint .Z = pEnvelope.ZMin;
                IPoint maxPoint = new PointClass();
                maxPoint = GetProjectPoint(pEnvelope.XMax, pEnvelope.YMax);
                (maxPoint as IZAware).ZAware = true;
                maxPoint.Z = pEnvelope.ZMax;
                IEnvelope GeoEnvelope = new EnvelopeClass();

                //设置平面Extent
                GetEnvelope(minPoint,maxPoint,out GeoEnvelope);

                //将得到的Envelope赋值给MapControl

                 MapControl.ActiveView.Extent = GeoEnvelope;
                 MapControl.ActiveView.Activate(MapControl.hWnd);
                 MapControl.ActiveView.Refresh();

        简单介绍这段程序的使用,当在TapControl中从GlobeControl到MapControl的切换时,以上的代码就能实现位置同步。

         而从MapControl到GlobeControl即可用IGlobeCamera.SetToZoomToExtents方法就能够实现。

  • 相关阅读:
    c# 02-18 值类型 引用类型 字符串的不可变性 字符串的处理方法
    c#0218-命名空间
    c#学习0217
    BootStrap学习
    c#学习0216
    AngularJS学习
    java面试题之什么是死锁、活锁、饿死和竞态条件?
    java面试题之能创建volatile数组吗?
    java面试题之sleep()和wait()方法的区别
    java面试题之Thread的run()和start()方法有什么区别
  • 原文地址:https://www.cnblogs.com/wangzihao/p/1909815.html
Copyright © 2020-2023  润新知