---
title: "MapXtreme2004代码 简单专题图的显示"
author: "mmdev"
date: "2005-01-20T12:13:00Z"
tags: []
slug: "mapxtreme2004"
draft: false
lastmod: "2012-10-29T21:24:31Z"
id: 1708301
url: "https://mmdev.iteye.com/blog/1708301"
---

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 &gt; 0)

{

LegendControl1.Legend = MapControl1.Map.Legends\[0];

}

//在LegendControl1控件中显示Legend

说明：这只是个简单的例子，对于不同的地图文件，具体代码有所不同，要修改一些地方。