ThinkGeo.com    |     Documentation    |     Premium Support

Display road name from mssql?

I load layer from mssql by AddLayerFromSQL() method .It's ok.


How to display road name from custom column "text" ?




  public void AddLayerFromSQL(string tableName)
        {
            string connectString = ConfigurationManager.ConnectionStrings["WebGISConnectionString"].ConnectionString;
            MsSql2008FeatureLayer myLayer = new MsSql2008FeatureLayer(connectString, tableName, "ID");
             myLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad1;
            myLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            myLayer.DrawingMarginPercentage = 10;
            Proj4Projection proj4 = new Proj4Projection();
            proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(32648);//UTM 48N = 32648
            proj4.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3405);//EPSG = 3405
            myLayer.FeatureSource.Projection = proj4;
            myLayer.Open();
            Map1.CurrentExtent = myLayer.GetBoundingBox();
            myLayer.Close();
            // 
            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.IsBaseOverlay = false;
            staticOverlay.Layers.Add(myLayer);
            Map1.CustomOverlays.Add(staticOverlay);
        }



db.jpg (7.57 KB)
view.jpg (13.9 KB)

Hi Dinh, 
  
 Thanks for your post and welcome to MapSuite world, Please consider the following code: 
  
 myLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("text", new GeoFont("Arial", 14), new GeoSolidBrush(GeoColor.SimpleColors.Black)); 
  
 If any question, please feel free to let me know. 
  
 Johnny 


Hi Johnny, 
 Thanks for your respone. 
  
 I used your code but my problem not resolve. 
  
  
  public void AddLayerFromSQL(string tableName)
        {
            if (!string.IsNullOrEmpty(tableName))
            {
                string connectString = ConfigurationManager.ConnectionStrings["WebGISConnectionString"].ConnectionString;
                myLayer = new MsSql2008FeatureLayer(connectString, tableName, "ID");
                myLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad1;
                myLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("text", new GeoFont("Arial", 14), new GeoSolidBrush(GeoColor.SimpleColors.Black)); 
                myLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                myLayer.DrawingMarginPercentage = 10;
                Proj4Projection proj4 = new Proj4Projection();
                proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(32648);//UTM 48N = 32648
                proj4.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3405);//EPSG = 3405
                myLayer.FeatureSource.Projection = proj4;
                myLayer.Open();
                Map1.CurrentExtent = myLayer.GetBoundingBox();
                myLayer.Close();
                LayerOverlay staticOverlay = new LayerOverlay();
                staticOverlay.IsBaseOverlay = false;
                staticOverlay.Layers.Add(myLayer);
                Map1.CustomOverlays.Add(staticOverlay);
               
                // TextStyle textStyle = new TextStyle("text", new GeoFont("Arial", 12), new GeoSolidBrush(GeoColor.StandardColors.Black));
                //textStyle.DuplicateRule = LabelDuplicateRule.OneDuplicateLabelPerQuadrant;
                //textStyle.FittingLineInScreen = true;
                //textStyle.TextLineSegmentRatio = 5;
                //textStyle.LabelAllLineParts = true;
                //textStyle.SplineType = SplineType.StandardSplining;
            }
        }


Hi Dinh, 
  
 Sorry for the inconvenience, I tried to use your code to recreate the problem, but it didn’t show up, would you please provide us a back up of your database that help us to recreate the problem? 
  
 Thanks for your help. 
  
 Gary