• ArcEngine开发鹰眼实现问题


    在网上百度一下有关AE鹰眼实现的代码,基本是一样的,可问题是好多代码自己运行起来鹰眼却总是加不进地图。住视图axMapControl1.OnMapReplaced(),axMapControl1.OnExtentUpdated(),axMapControl2.OnMouseDown(),axMapControl2.OnMouseMove()在这几个事件绑定的委托方法里写代码,能够实现鹰眼所必须的功能。问题看似简单,代码也不难理解,可往往别人的代码到我们这里却总是会出现很多bug,问题是什么,我现在也不知道,为什么鹰眼地图总是加不进去,按理说代码改来改去都觉得问题不大应该可以实现,可就是无法显示,蛋疼的很。这也就是我们看别人代码思路感觉都对着,可往往在我们实际去做,总是会出现各种各样的不如人意。哎,不说了,把那经典的代码贴下来,那天返回来再看吧。现在我只有用比较笨的硬拷贝方法来实现鹰眼的显示联动问题了。

            private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
            {
                if (axMapControl2.Map.LayerCount > 0)
                {
                    if (e.button == 1)
                    {
                        IPoint pPt = new PointClass();
                        pPt.X = e.mapX;
                        pPt.Y = e.mapY;
                        IEnvelope pEnvelope = axMapControl1.Extent as IEnvelope;
                        pEnvelope.CenterAt(pPt);
                        axMapControl1.Extent = pEnvelope;
                        axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
    
                    }
                    else if (e.button == 2)
                    {
                        IEnvelope pEnvelope = axMapControl2.TrackRectangle();
                        axMapControl1.Extent = pEnvelope;
                        axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    }
                }
            }
    
            private void axMapControl2_OnMouseMove(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e)
            {
                if (e.button != 1)
                    return;
                IPoint pPt = new PointClass();
                pPt.X = e.mapX;
                pPt.Y = e.mapY;
                axMapControl1.CenterAt(pPt);
                axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
    
            private void axMapControl1_OnMapReplaced(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvent e)
            {
                if (axMapControl1.LayerCount > 0)
                {
                    //IMap pMap = axMapControl1.Map;
                    axMapControl2.Map = new MapClass();
                   
                    for (int i = 0; i <= axMapControl1.Map.LayerCount - 1; i++)
                    {
                        //axMapControl2.Map.AddLayer(pMap.get_Layer(i));
                        axMapControl2.AddLayer(axMapControl1.get_Layer(i));
                    }
                }
                axMapControl2.Extent = axMapControl1.FullExtent;
                axMapControl2.Refresh();
            }
    
            private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
            {
                IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
                IActiveView pAV = pGraphicsContainer as IActiveView;
                pGraphicsContainer.DeleteAllElements();
                IRectangleElement pRecElement = new RectangleElementClass();
                IElement pEle = pRecElement as IElement;
                IEnvelope pEnv;
                pEnv = e.newEnvelope as IEnvelope;
                IRgbColor pColor = new RgbColorClass();
                pColor.Red = 200;
                pColor.Green = 0;
                pColor.Blue = 0;
                pColor.Transparency = 255;
                //产生一个线符号对象
                ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
                pLineSymbol.Width = 2;
                pLineSymbol.Color = pColor;
                //设置填充符号属性
                IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                //设置透明颜色
                pColor.Transparency = 0;
                pFillSymbol.Color = pColor;
                pFillSymbol.Outline = pLineSymbol;
                IFillShapeElement pFillShapeElement = pRecElement as IFillShapeElement;
                pFillShapeElement.Symbol = pFillSymbol;
                pGraphicsContainer.AddElement(pEle, 0);
    
                axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }

    why it doesn't run ?

  • 相关阅读:
    减少.NET应用程序内存占用的一则实践
    ASP.NET中检测图片真实否防范病毒上传
    PHP、Python 相关正则函数实例
    利用脚本将java回归到面向函数式编程
    ASP.Net 实现伪静态方法及意义
    ExecuteNonQuery()方法
    在.net中使用split方法!
    str.split()如何用?谢谢
    输出货币型
    (DataRowView)e.Item.DataItem只有在ItemDataBound这个事件中起效
  • 原文地址:https://www.cnblogs.com/lxGIS/p/3341941.html
Copyright © 2020-2023  润新知