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

How to assign custom labels to geometric shapes dynamicaly

Topics: General Topics
Jan 22, 2007 at 7:16 AM

I need to display geometric shapes' (polygons, lines, etc.) labels that are not read from shp file but determined in run time. Drawing shapes is ok but I couldnt assign labels to these shapes.

The code sample is below, when run this code it gives "Attribute data is not supported by the GeometryProvider."

System.Collections.Generic.List<SharpMap.Geometries.Geometry> GeomColl = new System.Collections.Generic.List<SharpMap.Geometries.Geometry>();

LabelLayer m_LabelLayer = new LabelLayer("Text Layer");
m_LabelLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(GeomColl);
m_LabelLayer.LabelStringDelegate = getString;

private static string getString(SharpMap.Data.FeatureDataRow fdr)
return "My custom label";

Thank you very much for your help..

Jan 22, 2007 at 9:02 PM

Unfortunately the Geometry Provider doesn't support attribute data at the moment.
Please try to use the OleDb Provider with a Access database.