更改图层样式(mapXtreme2008+C#)

区域图形的层,需要变更样式为透明,只显示边界线,实现代码如下:



//修改样式
        
          public void change_style(String name)
          {
              try
              {

                 //定义样式
                  MapInfo.Styles.SimpleInterior sis =

                new MapInfo.Styles.SimpleInterior(1, System.Drawing.Color.Transparent);//填充颜色

               MapInfo.Styles.LineWidth lw = new MapInfo.Styles.LineWidth(2, MapInfo.Styles.LineWidthUnit.Point);//2填充图形是non.          MapInfo.Styles.LineWidthUnit.Point
                  MapInfo.Styles.SimpleLineStyle sl = new MapInfo.Styles.SimpleLineStyle(lw, 2, System.Drawing.Color.Blue);//蓝色边线
                  MapInfo.Styles.AreaStyle ar = new MapInfo.Styles.AreaStyle(sl, sis);

                  MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(ar);
                   Table tab = MapInfo.Engine.Session.Current.Catalog.GetTable(name);
                  FeatureLayer fl = new FeatureLayer(tab);

               int index=  MainMap.Map.Layers.IndexOf(MainMap.Map.Layers[name]);
                  MainMap.Map.Layers.Remove(name);

                   MainMap.Map.Layers.Insert(index, fl);

                  FeatureOverrideStyleModifier fosm =  new FeatureOverrideStyleModifier("Style", cs);
                  fl.Modifiers.Append(fosm);
              }
              catch (Exception ex)
              {
                  MessageBox.Show("样式修改错误:"+ex.ToString());
              }
          }

你可能感兴趣的:(styles,mapinfo)