ThinkGeo.com    |     Documentation    |     Premium Support

Bounding Box of a MSSQL2008FeatureLayer

Hi,


Is there any api off of the MSQL2008FeatureLayer to get the bounding box of that contains all the features? 


Thanks!


 



The following code seems to work for my project.  I imported the US States and Austin Streets Shape files into an SQLExpress 08 Spatial database.  This only gets the bounding box for one layer not all layers added to the map window.



                winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

                MsSql2008FeatureLayer streetsAustinLayer = new MsSql2008FeatureLayer(@"Server=CHARLESRLAPTOP\SQLEXPRESS;Database=MapSuite;Trusted_Connection=True;", "Austinstreets", "ID");
                streetsAustinLayer.ZoomLevelSet.ZoomLevel08.DefaultLineStyle.OuterPen.Width = 1;
                streetsAustinLayer.ZoomLevelSet.ZoomLevel08.DefaultLineStyle.OuterPen.Color = GeoColor.StandardColors.Black;
                streetsAustinLayer.ZoomLevelSet.ZoomLevel08.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                streetsAustinLayer.Name = "Austinstreets";

                MsSql2008FeatureLayer statesUS = new MsSql2008FeatureLayer(@"Server=CHARLESRLAPTOP\SQLEXPRESS;Database=MapSuite;Trusted_Connection=True;", "USStates", "ID");
                statesUS.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Width = 1;
                statesUS.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Black;
                statesUS.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                statesUS.Name = "statesUS";

                winformsMap1.DynamicOverlay.Layers.Add(statesUS.Name, statesUS);
                winformsMap1.DynamicOverlay.Layers.Add(streetsAustinLayer.Name, streetsAustinLayer);

                //                winformsMap1.CurrentExtent = new RectangleShape(-182, 76, -56, 16);   //Use this for US States
                //                winformsMap1.CurrentExtent = new RectangleShape(-97.82, 30.38, -97.65, 30.21);  /use this for just Aurtin Streets
                statesUS.Open();
                winformsMap1.CurrentExtent = statesUS.GetBoundingBox();



Clint, 
  
 Charles is correct that the method GetBoundingBox() is what you need.  
  
 Thanks Charles :) 
  
 Ben