Creating Background Map for SharpMap Output

Oct 21, 2010 at 1:51 PM


I am curently working on a project involving the graphical output of Pipelines and have a little trouble getting into your library...

OUr porject is a Desktop project that should draw pipelines onto a MapBox (we used SharpMap for this task).

What we now want to do is to use BruTile to get the neccessary Tiles for the Background Map so the user has a better overview.


We want to use the Map information from Openstreetmap, but I don't understand the structure of BruTile and how I can make it work with SharpMap,

as I cannot find any working demos or Documentation that helped me out with this one, i wanted to ask you directly if you might know were I could find any

Documentation regarding BruTile/SharpMap or if you would be kind enough to explain it to me.


With best regards and hopes

Marc Reinmayr

Oct 21, 2010 at 2:12 PM

Hi Marc,

The SharpMap trunk (and today's release) include a WinFormsSample with tile layers, including OSM:

Adding an OSM layer can be done with:

map.Layers.Add(new TileLayer(new OsmTileSource(), "TileLayer - OSM with XLS"));

Keep in mind that the OSM tiles are in SphericalMercator so your vector data should also be in SphericalMercator (or projected to it).


Oct 21, 2010 at 2:19 PM

Thanks for the (very very) quick reply!

This definitly looks like something I should look into, but just a little question in detail:

Is it possible with this method to cache the Tiles localy? Most of our users wont have internet access all the time.

Thank you for the help!

Oct 22, 2010 at 11:09 AM

The OsmTileSource has no cache. You can always construct any kind of TileSource from the lower level components, but it is not that straight forward. Here a Osm TileSource with File Cache:

            var osmTileSource = new TileSource(new WebTileProvider(
                new TmsRequest(new Uri(""), "png"), new FileCache(@"c:\temp\BruTile", "png"))
                , new SphericalMercatorInvertedWorldSchema());

It should be easier to do things like this. Hope to find some time for it soon.


Nov 22, 2010 at 8:46 AM

Thank you very much again for the quick reply.

We now implemented both ways into our programm, but all we get from both Methods is a Redframe and Cross behind our Map.

I guess it is because of the SpericalMercator and our Shapefile might not be in the right projection for it.

If this is the case could you give us any hints or directions on how to achieve the right projection?

Thank you very much for your help so far!


Marc Reinmayr

Nov 22, 2010 at 9:48 AM

In case of a projection problem I would not expect the cross but just a white surface. Did you manage to get the tiles working in a separate project without your own data? 

Projection might be a problem anyway. Tiles can not be projected, so your own data need to be projected to SphericalMercator. This should be done by adding projection info to that layer. Fobermaier has just committed a new projection library to SharpMap. He probably committed some samples too.


Dec 16, 2010 at 2:21 PM

Hello Paul!

After a long struggle we still weren't able to get any MapTiles from OSM, all we get is the Red Cross/Frame

Even when trying to access small amounts of Data or none at all.

I would really appreciaty it if you could help us out again.

With best regards

Marc Reinmayr

Dec 17, 2010 at 3:13 PM

hi Marc, 

First, If you download the most recent source code of SharpMap, and start the WinFormSample project, and run the OSM tile sample, do you see OSM tiles?


Dec 29, 2010 at 12:45 PM

Hi Paul!

Sorry for responding that late. I had to play around with SharpMap a lot and our Development Team hat a little trouble.

I was now able to run the latest release of SharpMap and start the WinFormSamples, and they do work perfectly.

I used there code as reference but I still get nothing else than the red cros/frame.


With best regards

Marc & the Development Team^^

Jan 13, 2011 at 3:02 PM

Hello again!

I thank you again for all the support and also for the way cach images locally

I was now able to run BruTile correctly and get Map Material as well as caching it loacally!

Thank you very much for your patience in answering my questions!

Kind Regards

Marc Reinmayr