隨筆-348  評論-598  文章-0  trackbacks-0

          很久沒寫blog了,備份一下,這段代碼是我從網(wǎng)上看來的,根據(jù)需要修改了一下。

                 /// <summary>
                  
          /// 更新鷹眼圖
                  
          /// </summary>

                  private void UpdateEyeMap()
                  
          {
                      
          try {
                          
          //如果主圖和鷹眼圖加載的是同一實(shí)例,那么鷹眼圖就需要檢測是否有效
                          
          //if (eyeMap != null)
                          {
                              
          //加載鷹眼矩形臨時(shí)表
                              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);

                              
          //實(shí)時(shí)在鷹眼臨時(shí)表圖上畫矩形
                              tblRect = Session.Current.Catalog.GetTable("TempRect");
                              (tblRect 
          as ITableFeatureCollection).Clear();//清除當(dāng)前層上的圖元

                              
          //設(shè)置矩形的樣式
                              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(
          "顯示鷹眼圖錯(cuò)誤,"+ex.Message);
                      }

           
                     
                  }
          將該函數(shù)放入Map_ViewChangedEvent事件中,每當(dāng)主圖改變的時(shí)候鷹眼圖會(huì)跟著變化,不過速度慢了點(diǎn),因?yàn)樾枰乩L方框和移動(dòng)中心坐標(biāo)。
          當(dāng)然之前你要載入和主圖一樣的地圖:
                          //鷹眼圖加載,添加不同實(shí)例,減小耦合性
                          eyeMap.Load(new MapGeosetLoader(basePath + GlobalHelper.IniFile["GST"]["gstFile"]));


          ---------------------------------------------------------
          專注移動(dòng)開發(fā)

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2008-02-25 14:24 TiGERTiAN 閱讀(1592) 評論(2)  編輯  收藏 所屬分類: DotNetMapXtreme

          評論:
          # re: mapxtreme 鷹眼圖的開發(fā)[未登錄] 2008-09-12 11:09 | george
          請問,你這個(gè)是不是缺了很大部分的代碼呢,不用客戶端代碼嗎?
          是適用于web開發(fā)gis的鷹眼嗎?
          我想請教你下  回復(fù)  更多評論
            
          # re: mapxtreme 鷹眼圖的開發(fā) 2008-09-12 15:32 | TiGERTiAN
          @george
          這個(gè)是絕大多數(shù)的代碼,還缺少幾個(gè)變量的聲明而已。
          這個(gè)適用于winform的開發(fā),web的開發(fā)可能需要修改。  回復(fù)  更多評論
            
          專注移動(dòng)開發(fā)--Windows Mobile, Android, iPhone, J2ME, BlackBerry, Symbian, Windows Phone

          慢慢混,慢慢學(xué)
          <2008年2月>
          272829303112
          3456789
          10111213141516
          17181920212223
          2425262728291
          2345678

          常用鏈接

          留言簿(43)

          隨筆分類(402)

          隨筆檔案(306)

          相冊

          我的好友們

          搜索

          •  

          積分與排名

          • 積分 - 811919
          • 排名 - 50

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 屏东县| 佛坪县| 马山县| 易门县| 萨迦县| 郓城县| 绵竹市| 永宁县| 武平县| 阿克| 沐川县| 舒兰市| 谢通门县| 莱阳市| 南澳县| 深水埗区| 青田县| 民和| 澎湖县| 社会| 武平县| 漳平市| 闽侯县| 手机| 宾川县| 横山县| 中方县| 万盛区| 新乡市| 泰和县| 古交市| 唐海县| 万山特区| 霍林郭勒市| 金坛市| 虎林市| 玛曲县| 东辽县| 中方县| 定日县| 溧阳市|