本文整理汇总了C#中AxMapControl.LoadMxFile方法的典型用法代码示例。如果您正苦于以下问题:C# AxMapControl.LoadMxFile方法的具体用法?C# AxMapControl.LoadMxFile怎么用?C# AxMapControl.LoadMxFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxMapControl
的用法示例。
在下文中一共展示了AxMapControl.LoadMxFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadGeoData
public static void LoadGeoData(AxMapControl axMapControl1, AxMapControl axMapControl2, string strFileN)
{
string strFExtenN = System.IO.Path.GetExtension(strFileN);
switch (strFExtenN)
{
case ".shp":
{
string strPath = System.IO.Path.GetDirectoryName(strFileN);
string strFile = System.IO.Path.GetFileNameWithoutExtension(strFileN);
axMapControl1.AddShapeFile(strPath, strFile);
axMapControl2.ClearLayers();
axMapControl2.AddShapeFile(strPath, strFile);
axMapControl2.Extent = axMapControl2.FullExtent;
break;
}
case ".bmp":
case ".tif":
case ".jpg":
case ".img":
{
IWorkspaceFactory pWSF = new RasterWorkspaceFactoryClass();
string pathName = System.IO.Path.GetDirectoryName(strFileN);
string fileName = System.IO.Path.GetFileName(strFileN);
IWorkspace pWS = pWSF.OpenFromFile(pathName, 0);
IRasterWorkspace pRWS = pWS as IRasterWorkspace;
IRasterDataset pRasterDataSet = pRWS.OpenRasterDataset(fileName);
IRasterPyramid pRasPyramid = pRasterDataSet as IRasterPyramid;
if (pRasPyramid != null)
{
if (!(pRasPyramid.Present))
{
pRasPyramid.Create();
}
}
IRaster pRaster = pRasterDataSet.CreateDefaultRaster();
IRasterLayer pRasterLayer = new RasterLayerClass();
pRasterLayer.CreateFromRaster(pRaster);
ILayer pLayer = pRasterLayer as ILayer;
axMapControl1.AddLayer(pLayer, 0);
axMapControl2.ClearLayers();
axMapControl2.AddLayer(pLayer, 0);
axMapControl2.Extent = axMapControl2.FullExtent;
break;
}
case ".mxd":
{
if (axMapControl1.CheckMxFile(strFExtenN))
{
axMapControl1.LoadMxFile(strFExtenN);
}
else
MessageBox.Show("所选择的文件不是Mxd文件!", "提示信息");
break;
}
default:
break;
}
}
示例2: OpenMxdFile
/// <summary>
/// 打开mxd文档
/// path为打开mxd文件的路径,mapControl加载该地图文档的地图控件名称
/// 日期2013-12-13
/// lntu_GISer1
/// </summary>
public string OpenMxdFile(string path,AxMapControl mapControl)
{
string filename = openfileDialog(path);
try
{
if (filename != "")
{
mapControl.LoadMxFile(filename);
mapControl.Extent = mapControl.FullExtent;
}
return filename;
}
catch(Exception e)
{
MessageBox.Show(e.Message);
return "";
}
}
示例3: loadMapDocument
//IMapDocument pMapDocument;
/// <summary>
/// 打开工程文档
/// </summary>
/// <param name="pAxMapControl">axMapControl</param>
private void loadMapDocument(AxMapControl pAxMapControl)
{
OpenFileDialog openFileDialog;
openFileDialog = new OpenFileDialog();
openFileDialog.Title = "打开工程";
openFileDialog.Filter = "工程文档(*.mxd)|*.mxd";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string sFilePath = openFileDialog.FileName;
//需要添加 判断原来的AxMapControl中是不是有地图
if (pAxMapControl.CheckMxFile(sFilePath))
{
pAxMapControl.MousePointer = esriControlsMousePointer.esriPointerHourglass;
pAxMapControl.LoadMxFile(sFilePath, 0, Type.Missing);
pAxMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
//加载鹰眼地图
//loadEagleEyeDocument(filePath);
//pAxMapControl.Extent = pAxMapControl.FullExtent;
}
else
{
MessageBox.Show(sFilePath + "不是有效的工程文档!");
}
}
}