Ejemplo n.º 1
0
        /// <summary>
        /// 根据名称获取图层
        /// </summary>
        /// <param name="mapControl">The map control.</param>
        /// <param name="layerName">Name of the layer.</param>
        /// <returns>ILayer.</returns>
        public static ILayer GetLayerByName(this AxMapControl mapControl, string layerName)
        {
            var layerFinded = from layer in mapControl.GetLayers() where layer.Name == layerName select layer;

            if (layerFinded == null || layerFinded.Count() == 0)
            {
                return(null);
            }
            else if (layerFinded.Count() > 1)
            {
                return(null);
            }
            else
            {
                return(layerFinded.First());
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取要素图层
 /// </summary>
 /// <param name="mapControl">The map control.</param>
 /// <returns>IEnumerable&lt;IFeatureLayer&gt;.</returns>
 public static IEnumerable <IFeatureLayer> GetFeatureLayers(this AxMapControl mapControl)
 {
     return(from layer in mapControl.GetLayers()
            where layer is IFeatureLayer
            select layer as IFeatureLayer);
 }