示例#1
0
        /// <summary>
        ///  该函数负责将给定featuresource配以style并返回layer
        /// </summary>
        /// <param name="gdb"></param>
        /// <param name="datapath"></param>
        /// <param name="stylepath"></param>
        /// <param name="layername"></param>
        /// <returns></returns>
        public static Layer LoadLayer(FeatureSource featuresource, string layername, string stylepath)
        {
            Style style = null;

            try
            {
                if (stylepath != null)
                {
                    style = Style.parseStyleFile(stylepath);
                }
            }catch (Exception e)
            {
            }
            if (style == null)
            {
                style = Style.createSimpleStyle(featuresource);
            }
            Layer layer = new Layer(layername, featuresource, style);

            return(layer);
        }
示例#2
0
        /// <summary>
        /// 用户向已有gdb中添加一个新的图层,该图层必须已存在shp文件
        /// 向该mapcontent中添加一个layer
        /// </summary>
        /// <param name="gdb"></param>
        /// <param name="layerpath"></param>
        /// <param name="stylepath"></param>
        /// <returns></returns>
        public string addLayer(string layerpath, string stylepath, string guid, string layername)
        {
            if (layerpath == null)
            {
                return(null);
            }
            FeatureSource featuresource = null;
            PGGeoDatabase gdb           = (PGGeoDatabase)this.gdb;

            //string layername =
            gdb.AddSHPFeatureSource(layerpath, guid);
            if (!this.gdb.featureSources.TryGetValue(guid, out featuresource))
            {
                return(null);
            }
            Style style = null;

            try
            {
                if (stylepath != null)
                {
                    style = Style.parseStyleFile(stylepath);
                }
            }
            catch (Exception e)
            {
            }
            if (style == null)
            {
                style = Style.createSimpleStyle(featuresource);
            }
            Layer layer = new Layer(layername, featuresource, style);

            this.layerlist.Insert(0, layer);
            return(layername);
        }