This project has moved and is read-only. For the latest updates, please go here.

Problem with label layer

Topics: General Topics
May 30, 2007 at 9:46 AM
Edited May 30, 2007 at 4:16 PM
Hi there, I've got a map that shows the provinces of a region. My map is composed of 2 layer: a vector layer and a label layer. I've a problem with the label layer, because sometimes I've got a province's name that appear in great measure in another province. Is there a way to put a name inside the province's boundary?I've got only a shapefile and I take the provinces name from a shapefile column.
May 31, 2007 at 5:04 PM
May 31, 2007 at 11:49 PM
Hi Jako

I am not sure what you mean by "appear in great measure in another province" if it is that the same name appear in a other province then the shapefile .dbf has some duplicate names , Download a map viewer to see if this is the case if not then something is wrong with you Sharpmap data provider (Does other maps show correctly!)

As far as showing names in the centroid of Prov region can be done by using the Label name field of the same datasource of the shapefile for Provinces..shp but new label layer - something like

Layers.LabelLayer layASLabel = new SharpMap.Layers.LabelLayer("labels");
layASLabel.DataSource = your shapefile layername.DataSource;
layASLabel.LabelColumn = "your column name";
layASLabel.Style.Font = new Font("Arial", 12, FontStyle.Bold);
layASLabel.Style = new SharpMap.Styles.LabelStyle();
layASLabel.Style.ForeColor = Color.Black;
layASLabel.Style.Offset = new PointF(10, 0);
layASLabel.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
layASLabel.SmoothingMode = SmoothingMode.AntiAlias;
layASLabel.SRID = 7542; //This is your spatial ref no
layASLabel.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection;
layASLabel.Style.CollisionDetection = true;

I don'y know what you've done but hope it helps!

Jun 1, 2007 at 8:49 AM
Edited Jun 1, 2007 at 4:04 PM
Hi Gdevilliers,
thanks for your post. My shapefile is correct, the problem is that the label are put in center, middle, top, bottom,... respect to the bounding box, so if a province have a particulare shape I can have the label that "appear in great measure in another province".
I hope you can understand me.