Hi Ethan ,
I want to load all Layer from the GDB file.
I loop through all table from GDB file its throw object null reference error.
Please do the needful.
Code
private void Form1_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
//NewMethod("COUNTY");
//NewMethod("SCHOOL");
Collection<string> tables = FileGeoDatabaseFeatureLayer.GetTableNames(@"..\..\AppData\MapData.gdb");
foreach (string strem in tables)
{
NewMethod(strem);
}
winformsMap1.Refresh();
}
private void NewMethod(string str)
{
try
{
LayerOverlay layerOverlay = new LayerOverlay();
FileGeoDatabaseFeatureLayer fileGeoDatabaseFeatureLayer = new FileGeoDatabaseFeatureLayer(@"..\..\AppData\MapData.gdb", str);
Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = fileGeoDatabaseFeatureLayer.GetInternalProj4ProjectionParametersString();
proj4.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
proj4.Open();
fileGeoDatabaseFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
fileGeoDatabaseFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Canal1;
fileGeoDatabaseFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City1;
fileGeoDatabaseFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
fileGeoDatabaseFeatureLayer.FeatureSource.Projection = proj4;
layerOverlay.Layers.Add(fileGeoDatabaseFeatureLayer);
winformsMap1.Overlays.Add(layerOverlay);
fileGeoDatabaseFeatureLayer.Open();
winformsMap1.CurrentExtent = fileGeoDatabaseFeatureLayer.GetBoundingBox();
winformsMap1.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Also attach my screen shot.
Thanks,
Tamilarasan.