Beispiel #1
0
        //------------------------------------------
        internal MapPolygonLayer AddProviderShapeFile(string Name)
        {
            MapPolygonLayer MyLayer = null;

            try
            {
                MyLayer            = (MapPolygonLayer)ProviderMap.AddLayer(DataPath + ShapeFilename);
                MyLayer.LegendText = Name;
                DataTable LayerDT = MyLayer.DataSet.DataTable;

                if (MyLayer == null)
                {
                    MessageBox.Show("The Base ShapeFile is not a polygon layer.");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error Loading Shape File:[ " + DataPath + ShapeFilename + "] :" + e.Message);
            }
            return(MyLayer);
        }
Beispiel #2
0
        //--------------------------------------------------------------
        internal void AddProviderBaseShapeFile()
        {
            try
            {
                ProviderMap.AddLayer(DataPath + ShapeFilename);

                //Assign the mappolygon layer from the map
                MapPolygonLayer BaseLayer = default(MapPolygonLayer);
                BaseLayer = (MapPolygonLayer)ProviderMap.Layers[0];

                if (BaseLayer == null)
                {
                    MessageBox.Show("The Base Layer of Provider Map is not a polygon layer.");
                }
                else
                {
                    //Get the shapefile's attribute table to our datatable dt
                    DataTable DT = BaseLayer.DataSet.DataTable;

                    // Create a Scheme
                    PolygonScheme BaseScheme = new PolygonScheme();
                    //Set the ClassificationType for the PolygonScheme via EditorSettings
                    BaseScheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues;
                    //Set the UniqueValue field name
                    BaseScheme.EditorSettings.FieldName = "ADWR_NAME";
                    // Create Catagories based on data
                    BaseScheme.CreateCategories(DT);
                    // Set the Symbology to this Scheme
                    BaseLayer.Symbology = BaseScheme;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error Loading Shape File:[ " + DataPath + ShapeFilename + "] :" + e.Message);
            }
        }