arcgis add-in 开发 打开地图后获取不到地图的图层信息
add-in功能中 想打开一个地图,然后进行缩放 但是在 ILayer pLayer = mMap.get_Layer(0);的时候报错,报错的原因是 地图还没有加载。 private void OpenMXD()
{
string Docpath = @"D:\2021年\农业保险\制图数据结果\双城区单城镇富源村.mxd";
ArcMap.Application.OpenDocument(Docpath);
IMxDocument pMxDoc = ArcMap.Document;
IPageLayout pPageLayout = pMxDoc.PageLayout;
ArcMap.Application.RefreshWindow();
}
private void ZoomLayer()
{
IMxDocument pMxDoc = ArcMap.Document;
IMaps mMaps = pMxDoc.Maps;
IMap mMap = mMaps.get_Item(0);
ILayer pLayer = mMap.get_Layer(0);
pMxDoc.ActiveView.Extent = pLayer.AreaOfInterest;
pMxDoc.ActiveView.Refresh();
}
{
string Docpath = @"D:\2021年\农业保险\制图数据结果\双城区单城镇富源村.mxd";
ArcMap.Application.OpenDocument(Docpath);
IMxDocument pMxDoc = ArcMap.Document;
IPageLayout pPageLayout = pMxDoc.PageLayout;
ArcMap.Application.RefreshWindow();
}
private void ZoomLayer()
{
IMxDocument pMxDoc = ArcMap.Document;
IMaps mMaps = pMxDoc.Maps;
IMap mMap = mMaps.get_Item(0);
ILayer pLayer = mMap.get_Layer(0);
pMxDoc.ActiveView.Extent = pLayer.AreaOfInterest;
pMxDoc.ActiveView.Refresh();
}
1 个回复
菠萝仔
赞同来自:
IMxDocument pMxDoc=null;
private void OpenMXD()
{
string Docpath = @"D:\2021年\农业保险\制图数据结果\双城区单城镇富源村.mxd";
ArcMap.Application.OpenDocument(Docpath);
// IMxDocument pMxDoc = ArcMap.Document;
pMxDoc = ArcMap.Document;
IPageLayout pPageLayout = pMxDoc.PageLayout;
ArcMap.Application.RefreshWindow();
}
private void ZoomLayer()
{
//IMxDocument pMxDoc = ArcMap.Document;
IMaps mMaps = pMxDoc.Maps;
IMap mMap = mMaps.get_Item(0);
ILayer pLayer = mMap.get_Layer(0);
pMxDoc.ActiveView.Extent = pLayer.AreaOfInterest;
pMxDoc.ActiveView.Refresh();
}
要回复问题请先登录或注册