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

Better way to add labels?

Topics: Data Access, SharpMap v0.9 / v1.x
Apr 9, 2012 at 2:56 PM

I'm using SharpMap to build up a static map image for inclusion in auto-generated print products.  For the most part it is going well but I've run into an issue with including labels which is giving me a headache.  When building out my map I can't directly tie into a database provider.  The marker information is stored in memory data structures and then fed into the map generator code.  This isn't a problem for the markers as I can pass an array of Geometry objects to a GeometryProvider object which is then used to build a layer.

Labels don't seem to work as easily.  So far I haven't found a way to pass in a list of structures (or classes) with the labels and their coordinates.  The way I'm getting around it currently is to manually build a DataTable object and then feeding that to the DataTablePoint class available in SharpMap.Extras.  This works but introduces a couple of issues.  First, it just seems very ineligant to convert the data into such a heavy object as the DataTable.  Most important, the SharpMap.Extras class is linked against a number of other libraries and if they are not included with the extras DLL I end up with a number of compiler warnings.

Is there a way to add labels to the map from in memory structures without passing through the classes above?  It would be nice if there was something like the DataTablePoint class which could consume an IEnumerable<> collection and then use reflection (or lambda parameters as the LINQ ToDictionary method uses) to get the data back out.


Apr 10, 2012 at 1:59 AM


You can use GeometryFeatureProvider in Sharpmap


Apr 10, 2012 at 12:15 PM

That works great.  Thanks.