zoukankan      html  css  js  c++  java
  • Mapcontrol 遍历所有图层方法

    mapcontrol 遍历所有图层方法
    2011-04-29 19:51
    通过IMap中的get_layers()可以遍历MapControl中当前的图层。此方法可以通过指定UID对图层进行过滤或者分类。
     
    1. 遍历矢量图层
     
     
      public IEnumLayer GetFeatureLayers()
            {
                UID uid = new UIDClass();
                uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";//FeatureLayer
                IEnumLayer layers = frmMap.m_mapCtrl.Map.get_Layers(uid, true);
                return layers;
            }
     
     
    2. 遍历栅格图层
     
     
      public IEnumLayer GetRasterLayers()
            {
                UID uid = new UIDClass();
                uid.Value = "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}";//RasterLayer
                IEnumLayer layers = frmMap.m_mapCtrl.Map.get_Layers(uid, true);
                return layers;
     }
     
     
    3.遍历其它图层
     
    只要修改相应的UID即可。常见的数据类型的UID有:
     
     
    {6CA416B1-E160-11D2-9F4E-00C04F6BC78E} IDataLayer (包括所有类型的图层)
    {40A9E885-5533-11d0-98BE-00805F7CED21} IFeatureLayer
    {E156D7E5-22AF-11D3-9F99-00C04F6BC78E} IGeoFeatureLayer
    {34B2EF81-F4AC-11D1-A245-080009B6F22B} IGraphicsLayer
    {5CEAE408-4C0A-437F-9DB3-054D83919850} IFDOGraphicsLayer
    {0C22A4C7-DAFD-11D2-9F46-00C04F6BC78E} ICoverageAnnotationLayer
    {EDAD6644-1810-11D1-86AE-0000F8751720} IGroupLayer
     
     
    4. 通过图层名获取图层接口
     
    在AE开发中,这是常用到的功能,配合上面的方法,很容易实现。
     
     
     //获取矢量图层接口
     public IFeatureLayer GetFeatureLayer(string layerName)
            {
                //get the layers from the maps
                IEnumLayer layers = GetFeatureLayers();
                layers.Reset();
                ILayer layer = null;
     while ((layer = layers.Next()) != null)
                {
                    if (layer.Name == layerName)
                        return layer as IFeatureLayer;
                }
                return null;
            }
     
    //获取栅格图层接口        
    public IRasterLayer GetRasterLayer(string layerName)
            {
                //get the layers from the maps
                IEnumLayer layers = GetRasterLayers();
                layers.Reset();
                ILayer layer = null;
                while ((layer = layers.Next()) != null)
                {
                    if (layer.Name == layerName)
                        return layer as IRasterLayer;
                }
                return null;
            }
     
     
     
    获取其它类型的图层接口,同此类似。
    本篇文章来源于 3SDN  转载请以链接形式注明出处 网址:http://www.3sdn.net/gis2dev/ae/2009-08-29/454.html
  • 相关阅读:
    WSP部署错误—SharePoint管理框架中的对象“SPSolutionLanguagePack Name=0”依赖其他不存在的对象
    Elevate Permissions To Modify User Profile
    Error with Stsadm CommandObject reference not set to an instance of an object
    ASP.NET MVC3添加Controller时没有Scaffolding options
    测试使用Windows Live Writer写日志
    配置TFS 2010出现错误—SQL Server 登录的安全标识符(SID)与某个指定的域或工作组帐户冲突
    使用ADO.NET DbContext Generator出现错误—Unable to locate file
    CSS
    HTML DIV标签
    数据库
  • 原文地址:https://www.cnblogs.com/c-gis/p/3399198.html
Copyright © 2011-2022 走看看