這將是C#的示例遍歷所有層,如果它是一個功能層,得到直到在工作區從它那裏得到的路徑或任何:
/* Make a list of all feature classes. */
List<ILayer> layers_list = new List<ILayer>();
IMap map = get_map();
IEnumLayer enumLayer = map.get_Layers(null, true);
ILayer layer = null;
while (layer = enumLayer.Next() != null) {
// we're looking for a feature class only
if (layer is IFeatureLayer) {
try {
IFeatureClass fclass = ((IFeatureLayer)layer).FeatureClass;
IFeatureLayer featureLayer = (IFeatureLayer)layer;
// Get the dataset and workspace of the feature class
IDataset ds = (IDataset)fclass;
IWorkspace ws = (IWorkspace)ds.Workspace;
// Do something with the workspace, like getting the path or
// whatever...
} catch (Exception e) {
MessageBox.Show("Layer ' " + layer.Name + "': \n\n" + e.Message);
}
}
}
單個_layer_只有從提取數據單個要素類;一個_圖層組可能有多個圖層(和多個要素類)。我很抱歉,如果這看起來很挑剔,但術語是重要的:) – Erica