本文整理汇总了C#中AxMapControl.get_Layer方法的典型用法代码示例。如果您正苦于以下问题:C# AxMapControl.get_Layer方法的具体用法?C# AxMapControl.get_Layer怎么用?C# AxMapControl.get_Layer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxMapControl
的用法示例。
在下文中一共展示了AxMapControl.get_Layer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getLayerFromName
public static IFeatureLayer getLayerFromName(AxMapControl mapControl)
{
IFeatureLayer layer = null;
int s = 0;
for (int i = 0; i < mapControl.LayerCount; i++)
{
ILayer layers = mapControl.get_Layer(i);
if (layers is GroupLayer || layers is ICompositeLayer) //判断是否是groupLayer
{
MessageBox.Show(layers.Name);
//创建文件夹:slgc,ztdt,bhzy
if(layer.Name.Equals("水利工程"))
{
//创建文件夹:slgc
//将该文件路径传入函数中
layer = getSubLayer(layers); //递归的思想
}
else if (layer.Name.Substring(0, 2).Equals("方案"))
{
s++;
//创建ztdu文件夹
//传入参数 ztdt和方案i
layer = getSubLayer(layers); //递归的思想
}
else
{
//创建bhzy文件夹
//传入参数
layer = getSubLayer(layers); //递归的思想
}
if (layer != null)
{
continue;
}
}
else
{
//if (mapControl.get_Layer(i).Name.Equals(layerName))
//{
layer = layers as IFeatureLayer;
//}
}
}
//MessageBox.Show(layer.Name);
return layer;
}
示例2: AddLayersToEagleEye
public static void AddLayersToEagleEye(AxMapControl axMapControl1,AxMapControl axMapControl2)
{
// 当主地图显示控件的地图更换时,鹰眼中的地图也跟随更换
axMapControl2.Map = new MapClass();
axMapControl2.ClearLayers();
// 添加主地图控件中的所有图层到鹰眼控件中
for (int i = axMapControl1.LayerCount - 1; i >= 0; i--)
{
axMapControl2.AddLayer(axMapControl1.get_Layer(i));
}
// 设置 MapControl 显示范围至数据的全局范围
axMapControl2.Extent = axMapControl1.Extent;
// 刷新鹰眼控件地图
axMapControl2.Refresh();
}
示例3: DelFeature
/// <summary>
/// 删除feature图元
/// </summary>
/// <param name="intObjID"></param>
/// <param name="strLayerName"></param>
/// <param name="map"></param>
public void DelFeature(int intObjID, string strLayerName, AxMapControl map)
{
IFeatureLayer pfeaLayer;
for (int intI = 0; intI < map.LayerCount; intI++)
{
try
{
pfeaLayer = map.get_Layer(intI) as IFeatureLayer;
if (pfeaLayer != null && pfeaLayer.FeatureClass.AliasName == strLayerName)
{
//定义一个地物类,把要编辑的图层转化为定义的地物类
IFeatureClass fc = pfeaLayer.FeatureClass;
//先定义一个编辑的工作空间,然后把转化为数据集,最后转化为编辑工作空间,
IWorkspaceEdit w = (fc as IDataset).Workspace as IWorkspaceEdit;
//开始事务操作
w.StartEditing(false);
//开始编辑
w.StartEditOperation();
IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.WhereClause = "OBJECTID=" + intObjID;
IFeatureCursor updateCursor = pfeaLayer.FeatureClass.Update(queryFilter, false);
IFeature feature = updateCursor.NextFeature();
int m = 0;
while (feature != null)
{
m++;
updateCursor.DeleteFeature();
feature = updateCursor.NextFeature();
}
//结束编辑
w.StopEditOperation();
//结束事务操作
w.StopEditing(true);
break;
}
}
catch
{
}
}
}
示例4: UpdateMapLayerNameList
public List<string> UpdateMapLayerNameList(List<string> mapLayerNameList, AxMapControl mapControl)
{
mapLayerNameList = new List<string>();
//每次读取地图, 都要更新图层列表中的图层名.
for (int i = 0; i < mapControl.LayerCount; i++)
{
ILayer layer = mapControl.get_Layer(i);
ICompositeLayer compositeLayer = layer as ICompositeLayer;
if (compositeLayer == null)
{
//说明不是一个组合图层, 直接获取图层名.
mapLayerNameList.Add(layer.Name);
}
else
{
for (int j = 0; j < compositeLayer.Count; j++)
{
ILayer ly = compositeLayer.get_Layer(j);
mapLayerNameList.Add(ly.Name);
}
}
}
return mapLayerNameList;
}
示例5: GetLayerByName
/// <summary>
/// �������ƻ�ȡ��ͼͼ��ӿ�
/// </summary>
/// <param name="layer">ͼ����</param>
public ILayer GetLayerByName(AxMapControl axMapControl1, string layer)
{
for (int i = 0; i < axMapControl1.LayerCount; i++)
{
if (axMapControl1.get_Layer(i).Name.Equals(layer))
{
return axMapControl1.get_Layer(i);
}
}
return null;
}
示例6: updateMapLayerNameList
protected void updateMapLayerNameList(ObservableCollection<string> mapLayerNameList, AxMapControl mapControl)
{
//每次读取地图, 都要更新图层列表中的图层名.
for (int i = 0; i < mapControl.LayerCount; i++)
{
ILayer layer = mapControl.get_Layer(i);
ICompositeLayer compositeLayer = layer as ICompositeLayer;
if (compositeLayer == null)
{
//说明不是一个组合图层, 直接获取图层名.
mapLayerNameList.Add(layer.Name);
}
else
{
for (int j = 0; j < compositeLayer.Count; j++)
{
ILayer ly = compositeLayer.get_Layer(j);
mapLayerNameList.Add(ly.Name);
}
}
}
}
示例7: AddData_CAD
public static void AddData_CAD(AxMapControl axMapControl1)
{
IWorkspaceFactory pWorkspaceFactory;
IFeatureWorkspace pFeatureWorkspace;
IFeatureLayer pFeatureLayer;
IFeatureDataset pFeatureDataset;
//获取当前路径和文件名
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
string strFullPath = dlg.FileName;
if (strFullPath == "") return;
int Index = strFullPath.LastIndexOf("//");
string filePath = strFullPath.Substring(0, Index);
string fileName = strFullPath.Substring(Index + 1);
//打开CAD数据集
pWorkspaceFactory = new CadWorkspaceFactoryClass();
pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(filePath, 0);
//打开一个要素集
pFeatureDataset = pFeatureWorkspace.OpenFeatureDataset(fileName);
//IFeaturClassContainer可以管理IFeatureDataset中的每个要素类
IFeatureClassContainer pFeatClassContainer = (IFeatureClassContainer)pFeatureDataset;
//对CAD文件中的要素进行遍历处理
for (int i = 0; i < pFeatClassContainer.ClassCount - 1; i++)
{
IFeatureClass pFeatClass = pFeatClassContainer.get_Class(i);
if (pFeatClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
//如果是注记,则添加注记层
pFeatureLayer = new CadAnnotationLayerClass();
else
//如果是点、线、面,则添加要素层
pFeatureLayer = new FeatureLayerClass();
pFeatureLayer.Name = pFeatClass.AliasName;
pFeatureLayer.FeatureClass = pFeatClass;
axMapControl1.Map.AddLayer(pFeatureLayer);
axMapControl1.ActiveView.Refresh();
}
ILayer layer = axMapControl1.get_Layer(0);
axMapControl1.Extent = layer.AreaOfInterest;
}
}
示例8: QueryByBuffer
//查询
public static void QueryByBuffer(AxMapControl axMapControl)
{
// IDataset data = null;
ILayer layer = axMapControl.get_Layer(0);
IFeatureLayer featureLayer = layer as IFeatureLayer;
//获取featurelayer的featureClass
IFeatureClass featureClass = featureLayer.FeatureClass;
IFeature feature = null;
IQueryFilter queryFilter = new QueryFilterClass();
IFeatureCursor featureCursor;
queryFilter.WhereClause = "NAME";
featureCursor = featureClass.Search(queryFilter, true);
feature = featureCursor.NextFeature();
if (feature != null)
{
axMapControl.Map.SelectFeature(axMapControl.get_Layer(axMapControl.Map.LayerCount), feature);
axMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
}
axMapControl.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerCrosshair;
IGeometry geometry = null;
geometry = axMapControl.TrackPolygon();
//geometry = axMapControl.get_Layer(axMapControl.Map.LayerCount - 1) as IGeometry;
axMapControl.Map.SelectByShape(geometry, null, false);
axMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
}
示例9: query
public static int query(AxMapControl axMapControl1, string searchName,int index,bool flash)
{
ILayer layer = axMapControl1.get_Layer(index);
IFeatureLayer featureLayer = layer as IFeatureLayer;
int i=0;
if(featureLayer==null)
{
MessageBox.Show("选择图层不是Feature图层!");
return i;
}
//获取featureLayer的featureClass
IFeatureClass featureClass = featureLayer.FeatureClass;
IFeature feature = null;
IQueryFilter queryFilter = new QueryFilterClass();
//queryFilter.WhereClause = "SELECT * FROM " + featureClass.AliasName + " WHERE: 'CC' = '" + searchName + "'";
try
{
queryFilter.WhereClause = "用地类型 = '" + searchName + "'";
IFeatureCursor featureCusor = featureLayer.Search(queryFilter, false); ;
//featureCusor
//search的参数第一个为过滤条件,第二个为是否重复执行。
while ((feature = featureCusor.NextFeature()) != null)
{
//axMapControl1.Extent =(IEnvelope) feature.Shape;
axMapControl1.Map.SelectFeature(axMapControl1.get_Layer(index), feature);
if(flash)
axMapControl1.FlashShape(feature.Shape);
//axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphicSelection, null, null);
i++;
}
axMapControl1.ActiveView.Refresh();
return i;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return i;
}
}
示例10: HideAllLayerInMap
public static void HideAllLayerInMap(AxMapControl mapControl)
{
if (mapControl == null)
{
return;
}
for (int i = 0; i < mapControl.LayerCount; i++)
{
ILayer layer = mapControl.get_Layer(i);
layer.Visible = false;
}
mapControl.ActiveView.Refresh();
}
示例11: getGroupLayerFromName
public static IGroupLayer getGroupLayerFromName(string name, AxMapControl mapControl)
{
for (int i = 0; i < mapControl.LayerCount; i++)
{
if (mapControl.get_Layer(i).Name == name)
{
IGroupLayer layer = mapControl.get_Layer(i) as IGroupLayer;
return layer;
}
}
return null;
}
示例12: CheckMapIntegrity
public static bool CheckMapIntegrity(string folder, AxMapControl mapControl)
{
for (int i = 0; i < mapControl.LayerCount; i++)
{
ICompositeLayer cLayer = mapControl.get_Layer(i) as ICompositeLayer;
if (cLayer == null)
{
ILayer layer = mapControl.get_Layer(i);
if (!CheckLayerIntegrity(layer, folder))
{
return false;
}
}
else
{
for (int j = 0; j < cLayer.Count; j++)
{
ILayer layer = cLayer.get_Layer(j);
if (!CheckLayerIntegrity(layer, folder))
{
return false;
}
}
}
}
return true;
}
示例13: GetRasterLayer
public static List<IRasterLayer> GetRasterLayer(AxMapControl mapControl)
{
List<IRasterLayer> rasterLayerList = new List<IRasterLayer>();
for (int i = 0; i < mapControl.LayerCount; i++)
{
ILayer layer = mapControl.get_Layer(i);
ICompositeLayer cLayer = layer as ICompositeLayer;
if (cLayer == null)
{
IFeatureLayer fLayer = layer as IFeatureLayer;
if (fLayer == null)
{
IRasterLayer rLayer = layer as IRasterLayer;
rasterLayerList.Add(rLayer);
}
}
else
{
for (int j = 0; j < cLayer.Count; j++)
{
IFeatureLayer fLayer = cLayer.get_Layer(j) as IFeatureLayer;
if (fLayer == null)
{
IRasterLayer rLayer = cLayer.get_Layer(j) as IRasterLayer;
rasterLayerList.Add(rLayer);
}
}
}
}
return rasterLayerList;
}
示例14: getLayerByName
public static ILayer getLayerByName(string name, AxMapControl mapControl)
{
if (mapControl == null)
{
return null;
}
for (int i = 0; i < mapControl.LayerCount; i++)
{
ILayer layer = mapControl.get_Layer(i);
ICompositeLayer compositeLayer = layer as ICompositeLayer;
if (compositeLayer == null)
{
//说明不是一个组合图层, 直接获取图层名.
if (layer.Name == name)
{
return layer;
}
}
else
{
for (int j = 0; j < compositeLayer.Count; j++)
{
ILayer ly = compositeLayer.get_Layer(j);
if (ly.Name == name)
{
return compositeLayer as ILayer;
}
}
}
}
return null;
}
示例15: GetShpNameByMapLayerName
public static string GetShpNameByMapLayerName(AxMapControl mapControl, string mapLayerName)
{
for (int i = 0; i < mapControl.LayerCount; i++)
{
ICompositeLayer cLayer = mapControl.get_Layer(i) as ICompositeLayer;
if (cLayer == null)
{
ILayer layer = mapControl.get_Layer(i);
IFeatureLayer fLayer = layer as IFeatureLayer;
if (fLayer == null)
{
continue;
}
IFeatureClass featureClass = fLayer.FeatureClass;
if (featureClass == null)
{
continue;
}
string fileName = featureClass.AliasName;
if (layer.Name == mapLayerName)
return fileName;
}
else
{
for (int j = 0; j < cLayer.Count; j++)
{
ILayer layer = cLayer.get_Layer(j);
IFeatureLayer fLayer = layer as IFeatureLayer;
if (fLayer == null)
continue;
string fileName = fLayer.FeatureClass.AliasName;
if (layer.Name == mapLayerName)
return fileName;
}
}
}
return "";
}