MapControl1.Map.Clear();
MapGeosetLoader gl=new MapGeosetLoader(@"F:/test.gst");
MapControl1.Map.Load(gl);
//打开地图
MapControl1.Map.Load(new MapTableLoader(@"F:/test.tab"));
//打开test.tab地图文件
FeatureLayer lyrPnt=MapControl1.Map.Layers["test"] as FeatureLayer;
RangedTheme thm = new RangedTheme(lyrPnt,"PH__1999","ph",3,DistributionMethod.EqualCountPerRange);
lyrPnt.Modifiers.Insert(0,thm);
//定义一个RangedTheme
ThemeLegendFrame frame = LegendFrameFactory.CreateThemeLegendFrame("PH__1999","pp",thm);
Legend legend = MapControl1.Map.Legends.CreateLegend(new Size(5,5));
legend.Frames.Append(frame);
//定义一个Legend
//MapControl1.Map.Adornments.Append(legend);
//如果保留此句,MapControl1中将显示Legend
LegendControl1.Map = MapControl1.Map;
if (MapControl1.Map.Legends.Count > 0)
{
LegendControl1.Legend = MapControl1.Map.Legends[0];
}
//在LegendControl1控件中显示Legend
说明:这只是个简单的例子,对于不同的地图文件,具体代码有所不同,要修改一些地方。
博客给出地图操作代码示例,包括清空地图、加载地图文件,定义RangedTheme主题和Legend图例,还可在LegendControl1控件中显示图例。强调不同地图文件需修改部分代码。
2万+

被折叠的 条评论
为什么被折叠?



