- 积分
- 57046
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
讲讲多个MapFrame的用法,以在MapLayout上添加中国南海脚图为例。写一个函数AddMapFrame_ChinaSouthSea()函数,首先创建一个MapFrame对象,将其添加到LayersLegend中,会自动给相关联的MapLayout中增加一个LayoutMap;给这个MapFrame对象添加图层;获得这个MapFrame对应的LayoutMap,并设置相应的属性;将MapFrame的MapView缩放到中国南海范围。代码如下:
- private void AddMapFrame_ChinaSouthSea()
- {
- //Add an empty map frame
- MapFrame aMF = new MapFrame();
- aMF.Text = "China South Sea";
- layersLegend1.AddMapFrame(aMF);
- //Add a layer to this map frame
- string aFile = Application.StartupPath + "\\Map\\country1.shp";
- MapLayer aLayer = MapDataManage.OpenLayer(aFile);
- aLayer.LegendScheme.breakList[0].Color = Color.WhiteSmoke;
- aMF.AddLayer(aLayer);
- //Set layout map property
- LayoutMap aLM = mapLayout1.LayoutMaps[1];
- aLM.DrawGridLabel = false;
- aLM.Left = 550;
- aLM.Top = 330;
- aLM.Width = 80;
- aLM.Height = 100;
- aMF.MapView.ZoomToExtent(105, 120, 0, 20);
- layersLegend1.Refresh();
- }
复制代码
在MapLayout中添加文本。写一个AddTitle()函数,用MapLayout的AddText函数创建一个LayoutGraphic对象即可:
- private void AddTitle()
- {
- LayoutGraphic title = mapLayout1.AddText("MeteoInfo Class Library Demo", mapLayout1.Width / 2, 20, 12);
- }
复制代码
上述两个函数放入主窗体的Load事件中即可。
图形保存为图像文件的功能。加一个菜单File,再加一个子菜单Export Figure,并在其Click事件中加入下列代码,很简单我就不细说了:
- private void TSMI_ExportFigure_Click(object sender, EventArgs e)
- {
- SaveFileDialog aDlg = new SaveFileDialog();
- aDlg.Filter = "Png Image (*.png)|*.png|Gif Image (*.gif)|*.gif|Jpeg Image (*.jpg)|*.jpg|Bitmap Image (*.bmp)|*.bmp|Tif Image (*.tif)|*.tif|Windows Meta File (*.wmf)|*.wmf";
- if (aDlg.ShowDialog() == DialogResult.OK)
- {
- if (tabControl1.SelectedIndex == 0)
- {
- mapView1.ExportToPicture(aDlg.FileName);
- }
- else if (tabControl1.SelectedIndex == 1)
- {
- mapLayout1.ExportToPicture(aDlg.FileName);
- }
- }
- }
复制代码
运行效果如下:
|
|