Пример #1
0
        private void AddShapeExtractorLayer(string pstrShapeExtractorFileName)
        {
            ShapeExtractor.ShapeExtractor oShapeExtractor = new ShapeExtractor.ShapeExtractor(pstrShapeExtractorFileName);
            oShapeExtractor.ShapeZipFile.Extract();
            string            strFileName = oShapeExtractor.ShapeZipFile.Contents.First(x => x.Value.IsShapeFile).Value.ExtractedFile.FullName;
            clsMapInformation oMI         = new clsMapInformation();

            oMI.MapSource      = enmMapSource.ShapeExtractorFile;
            oMI.MapName        = Path.GetFileNameWithoutExtension(pstrShapeExtractorFileName);
            oMI.SourcePathName = pstrShapeExtractorFileName;
            //fdr add to dictionary
            //fdr read stzyles
            AddShapeFileLayer(strFileName, true);
        }
Пример #2
0
        private void AddShapeFileLayer(string pstrShapeFileName, bool pblnFromExtractor = false)
        {
            string strLayerName = Path.GetFileNameWithoutExtension(pstrShapeFileName);

            SharpMap.Layers.VectorLayer oVectorLayer = new SharpMap.Layers.VectorLayer(strLayerName);

            oVectorLayer.DataSource = new SharpMap.Data.Providers.ShapeFile(pstrShapeFileName, true);

            if (!pblnFromExtractor)
            {
                clsMapInformation oMI = new clsMapInformation();
                oMI.MapSource      = enmMapSource.ShapeFile;
                oMI.MapName        = Path.GetFileNameWithoutExtension(pstrShapeFileName);
                oMI.SourcePathName = pstrShapeFileName;
                //fdr add to dictionary
                //fdr read stzyles
            }

            ////Create the style for Land
            //SharpMap.Styles.VectorStyle oLandStype = new SharpMap.Styles.VectorStyle();
            //oLandStype.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(232, 232, 232));

            ////Create the style for Water
            //SharpMap.Styles.VectorStyle oWaterStyle = new SharpMap.Styles.VectorStyle();
            //oWaterStyle.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(198, 198, 255));

            ////Create the theme items
            //Dictionary<string, SharpMap.Styles.IStyle> dictStyles = new Dictionary<string, SharpMap.Styles.IStyle>();
            //dictStyles.Add("land", oLandStype);
            //dictStyles.Add("water",oWaterStyle);

            ////Assign the theme
            //oVectorLayer.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme<string>("class", dictStyles, oLandStype);

            ctlMapBox.Map.Layers.Add(oVectorLayer);
            ctlMapBox.Map.ZoomToExtents();
            ctlMapBox.Refresh();
        }