隨筆-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);
                      }


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

                              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;
          第一句主要是從圖層的表中獲得列結(jié)構(gòu),然后給這個feature賦值地理信息和圖標(biāo),后面三句就是給這個feature添加編號和類型等信息(當(dāng)然這些屬性都是圖層表中的結(jié)構(gòu)),這樣當(dāng)點擊圖元的時候可以根據(jù)這些信息進(jìn)行搜索
          當(dāng)然如果圖片不在系統(tǒng)自定義圖片目錄下,你需要自定義一個圖片倉庫:
                          bool value = Session.Current.StyleRepository.BitmapPointStyleRepository.Reload(Constants.AppPath + "Resources");
          之后就可以使用
                          vs = new BitmapPointStyle();
                          vs.Name = @t.BmpName;
          直接載入相關(guān)圖片了,說明一點,圖片需要是4位色深的,如果是更大的色深則圖片會無法載入,在地圖上會顯示一個黑方塊。


          ---------------------------------------------------------
          專注移動開發(fā)

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2008-02-25 18:52 TiGERTiAN 閱讀(2385) 評論(0)  編輯  收藏 所屬分類: DotNetMapXtreme
          主站蜘蛛池模板: 广昌县| 昭觉县| 三都| 珠海市| 疏勒县| 平阴县| 德昌县| 赣榆县| 通渭县| 驻马店市| 临漳县| 富蕴县| 仙居县| 唐河县| 曲水县| 宁武县| 新泰市| 马尔康县| 墨江| 尉犁县| 临泽县| 延安市| 志丹县| 商洛市| 云阳县| 会理县| 丹阳市| 舒城县| 紫阳县| 肥西县| 岫岩| 钦州市| 长春市| 渭源县| 南陵县| 犍为县| 辽宁省| 揭西县| 兴文县| 加查县| 麻阳|