//MapControl == WinFormMap Control private void BuildDetailLayer(DataTable table, mwLegend legend) { //Setup Detail Layer mwMapLayer DetailLayer = new mwMapLayer(table, "name", "location", "",true); if (DetailLayer.ifFeaturesInitialized) { DetailLayer.Open(); DetailLayer.Columns.Add(new FeatureSourceColumn("TotalSelected")); DetailLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; ClassBreakStyle Breaks = new ClassBreakStyle("TotalSelected"); for (int j = 0; j < 5; j++) { AreaStyle aStyle = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(GeoColor.FromArgb(100, legend.ScaleColors[j]))); Breaks.ClassBreaks.Add(new ClassBreak(legend.nScaleValue[j], aStyle)); } DetailLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(Breaks); DetailLayer.Close(); //AreaStyle aStyle = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(GeoColor.FromArgb(100, legend.ScaleColors[3]))); //DetailLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(aStyle); LayerOverlay Layer = new LayerOverlay(); Layer.Layers.Add("DetailLayer1", DetailLayer); MapControl.Overlays.Add("DetailLayer", Layer); try { DetailLayer.FeatureSource.Open(); ERROR HERE >>>>>> MapControl.CurrentExtent = DetailLayer.FeatureSource.GetBoundingBox(); DetailLayer.FeatureSource.Close(); } catch (SystemException ex) { bc.OKMessage(ex.Message); } } } public class mwMapLayer : InMemoryFeatureLayer { private string IdColumnName; private string Longitude; private string Latitude; private string Polygon; private bool ifPolygon = false; private DataTable MapTable; public bool ifFeaturesInitialized = true; public mwMapLayer(DataTable maptable, string idcolumnname, string longitude, string latitude, bool ifpolygon) { IdColumnName = idcolumnname; Longitude = longitude; Latitude = latitude; ifPolygon = ifpolygon; if (ifPolygon) Polygon = longitude; MapTable = maptable; if (!SetupFeatures()) ifFeaturesInitialized = false; } public bool SetupFeatures() { try { Feature feature; foreach (DataRow row in MapTable.Rows) { if (ifPolygon) { string wkt = row[Polygon].ToString().Trim(); if (bc.Left(wkt, 5).Trim() == "MULTI") { MultipolygonShape multi = new MultipolygonShape(wkt); multi.Id = bc.NameProper(row[IdColumnName].ToString(),false); feature = multi.GetFeature(); } else { PolygonShape polyShape = new PolygonShape(wkt); polyShape.Id = bc.NameProper(row[IdColumnName].ToString(),false); feature = polyShape.GetFeature(); } } else { PointShape pointShape = new PointShape(Convert.ToDouble(row[Longitude]), Convert.ToDouble(row[Latitude])); pointShape.Id = bc.NameProper(row[IdColumnName].ToString(),false); feature = pointShape.GetFeature(); } foreach (DataColumn Col in MapTable.Columns) { string Value = row[Col.ColumnName].ToString(); feature.ColumnValues.Add(Col.ColumnName, Value); } InternalFeatures.Add(feature); } } catch(SystemException ex) { bc.OKMessage(ex.Message); return false; } return true; } }