如何为mapControl中的一个地图表增加主题

如何为mapControl中的一个地图表增加主题?
 为SHENGQU这个面样式表来增加主题。
 // Listen to some map events
 mapControl1.Resize += new EventHandler(mapControl1_Resize);
 //在此事件中处理当mapControl改变大小时来重新定位主题表的位置。

 // Create a ranged theme on the USA layer.
 Map map = mapControl1.Map;
 FeatureLayer lyr = map.Layers["SHENGQU"] as MapInfo.Mapping.FeatureLayer;

 RangedTheme thm = new MapInfo.Mapping.Thematics.RangedTheme(
  lyr,
  "Round(MI_Area(Obj, 'sq km', 'Spherical'), 1)",
  "Area (square kilometer)",
  5,
  MapInfo.Mapping.Thematics.DistributionMethod.EqualRangeSize);//.EqualCountPerRange);

 lyr.Modifiers.Append(thm);

 // Change the default fill colors from Red->Gray to White->Blue
 AreaStyle ars;
 // Get the style from our first bin
 CompositeStyle cs = thm.Bins[0].Style;
 // Get the region -- Area -- style
 ars = cs.AreaStyle;
 // Change the fill color
 ars.Interior = StockStyles.WhiteFillStyle();
 // Update the CompositeStyle with the new region color
 cs.AreaStyle = ars;
 // Update the bin with the new CompositeStyle settings
 thm.Bins[0].Style = cs;

 // Change the style settings on the last bin
 int nLastBin = thm.Bins.Count - 1;
 cs = thm.Bins[nLastBin].Style;
 ars = cs.AreaStyle;
 ars.Interior = StockStyles.BlueFillStyle();
 thm.Bins[nLastBin].Style = cs;

 // Tell the theme how to fill in the other bins
 thm.SpreadBy = SpreadByPart.Color;
 thm.ColorSpreadBy = ColorSpreadMethod.Rgb;
 thm.RecomputeStyles();

 // Create a legend
 legend = map.Legends.CreateLegend(new Size(5, 5));
 legend.Border = true;
 ThemeLegendFrame frame = LegendFrameFactory.CreateThemeLegendFrame("Area", "Area", thm);
 legend.Frames.Append(frame);
 frame.Title = "Area (sq. mi.)";
 map.Adornments.Append(legend);
 // Set the initial legend location to be the lower right corner of the map control.
 System.Drawing.Point pt = new System.Drawing.Point(0, 0);
 pt.X = mapControl1.Size.Width - legend.Size.Width;
 pt.Y = mapControl1.Size.Height - legend.Size.Height;
 legend.Location = pt;
 在mapControl1_Resize事件中针对mapControl大小的改变来变化主题表的位置。
 private void mapControl1_Resize(object sender, System.EventArgs e)
 {
  Control control = (Control)sender;

  // Move the Legend to the lower right corner...
  System.Drawing.Point pt = new System.Drawing.Point(0, 0);
  pt.X = control.Size.Width - legend.Size.Width;
  pt.Y = control.Size.Height - legend.Size.Height;
  legend.Location = pt;
 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值