随笔-348  评论-598  文章-0  trackbacks-0

很久没写blog了,备份一下,这段代码是我从网上看来的,根据需要修改了一下。

       /// <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), nullnullnull);

                    
//将矩形插入到图层中
                    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"]));


---------------------------------------------------------
专注移动开发

Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
posted on 2008-02-25 14:24 TiGERTiAN 阅读(1570) 评论(2)  编辑  收藏 所属分类: DotNetMapXtreme

评论:
# re: mapxtreme 鹰眼图的开发[未登录] 2008-09-12 11:09 | george
请问,你这个是不是缺了很大部分的代码呢,不用客户端代码吗?
是适用于web开发gis的鹰眼吗?
我想请教你下  回复  更多评论
  
# re: mapxtreme 鹰眼图的开发 2008-09-12 15:32 | TiGERTiAN
@george
这个是绝大多数的代码,还缺少几个变量的声明而已。
这个适用于winform的开发,web的开发可能需要修改。  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: