Пример #1
0
        /// <summary>
        /// 初始化默认图层过滤器
        /// </summary>
        private void InitializeBasicLayerFilters()
        {
            //添加默认过滤器
            //最顶图层
            LayerFilterProperties topMostLayerProperty = new LayerFilterProperties();
            //topMostLayerProperty.HeaderImage = null;
            topMostLayerProperty.LayerCategory = string.Empty;
            topMostLayerProperty.LayerFeatureType = LayerFeatureType.None;
            topMostLayerProperty.LayerFilterName = TopMostLayer;
            topMostLayerProperty.TargetLayer = null;
            //topMostLayerProperty.MapWindow = associateMapWindow;
            //可见图层
            LayerFilterProperties visibleLayerProperty = new LayerFilterProperties();
            //visibleLayerProperty.HeaderImage = null;
            visibleLayerProperty.LayerCategory = string.Empty;
            visibleLayerProperty.LayerFeatureType = LayerFeatureType.None;
            visibleLayerProperty.LayerFilterName = VisibleLayers;
            visibleLayerProperty.TargetLayer = null;
            //visibleLayerProperty.MapWindow = associateMapWindow;
            //可选图层
            LayerFilterProperties selectableLayerProperty = new LayerFilterProperties();
            //selectableLayerProperty.HeaderImage = null;
            selectableLayerProperty.LayerCategory = string.Empty;
            selectableLayerProperty.LayerFeatureType = LayerFeatureType.None;
            selectableLayerProperty.LayerFilterName = SelectableLayers;
            selectableLayerProperty.TargetLayer = null;
            //selectableLayerProperty.MapWindow = associateMapWindow;
            //所有图层
            LayerFilterProperties allLayerProperty = new LayerFilterProperties();
            //allLayerProperty.HeaderImage = null;
            allLayerProperty.LayerCategory = string.Empty;
            allLayerProperty.LayerFeatureType = LayerFeatureType.None;
            allLayerProperty.LayerFilterName = AllLayers;
            allLayerProperty.TargetLayer = null;
            //allLayerProperty.MapWindow = associateMapWindow;

            //保存图层引用
            layerFilterSet.Add(topMostLayerProperty);
            layerFilterSet.Add(visibleLayerProperty);
            layerFilterSet.Add(selectableLayerProperty);
            layerFilterSet.Add(allLayerProperty);
        }
Пример #2
0
 /// <summary>
 /// 加载地图窗口中的图层
 /// </summary>
 private void DisplayLayersFromMapControl()
 {
     IMap map = pAxMapControl.Map;
     if (map.LayerCount < 1) return;
     //获取指定类型图层
     UID uid = new UIDClass();
     //表示搜索的是IDataLayer
     uid.Value = "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}";
     //布尔参数表示要搜索GroupLayer中的图层
     IEnumLayer layers = map.get_Layers(uid, true);
     layers.Reset(); ILayer layer = layers.Next();
     while (layer != null)
     {
         LayerFilterProperties layerProperty = new LayerFilterProperties();
         //layerProperty.HeaderImage = null;
         layerProperty.LayerCategory = string.Empty;
         layerProperty.LayerFilterName = layer.Name;
         layerProperty.LayerFeatureType = GetLayerFeatureType(layer);
         layerProperty.TargetLayer = layer;
         //保存引用
         layerFilterSet.Add(layerProperty);
         layer = layers.Next();
     }
     //释放Com对象
     System.Runtime.InteropServices.Marshal.ReleaseComObject(layers);
 }