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

labellayer for polygonlayer, labels not inside polygon

Topics: SharpMap v0.9 / v1.x
Apr 10 at 3:02 PM
Given a polygon that looks like an L the label is rendered outside the area of the polygon.

Is there a configuration that forces the position of label inside the polygon?

CodPlex is shutting down: Will SharpMap move somewhere?
Coordinator
Apr 11 at 7:29 AM
Is there a configuration that forces the position of label inside the polygon?
LabelLayer ll = ...;
ll.LabelPositionDelegate = t => t.Geometry.PointOnSurface.Coordinate;
CodPlex is shutting down: Will SharpMap move somewhere?
SharpMap has moved to github https://github.com/SharpMap
Marked as answer by Lthrtt on 4/11/2017 at 5:59 AM
Apr 11 at 8:52 AM
ll.LabelPositionDelegate = t => t.Geometry.PointOnSurface.Coordinate;
Wow, C# is something. I didn't find an example in VB so i tried to define a delegate-function. Unfortunately it doesn't work.
...
ll.LabelPositionDelegate = New SharpMap.Layers.LabelLayer.GetLocationMethod(AddressOf GetPolygonPosition) 
...

    Function GetPolygonPosition(geom As GeoAPI.Geometries.IGeometry) As GeoAPI.Geometries.Coordinate
            GetPolygonPosition = geom.PointOnSurface.Coordinate
    End Function
SharpMap on GitHub: SharpMap.Rendering.Thematics.CategoryTheme, SharpMap.Rendering.Decorations.Legend, SharpMap.Layers.AnimatedGifLayer...i'm going to take a closer look;-)
Coordinator
Apr 11 at 9:19 AM
Edited Apr 11 at 10:50 AM
The signature of your delegate function is wrong, it has to be
REM Either

Private Function GetPolygonPosition(byval fdr as SharpMap.Data.FeatureDataRow) as GeoAPI.Geometries.Coordinate
    GetPolygonPosition = fdr.Geometry.PointOnSurface.Coordinate
End Function

REM  Or 

ll.LabelPositionDelegate = Function(fdr as SharpMap.Data.FeatureDataRow) fdr.Geometry.PointOnSurface.Coordinate;

Marked as answer by Lthrtt on 4/11/2017 at 5:59 AM