This project has moved. For the latest updates, please go here.

Create LabelLayer with Text on Path

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Mar 13, 2015 at 9:10 AM
Hi Team,
I need to draw a __TextonPath __ Label Layer as i googling arround and found sharpmap supports isTextOnPath property. but when i create a label layer on multilinestring Geometry it creates label according to line . As if multilineString contains 3 lines it draw 3 labels one for each line.
I need to draw a single Label on MultilineGeometry from starting point of First line to the end point of Last line .

Please suggest ..

Mar 17, 2015 at 1:33 PM
LabelLayer has a MultipartGeometryBehaviour. If you set that to MultipartGeometryBehaviourEnum.All all your line strings should be labeled.
For lineal geometries LabelLayer renders the label along the linestring by default. If you set LabelStyle.IsTextOnPath a different approach is used for placing the labels.
Mar 23, 2015 at 7:34 AM
Will you please refer some example code as i achieve nothing by using MultipartGeometryBehaviour..
Please as i stuck in this from very long.

Mar 23, 2015 at 11:22 AM
Taken from this sample. Maybe you need to set LabelStyle.IgnoreLength == true;
//Setup River label
var layRiverLabel = new LabelLayer("River labels") {
    DataSource = layRivers.DataSource,
    Enabled = true,
    LabelColumn = "Name",
    TextRenderingHint = TextRenderingHint.AntiAlias,
    SmoothingMode = SmoothingMode.AntiAlias,
    SRID = 4326,
    LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection,
    MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.All,
    Style = new LabelStyle {
        ForeColor = Color.DarkBlue,
        Font = new Font(FontFamily.GenericSansSerif, 11),
        HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center,
        VerticalAlignment = LabelStyle.VerticalAlignmentEnum.Middle,
        //CollisionDetection = true,
        Halo = new Pen(Color.Azure, 2), 
        IgnoreLength =  true