• 实现MapObject放大,缩小,平移,全图常用功能


    在axMap1的MouseDownEvent事件里加入下面代码

    代码
              MapObjects2.Rectangle rect;     //范围
                switch (axMap1.MousePointer)
                {
                    //放大
                    case MapObjects2.MousePointerConstants.moZoomIn:
                        {                        
                            rect 
    = axMap1.TrackRectangle(); //得到鼠标拖动范围
                            
    if (rect == null || rect.Width < 0.00005 || rect.Height < 0.00005)  //如果选择区域很小,可以认为是 单击、点选
                            {
                                rect 
    = axMap1.Extent;
                                rect.ScaleRectangle(
    0.5);   //设置放大比例
                            }
                            axMap1.Extent 
    = rect;
                            
    break;
                        }

                    
    //缩小 
                    case MapObjects2.MousePointerConstants.moZoomOut:
                        {
                            MapObjects2.Rectangle Tempr;
                            Tempr 
    = axMap1.Extent;
                            rect 
    = axMap1.TrackRectangle();
                            
    double NewSR;
                            
    if (rect == null || rect.Width < 0.00005 || rect.Height < 0.00005)
                            {
                                
    if (axMap1.Extent.Width / rect.Width > axMap1.Extent.Height / rect.Height)
                                {
                                    NewSR 
    = axMap1.Extent.Height / rect.Height;
                                }
                                
    else
                                {
                                    NewSR 
    = axMap1.Extent.Width / rect.Width;
                                }
                                Tempr.ScaleRectangle(NewSR);
                            }
                            
    else
                            {
                                Tempr.ScaleRectangle(
    2.0);   //设置缩小比率
                            }
                            axMap1.Extent 
    = Tempr;
                            
    break;
                        }
                    
    //漫游 
                    case MapObjects2.MousePointerConstants.moPan:
                        {
                            axMap1.Pan();
                            
    break;
                        }
               .
               .
               .

    这里要设置下鼠标的状态,比如在放大按钮的单击事件下加入:

    axMap1.MousePointer = MapObjects2.MousePointerConstants.moZoomIn;   //放大,改变鼠标状态

    全图:

    axMap1.Extent = axMap1.FullExtent;

  • 相关阅读:
    大数运算
    混合背包问题
    多重背包问题(二进制优化)
    完全背包
    01背包问题
    树状数组
    构建之法阅读笔记04
    第一次冲刺个人总结07
    构建之法阅读笔记03
    第一次冲刺个人总结06
  • 原文地址:https://www.cnblogs.com/tqlin/p/1675584.html
Copyright © 2020-2023  润新知