This project has moved and is read-only. For the latest updates, please go here.

SharpMap and Mono

Topics: SharpMap Project, WinForms Controls
Apr 28, 2008 at 12:24 AM
Hello there,

first let me thank you for providing us (the IT Crowd) with such a wonderful toolset for doing GIS-stuff with good 'ol .net. This Library is the first really usable thing I've found besides CarbonTools Lite. My Application needs a Map Control which is suplied with Tiles from our Tilecache based WMS-C server and everything is working so far thanks to your TiledWmsLayer implementation. My App however is also designed to support Windows, Linux and Mac OS X (via Mono) and even if the MapImage Control does only refer to Syste.Drawing (which should work nicely within mono, according to it seems that SharpMap and/or SharpMap.UI has certain problems with Mono (altough it compiled nicely...)

Is there some effort going on in making SharpMap a little more portable? If I could find some way to actually find out where the Problems are I would be pleased to support the project by helping to resolve theese incompabilities.

BTW.: The Code I use to display my slippy map within MapImage is the WMS-C implementation found at


Apr 28, 2008 at 10:04 AM
Edited Apr 28, 2008 at 10:06 AM
Hi Sebastian, I was recently chatting with KiboHely who is doing work with sharpmap/ mono/ gtk# he had managed to render a map to screen by editing MapImage.cs in the UI project. I am not a mono person at all but the following may help, it assumes you are also using gtk#:

In MapImage.Refresh()...
First call GetMap() to a get a bitmap.
then get a GtKPixelMap (perhaps pixel buffer or similar cant remember the name or find the docs link) from the bitmap.
Use this pixel buffer to create a GtkImage.
this can then be displayed on screen.
This was a partial solution because at that point the 'panning' didnt work.
I think this was fixed by caching the original bitmap after every call to Refresh and changing the panning code in the MapImage.cs project to use the cached bitmap to create new GtkImages while dragging before calling getmap again on drag end (or equivalent event). i.e edit MapImage_MouseMove:

Alternatively if you want to get your hands dirty you can have a look at the 1.1 experimental branch and have a go at creating your own IMapRenderer<Drawable> or IMapRenderer<GtkImage>

HTH jd
Apr 28, 2008 at 11:37 AM
Thanks for the information John. I will see if I can get MapImage to work altough my project doesn't use GTK#, but Windows.Forms.
Apr 28, 2008 at 12:37 PM
It seem's I can't get this thing to work. But I frankly can't understand why...there is no freaky stuff involved throwing some png tiles on a Control that extends PictureBox. :(
Apr 28, 2008 at 2:54 PM
I just captured the network traffic issued by SharpMap (using WmsTiledLayer) when running on .NET2.0 and Mono 1.9
The .NET2.0 instance does send GetCapablities followed by the expected GetMap request which load the tiles from the server, where as the Mono running instance seems to only send the GetCapabilities. Might this be the point to hook for solving this issue?
Apr 28, 2008 at 3:58 PM
Edited Apr 29, 2008 at 10:16 AM
hi MauiMauer,

KiboHely did manage to create simple mapImage in gtk#, so it should be possible. Maybe you can send him a codeplex notification.

Can you render an ordinary shapefile?

Did you include it as a project (advised) or as dll?

What happens when you put a breakpoint in the Map.GetMap request?

Apr 28, 2008 at 5:39 PM
Ok, I have resolved this issue. SharpMap.UI is all fine and runs out of the box on Mono.
It was right that none of the GetMap requests seemed to make their way trough to the server.

Mono would always throw a "Request timed out" WebEx (don't ask me why, the Timeout Value seems to be okay)

However by removing the following lines from WmsGetMap I was able to make it work:

webRequest.Method = resource.Type;
webRequest.Timeout = this.TimeOut;