隨筆-348  評論-598  文章-0  trackbacks-0
                  /// <summary>
                  
          /// 給給定圖層添加圖元
                  
          /// </summary>
                  
          /// <param name="layerName"></param>
                  
          /// <param name="list"></param>

                  private void DrawFeature(string layerName, ArrayList list)
                  
          {
                      DPoint dpoint;
                      Point point;
                      BitmapPointStyle vs;
                      Feature f;
                      FeatureLayer flayer;

                      
          try
                      
          {
                          flayer 
          = map.Layers[layerName] as FeatureLayer;
                          
          if (flayer == null)
                              
          return;

                          Table fTable 
          = flayer.Table;

                          
          foreach (object o in list)
                          
          {
                              
                              Trouble t 
          = (Trouble) o;
                              dpoint 
          = new DPoint(t.X, t.Y);
                              point 
          = new Point(map.GetDisplayCoordSys(), dpoint);

                              vs 
          = new BitmapPointStyle();
                              vs.Name 
          = @t.BmpName;
                              vs.PointSize 
          = Convert.ToInt16(24);
                              vs.Attributes 
          = StyleAttributes.PointAttributes.BaseAll;
                              vs.SetApplyAll();

                              f 
          = new Feature(fTable.TableInfo.Columns);
                              f.Geometry 
          = point;
                              f.Style 
          = vs;
                              f[GlobalHelper.MIFields[
          0]] = t.TroubleType;
                              f[GlobalHelper.MIFields[
          1]] = t.Id;
                              f[GlobalHelper.MIFields[
          2]] = t.SpecTypeCode;


                              flayer.Table.InsertFeature(f);
                          }


                      }

                      
          catch (Exception ex)
                      
          {
                          GlobalHelper.ShowError(
          "繪制隱患圖元錯誤,原因:" + ex.Message);
                      }


                  }
          上半部分都是獲得地理信息和圖標,到了這邊

                              f = new Feature(fTable.TableInfo.Columns);
                              f.Geometry = point;
                              f.Style = vs;
                              f[GlobalHelper.MIFields[0]] = t.TroubleType;
                              f[GlobalHelper.MIFields[1]] = t.Id;
                              f[GlobalHelper.MIFields[2]] = t.SpecTypeCode;
          第一句主要是從圖層的表中獲得列結構,然后給這個feature賦值地理信息和圖標,后面三句就是給這個feature添加編號和類型等信息(當然這些屬性都是圖層表中的結構),這樣當點擊圖元的時候可以根據這些信息進行搜索
          當然如果圖片不在系統自定義圖片目錄下,你需要自定義一個圖片倉庫:
                          bool value = Session.Current.StyleRepository.BitmapPointStyleRepository.Reload(Constants.AppPath + "Resources");
          之后就可以使用
                          vs = new BitmapPointStyle();
                          vs.Name = @t.BmpName;
          直接載入相關圖片了,說明一點,圖片需要是4位色深的,如果是更大的色深則圖片會無法載入,在地圖上會顯示一個黑方塊。


          ---------------------------------------------------------
          專注移動開發

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2008-02-25 18:52 TiGERTiAN 閱讀(2391) 評論(0)  編輯  收藏 所屬分類: DotNetMapXtreme
          專注移動開發--Windows Mobile, Android, iPhone, J2ME, BlackBerry, Symbian, Windows Phone

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

          常用鏈接

          留言簿(43)

          隨筆分類(402)

          隨筆檔案(306)

          相冊

          我的好友們

          搜索

          •  

          積分與排名

          • 積分 - 813938
          • 排名 - 50

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 崇州市| 宝鸡市| 阳新县| 沽源县| 图片| 梁平县| 米林县| 多伦县| 巴青县| 牙克石市| 永川市| 溧阳市| 明溪县| 孝昌县| 西充县| 河源市| 宣威市| 靖远县| 盱眙县| 虹口区| 岢岚县| 平凉市| 会东县| 漳平市| 朝阳市| 芷江| 保康县| 上虞市| 贡嘎县| 驻马店市| 富川| 浦城县| 黔江区| 达尔| 桦川县| 垫江县| 绥江县| 新乐市| 昌图县| 淮安市| 抚松县|