隨筆-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 閱讀(1594) 評論(2)  編輯  收藏 所屬分類: DotNetMapXtreme

          評論:
          # re: mapxtreme 鷹眼圖的開發[未登錄] 2008-09-12 11:09 | george
          請問,你這個是不是缺了很大部分的代碼呢,不用客戶端代碼嗎?
          是適用于web開發gis的鷹眼嗎?
          我想請教你下  回復  更多評論
            
          # re: mapxtreme 鷹眼圖的開發 2008-09-12 15:32 | TiGERTiAN
          @george
          這個是絕大多數的代碼,還缺少幾個變量的聲明而已。
          這個適用于winform的開發,web的開發可能需要修改。  回復  更多評論
            
          主站蜘蛛池模板: 北安市| 屯留县| 朝阳县| 环江| 新巴尔虎左旗| 武威市| 河北省| 八宿县| 张北县| 遵义市| 临泉县| 伊宁县| 乐昌市| 大兴区| 连江县| 北辰区| 霍州市| 东乡县| 卓尼县| 兴业县| 邯郸县| 油尖旺区| 永清县| 安国市| 枣强县| 浪卡子县| 托克托县| 台北县| 郧西县| 晋中市| 中宁县| 江川县| 建宁县| 垣曲县| 定结县| 新建县| 江山市| 嘉黎县| 文成县| 东明县| 米林县|