mapxtreme 鹰眼图的开发

 /// <summary>
        /// 更新鹰眼图
        /// </summary>
        private void UpdateEyeMap()
        {
            try {
                //如果主图和鹰眼图加载的是同一实例,那么鹰眼图就需要检测是否有效
                //if (eyeMap != null)
                {
                    //加载鹰眼矩形临时表
                    Table tblRect;
                    tblRect = Session.Current.Catalog.GetTable("TempRect");
                    if (tblRect != null)
                        tblRect.Close();
                    TableInfo tblInfo;
                    tblInfo = TableInfoFactory.CreateTemp("TempRect");
                    TableSessionInfo tblSessionInfo = new TableSessionInfo();

                    tblRect = Session.Current.Catalog.CreateTable(tblInfo, tblSessionInfo);
                    FeatureLayer feaLayer = new FeatureLayer(tblRect);
                    eyeMap.Layers.Insert(0, feaLayer);

                    //实时在鹰眼临时表图上画矩形
                    tblRect = Session.Current.Catalog.GetTable("TempRect");
                    (tblRect as ITableFeatureCollection).Clear();//清除当前层上的图元

                    //设置矩形的样式
                    DRect rect = mapControl.Map.Bounds;
                    FeatureGeometry feageo = new MapInfo.Geometry.Rectangle(mapControl.Map.GetDisplayCoordSys(), rect);
                    SimpleLineStyle simLineStyle = new SimpleLineStyle(new LineWidth(2, MapInfo.Styles.LineWidthUnit.Point), 2, System.Drawing.Color.Red);
                    SimpleInterior simInterior = new SimpleInterior(9, System.Drawing.Color.Gray, System.Drawing.Color.Green, true);
                    CompositeStyle comStyle = new CompositeStyle(new AreaStyle(simLineStyle, simInterior), null, null, null);

                    //将矩形插入到图层中
                    Feature fea = new Feature(feageo, comStyle);
                    tblRect.InsertFeature(fea);
                    //重新定位鹰眼图的中心
                    eyeMap.Center = map.Center;
                    eyeMap.Layers["TempRect"].Invalidate();

                    //清理对象变量
                    tblSessionInfo = null;
                    feageo = null;
                    simLineStyle = null;
                    simInterior = null;
                    comStyle = null;
                    fea = null;
                }              
            }catch(Exception ex) {
                GlobalHelper.ShowError("显示鹰眼图错误,"+ex.Message);
            }
 
           
        }

将该函数放入Map_ViewChangedEvent事件中,每当主图改变的时候鹰眼图会跟着变化,不过速度慢了点,因为需要重绘方框和移动中心坐标。
当然之前你要载入和主图一样的地图:

 eyeMap.Load(new MapGeosetLoader(basePath + GlobalHelper.IniFile["GST"]["gstFile"]));

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值