使用.net开发基于MapX的地理信息系统-鹰眼图模块

    VB下开发MapX比较容易,鉴于现在.net开发环境 日益流行,使用.net开发基于MapX的地理信息系统的朋友越来越多,现在我共享我平时开发的一些代码,希望能给大家带来一些帮助:

    鹰眼图实际上是在导航图上,显示一个主窗体显示的区域!在导航图上添加一个临时层,在上面添加一个矩形的图元!

private void InitEagleReigon()
        {
            MapXLib.Feature TempFea;           
            MapXLib.StyleClass tempStyle;
           
            try
            {
                if (this.m_eagleLayer.AllFeatures.Count == 0)//判断该图元是否存在
                {
                    tempStyle = new MapXLib.StyleClass();
                    //设置矩形边框样式
                    tempStyle.RegionPattern = MapXLib.FillPatternConstants.miPatternNoFill;
                    tempStyle.RegionBorderColor = 255;
                    tempStyle.RegionBorderWidth = 2;
                    //在临时图层添加大小为mymap的边界的Rectangle对象
                    MapXLib.Points pnts = new MapXLib.Points();
                    pnts.AddXY(axMap_Full.CtlBounds.XMin, axMap_Full.CtlBounds.YMin, 1);
                    pnts.AddXY(axMap_Full.CtlBounds.XMax, axMap_Full.CtlBounds.YMin, 2);
                    pnts.AddXY(axMap_Full.CtlBounds.XMax, axMap_Full.CtlBounds.YMax, 3);
                    pnts.AddXY(axMap_Full.CtlBounds.XMin, axMap_Full.CtlBounds.YMax, 4);
                    TempFea = this.axMap_Eagle.FeatureFactory.CreateRegion(pnts, tempStyle);
                    m_fea = m_eagleLayer.AddFeature(TempFea, nullObject);
                    m_fea.Update(true, nullObject);                 
                }
                else
                {
                    m_fea.Parts._Item(1).RemoveAll();
                    m_fea.Parts._Item(1).AddXY(axMap_Full.CtlBounds.XMin, axMap_Full.CtlBounds.YMin, 1);
                    m_fea.Parts._Item(1).AddXY(axMap_Full.CtlBounds.XMax, axMap_Full.CtlBounds.YMin, 2);
                    m_fea.Parts._Item(1).AddXY(axMap_Full.CtlBounds.XMax, axMap_Full.CtlBounds.YMax, 3);
                    m_fea.Parts._Item(1).AddXY(axMap_Full.CtlBounds.XMin, axMap_Full.CtlBounds.YMax, 4);
                    m_fea.Update(true, nullObject);                  
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("InitEagleReigon:" + ex.Message);
            }
        }

 
 
#region 鹰眼功能模块
        private void axMap_Eagle_MouseDownEvent(object sender, AxMapXLib.CMapXEvents_MouseDownEvent e)
        {
            double MapX=0.0;
            double MapY=0.0;
            IsMouseDown = true;
            axMap_Eagle.ConvertCoord(ref e.x, ref e.y, ref MapX, ref MapY, MapXLib.ConversionConstants.miScreenToMap);
            this.axMap_Full.CenterX = MapX;
            this.axMap_Full.CenterY = MapY;
        
        }
        private void axMap_Eagle_MouseMoveEvent(object sender, AxMapXLib.CMapXEvents_MouseMoveEvent e)
        {
            if (IsMouseDown)
            {
                double MapX = 0.0;
                double MapY = 0.0;
                axMap_Eagle.ConvertCoord(ref e.x, ref e.y, ref MapX, ref MapY, MapXLib.ConversionConstants.miScreenToMap);
                this.axMap_Full.CenterX = MapX;
                this.axMap_Full.CenterY = MapY;
            }
        }
        private void axMap_Eagle_MouseUpEvent(object sender, AxMapXLib.CMapXEvents_MouseUpEvent e)
        {
            IsMouseDown = false;
        }
        private void axMap_Full_MapViewChanged(object sender, EventArgs e)
        {
            if (IsEndInit)
                InitEagleReigon();//初始化eagle或者根据FullMap的可视改变改变eagle的大小           
        }
        #endregion
 
因为在VB里面可以使用默认参数,在.net里面没有默认参数,需要通过System.Reflection.Missing.Value来代替!
以后我会陆续发表其他的功能模块!敬请关注
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值