how to add a text layer

Oct 17, 2014 at 8:43 AM
Hello

I want to add some text to mark my polylines, and here's my code
            SharpMap.Layers.LabelLayer labellayer = new SharpMap.Layers.LabelLayer("labelLayer");
            GeoAPI.Geometries.Coordinate mapCoordinate = mapBoxCentre.Map.ImageToWorld(new PointF(100, 100));
            var factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326);
            var point = factory.CreatePoint(mapCoordinate);
            List<GeoAPI.Geometries.IGeometry> pti = new List<GeoAPI.Geometries.IGeometry>();
            pti.Add(point);
            labellayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(pti);
            labellayer.Style.Font = new Font("Arial", 12);
            labellayer.Style.ForeColor = Color.Black;

            labellayer.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            labellayer.LabelStringDelegate = LabelDelegate;



    private string LabelDelegate(SharpMap.Data.FeatureDataRow fdr)
    {
        //Simple output, but you can filter by FeatureDataRow fdr
        return "foobar";
    }



but it does not work, can someone help me ? thx!
Coordinator
Oct 17, 2014 at 9:15 AM
Geometry provider does not work with labeling. Use GeometryFeatureProvider instead.
Oct 19, 2014 at 4:32 PM
it works, thx