小菜的ArcObjects学习之路------如果通过MapDocument访问地图和图层
来源:互联网 发布:天谕捏脸数据玉虚男 编辑:程序博客网 时间:2024/05/17 09:09
How to access maps and layers via the MapDocument
The MapDocument class is a utility class for reading and modifying map documents (.mxds). This topic demonstrates how to open a map document and loop through all its maps and layers.
Accessing maps and layers via the MapDocument
In the following code example, the names of these objects are reported to the console. Do the following steps to access maps and layers:
1:Create a MapDocument.
[C#]
IMapDocument pMapDocument = new MapDocumentClass();
- Enumerate the maps in the MapDocument and print their names to the console.See the following code example:
[C#]
if (pMapDocument.get_IsMapDocument(path)) // 判断是否为地图文档
{
pMapDocument.Open(path, null); // 打开地图文档
IMap pMap;
for (int i = 0; i <= pMapDocument.MapCount - 1; i++)
{
pMap = pMapDocument.get_Map(i); // 获取地图
Console.WriteLine(pMap.Name);
IEnumLayer pEnumLayer = pMap.get_Layers(null, true); // 获取地图的图层
pEnumLayer.Reset();
ILayer pLayer = pEnumLayer.Next();
while (pLayer != null)
{
Console.WriteLine(pLayer.Name);
pLayer = pEnumLayer.Next();
}
}
}
如果通过MapDocument访问地图和图层
MapDocument类是实用类的阅读和修改地图文件(.mxds)。本主题演示如何通过其所有的地图和图层打开地图文档和循环。
在下面的代码示例,这些对象的名字上报到控制台。请执行下列步骤来访问地图和图层:
1:创建一个MapDocument。
[C#]
IMapDocument pMapDocument = new MapDocumentClass();
2枚举在MapDocument地图和将自己的名字打印到控制台上。看到下面的代码示例:
[C#]
if (pMapDocument.get_IsMapDocument(path)) //
{
pMapDocument.Open(path, null);
IMap pMap;
for (int i = 0; i <= pMapDocument.MapCount - 1; i++)
{
pMap = pMapDocument.get_Map(i);
Console.WriteLine(pMap.Name);
IEnumLayer pEnumLayer = pMap.get_Layers(null, true);
pEnumLayer.Reset();
ILayer pLayer = pEnumLayer.Next();
while (pLayer != null)
{
Console.WriteLine(pLayer.Name);
pLayer = pEnumLayer.Next();
}
}
}
- 小菜的ArcObjects学习之路------如果通过MapDocument访问地图和图层
- 小菜的ArcObjects学习之路------如何通过MxDocument访问地图和图层
- 小菜的ArcObjects学习之路------Map Grids的使用
- 小菜的ArcObjects学习之路------IMapControlDefault interface
- 小菜的ArcObjects学习之路------IArray Interface
- 小菜的ArcObjects学习之路------IMapDocument interface
- 小菜的ArcObjects学习之路------操作Map Surrounds
- 小菜的ArcObjects学习之路------C#中接口的转换
- 小菜的ArcObjects学习之路------ ArcGIS COM类型在.Net中继承
- 小菜的c++学习之路~~
- python小菜的学习之路之python初识
- python小菜的学习之路 之 面向对象编程
- 小菜的GIS之路
- ArcObjects中根据数据源生成相应的图层
- 关于ArcObjects图层编辑的读写编辑锁
- acm小菜的成长之路
- 通过sqlview动态发布地图图层
- ArcObjects学习
- Learning Python(7) Files
- Thrift入门及Java实例演示
- EditText自动弹出输入法问题
- virtualbox中fedora17安装增强工具失败 Building the main Guest Additions module [失败]
- The C programming Language -1.10 External Variables and Scope
- 小菜的ArcObjects学习之路------如果通过MapDocument访问地图和图层
- JAVA原创学习(—)
- 首发Zend Studio 9.0.3正式版注册破解
- EditText属性
- 走在逐渐成熟的道路上
- C# 写定时器(不拖控件)
- Android 视频播放器
- 注销了人人网账号
- MySql中delimiter的作用是什么?