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

Sharpmap layer

Topics: Algorithms, SharpMap v0.9 / v1.x, SharpMap v2.0, Web Controls, WinForms Controls
Dec 8, 2010 at 2:22 PM

Hi Felix,

I have a created a layer by javascript and openlayers, now I want to call the same layer using sharpmap.

I am using openlayers map with follwing code.


<html xmlns="">
    <title>MapServer Layer</title>
    <style type="text/css">
            width: 800px;
            height: 475px;
            border: 1px solid black;
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        var map, layer;

        function init() {
            map = new OpenLayers.Map('map');
            layer = new OpenLayers.Layer.MapServer("OpenLayers WMS",
       "", { layers: 'continents' });
<body onload="init()">
    <div id="map">
 Note:the above  code is working fine. and I am getting map as well as layer.


but now I am calling same layer, but with sharp map  I am using this below code.


  string wmsUrl = "";
                WmsLayer layWms = new WmsLayer("WMS", wmsUrl);
                //Map Server Transparancy 
                layWms.Transparancy = true;           
                layWms.ContinueOnError = false;
                layWms.BgColor = System.Drawing.Color.Red;
                layWms.Enabled = true;
                //Set timeout to 5 seconds
                layWms.TimeOut = 5000;
                //Map Server Projection ID            
                layWms.SRID = 4326;
the map and layer is not coming, what I am doing wrong?
Please guide me to do this?
thanks for the help,.

Dec 8, 2010 at 3:21 PM

Hello vivek,

I just inserted your code in the WmsSample.cs of the WinFormSamples project and I do not get an empty image.

Do you have one or some other layer(s) added and if so, what are their bounding boxes?

Cheers FObermaier

Dec 8, 2010 at 3:36 PM

Hi FObermaier,

I just sent a email to you !

thanks for the help!

Dec 8, 2010 at 3:49 PM

Hi FObermaier,

As per my email, I am having two layers one is OSM layer and another one is continents layer. but I am running one layer at a time.

and If i run OSM layer I am getting marker and Map but when I am running continents layer I am getting only marker but not the map layer.

Please help me to get out of this.


Vivek Kumar.



Dec 8, 2010 at 4:37 PM

Hi FObermaier,

Did you get I am doing wrong? did you get my email?

thanks for the help!



Dec 9, 2010 at 7:37 AM

Hi FObermaier,

Still I am getting blank screen.

Please guide me


Dec 9, 2010 at 10:29 AM

Please give us good information about where it's going wrong.

Please do so using the debugger of VS and by setting breakpoints when adding this WMS layer and other relevant lines of your code. Then go through each line of the code step by step and step into the classes of Sharpmap to find out which lines of code work and which ones don't. Add watches to the crucial variables in your code and the sharpmap code to see what's happening here.

We cannot look into your computer to see what's happening there, so you should post relevant stack traces or tell us where it goes wrong in your code.


Alternative solution would be that I would fix your code and provide you with all you need, but this comes at a very high price and I certainly don't have time until March to do so.

Dec 9, 2010 at 12:50 PM

Hi PeaceNlove,

thanks for the reply.
Actually I am using map server Url to call map layer with osm layer. I want both map layer rest of the things like zoom in and zoom out and of the other OSM map is working.
even I am adding markers on the map.but when I am doing map server layer nothing is coming out.
here is my code , hope you can understand this,.
kindly note my osm layer is working but the map server layer is not working.
when I comment OSM layer I am getting blank layer. ideally I should get map server layer,.

       public  static Map InitializeMap()

                var map = new Map();
                //--> Get OSM Layer         
                var osmLayer = new TileLayer(new OsmTileSource(), "OSM");
                //--> Get Map sever layer 
                string wmsUrl = "";
                WmsLayer layWms = new WmsLayer("WMS", wmsUrl);

                layWms.ContinueOnError = true;
                //Skip rendering the WMS Map if the server couldn't be requested (if set to false such an event would crash the app)
                layWms.TimeOut = 5000; //Set timeout to 5 seconds
                layWms.SRID = 4326;
                //limit the zoom to 360 degrees width
                map.MaximumZoom = 360;
                map.BackColor = Color.LightBlue;
                map.Zoom = 360;
                map.Center = new Point(0, 0);
                return map;


Dec 10, 2010 at 6:43 AM

How hard is it to use your debugger and to evaluate each line of code sharpmap uses to make this WMS layer?

I cannot help you if you don't put a breakpoint at this line:  WmsLayer layWms = new WmsLayer("WMS", wmsUrl);
When you've set this breakpoint you will step into each line of code, until all code has finished
When you do this, you will look into each variable to evaluate its value and you will have to recognize whether this value is correct
When you see a strange value in the variable, you will think about where it might stem from.
When you see a strange value in the variable, you first have to find a solution yourself
, when you see an error which you cannot understand at all, you can ask your question here.

If you would like to let me debug your code, me and my boss will be very happy to do so and it will cost you only $1000.00 a day. In other words: show some initiative instead of letting us debug your code.

Dec 10, 2010 at 11:12 AM
Edited Dec 10, 2010 at 11:13 AM

You may want to set your Timout to 30 seconds (that would be 30000) to see if you have a bottleneck internet connection

Dec 10, 2010 at 12:17 PM

Hi PeaceNlove,

thanks for the  great respone like $1000.00 a day.

I won't ask any question again.

thanks again

Dec 10, 2010 at 12:18 PM

Hi FObermaier,

thanks for the reply.

Dec 10, 2010 at 12:29 PM


Try replacing this line:

map.Center = new Point(0, 0);


Dec 10, 2010 at 1:52 PM
vivekkumar wrote:

Hi PeaceNlove,

thanks for the  great respone like $1000.00 a day.

I won't ask any question again.

thanks again


it is annoying for people who want to help you solve your problem, if they ask you to take certain steps (e.g. debug line-by-line, investigate variables, unexpected behaviour), they get as a reply the information you already posted earlier.

If the Timeout really was the problem, I'm almost certain that you would have found that, or at least the place where you get the webrequest fails, if you had followed PeaceNloves advice.

Cheers FObermaier