About how to show the label

Topics: General Topics, SharpMap v0.9 / v1.x
Feb 23, 2009 at 4:05 PM
Edited Feb 23, 2009 at 6:24 PM
Hi, all

I want to show the status fields(attribute,added by myself) in every polygon. So I do the Label Setup in my map layer.
Now I can see the label in the MapWindow GIS(a software for creating and editing shapemap),but I can not see them in the webpage.

who can give me some suggestions?

Now I can show this label in the web page.
But new question,I want to show more than one label in a polygon. For example,I want to show name,age and company.
When I add two label layers ,the map can not show in the web page.

code :

  #region label layer
        SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("status labels");
        layLabel.DataSource = layGraves.DataSource;
        layLabel.Enabled = true;
        layLabel.LabelColumn = "Status";
        layLabel.Style = new SharpMap.Styles.LabelStyle();
        layLabel.Style.ForeColor = Color.White;
        layLabel.Style.Font = new Font(FontFamily.GenericSerif, 12);
        layLabel.Style.BackColor = new System.Drawing.SolidBrush(Color.FromArgb(128, 255, 0, 0));
        layLabel.MaxVisible = 200;
        layLabel.MinVisible = 0;
        layLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center;
        layLabel.SRID = 4326;
        layLabel.MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest;

        SharpMap.Layers.LabelLayer layLabelDeceasedName = new SharpMap.Layers.LabelLayer("Deceased Name labels");
        layLabel.DataSource = layGraves.DataSource;
        layLabel.Enabled = true;
        layLabel.LabelColumn = "DeceasedName";
        layLabel.Style = new SharpMap.Styles.LabelStyle();
        layLabel.Style.ForeColor = Color.White;
        layLabel.Style.Font = new Font(FontFamily.GenericSerif, 12);
        layLabel.Style.BackColor = new System.Drawing.SolidBrush(Color.FromArgb(128, 255, 0, 0));
        layLabel.MaxVisible = 200;
        layLabel.MinVisible = 0;
        layLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center;
        layLabel.SRID = 4326;
        layLabel.MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest;
      

        #endregion

By the way,how can I make the map label larger or smaller when I zoom out or in?

Feb 23, 2009 at 10:06 PM
thanks god~I made it by myself.

:)
Feb 24, 2009 at 2:21 AM

forgotten question: 
       I want to show more than one label in a polygon. For example,I want to show name,age and company.
When I add two label layers ,the map can not show in the web page.

how can I do

Coordinator
Feb 24, 2009 at 9:19 AM
Hi athel, use the LabelStringDelegate property of the LabelLayer to supply a method which takes a FeatureDataRow and returns a string. This way you only need one LabelLayer. Be aware that the longer the label them more chance of an intersection with another label so the more chance the label will be removed. hth jd
Feb 24, 2009 at 2:01 PM
HI, john. But the problem still there.
Because I can not format the string using html  like <table>  or <br>.
So, does it have any other way to resolve  this trouble?
Coordinator
Feb 24, 2009 at 2:07 PM
you can add line breaks using "\r\n" and tabs using "\t" hth jd
Feb 24, 2009 at 2:12 PM
Got it.Thank you so much.