MapBox can not display LabelLayer

Dec 2, 2013 at 5:46 AM
Hi all,
I am programing with SharpMap 1.0, i want to display a polygon in a vector layer and display this vertices to a label layer.
My code
VectorLayer vLayer=new VectorLayer("vLayer");
        LabelLayer lLayer=new LabelLayer("lLayer");
        string wkt="POLYGON ((572654.16800000006 1115392.176, 572637.045 1115400.1030000001, 572636.52100000007 1115411.663, 572668.393 1115397.928, 572688.089 1115391.342, 572700.322 1115384.406, 572703.193 1115382.281, 572699.368 1115370.496, 572654.16800000006 1115392.176))";
        NetTopologySuite.IO.WKTReader reader=new NetTopologySuite.IO.WKTReader();
        Polygon p = (Polygon)reader.Read(wkt);
        vLayer.DataSource=new SharpMap.Data.Providers.GeometryProvider((IGeometry)p);
        VectorStyle vStyle=new VectorStyle();
        vStyle.Fill =Brushes.Transparent;
        vStyle.EnableOutline=true;
        vLayer.Style = vStyle;
        mapBox1.Map.Layers.Add(vLayer);

        FeatureDataTable fdt=new FeatureDataTable();
        fdt.Columns.Add(new DataColumn("id",typeof(uint)));
        fdt.Columns.Add(new DataColumn("Label",typeof(string)));
        fdt.AcceptChanges();

        int index=1;
        DataTable dtVertice=CreateTable();
        foreach(Coordinate c in p.ExteriorRing.Coordinates)
        {

            NetTopologySuite.Geometries.Point point =new NetTopologySuite.Geometries.Point(c.X,c.Y);
            FeatureDataRow fdr=fdt.NewRow();
            fdr.ItemArray = new object[]{index,index.ToString()};
            fdt.Rows.Add(fdr);
            fdr.Geometry = (IGeometry)point;
            index++;

            /*
            DataRow dr = dtVertice.NewRow();
            dr["FID"] = index;
            dr["X"] = c.X;
            dr["Y"] = c.Y;
            dr["LabelColumn"] = index.ToString();
            dr["RotationColumn"]=0;
            dtVertice.Rows.Add(dr);
            */
        }
        //FeatureDataTable fdt=new FeatureDataTable(dtVertice);
        lLayer.DataSource=  new SharpMap.Data.Providers.GeometryProvider(fdt);
lLayer.LabelColumn = "Label";
        LabelStyle lStyle=new LabelStyle();
        Font font=new Font("Times New Roman",10,FontStyle.Regular,GraphicsUnit.Point);
        lLayer.Style = lStyle;
        mapBox1.Map.Layers.Add(lLayer);
        mapBox1.Map.ZoomToExtents();
        mapBox1.Refresh();
It can not display anything.
if i do not add label layer, mapBox display a polygon, its ok.
what wrong in my code?
Thanks,
Coordinator
Dec 2, 2013 at 6:47 AM
If you want to label sth you need to use GeometryFeatureProvider.
Dec 3, 2013 at 1:09 AM
Many thanks, FObermaier.