分享

ArcEngine中使用上下左右键移动地图

 昵称QAb6ICvc 2017-08-24
axMapControl1.KeyIntercept = 1;

private void axMapControl1_OnKeyDown(object sender, ESRI.ArcGIS.MapControl.IMapControlEvents2_OnKeyDownEvent e)
        {
            switch (e.keyCode)
            {
                case (int)System.Windows.Forms.Keys.Up:
                    PanMap(0d, 0.5d);
                    break;
                case (int)System.Windows.Forms.Keys.Down:
                    PanMap(0d, -0.5d);
                    break;
                case (int)System.Windows.Forms.Keys.Left:
                    PanMap(-0.5d, 0d);
                    break;
                case (int)System.Windows.Forms.Keys.Right:
                    PanMap(0.5d, 0d);
                    break;
            }
        }

        private void PanMap(double ratioX, double ratioY)
        {
            //Pans map by amount specified given in a fraction of the extent e.g. rationX=0.5, pan right by half a screen 
            IEnvelope envelope = axMapControl1.Extent;
            double h = envelope.Width;
            double w = envelope.Height;
            envelope.Offset(h * ratioX, w * ratioY);
            axMapControl1.Extent = envelope;
        } 


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多