WMS tutorial

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Jun 7 at 2:19 PM
I have done the SharpMap WMS tutorial and it works great with the provided sample data. But when I try to use a Swedish WMS service then I only see the shapefile. Any Idea?
        SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("Klimat");
        vlay.DataSource = new SharpMap.Data.Providers.ShapeFile("C:\\Shapefiles\\Klimat.shp", true);
        mapBox1.Map.Layers.Add(vlay);
        mapBox1.Map.ZoomToExtents();
        mapBox1.Refresh();
        mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;


        string wmsUrl = "http://resource.sgu.se/service/wms/130/brunnar";
        SharpMap.Layers.WmsLayer layWms = new SharpMap.Layers.WmsLayer("Brunnar", wmsUrl);
        layWms.AddLayer("grundvatten:SE.GOV.SGU.BRUNNAR.250K");
        layWms.SetImageFormat(layWms.OutputFormats[0]);
        layWms.ContinueOnError = true;
        layWms.TimeOut = 10000; 
        layWms.SRID = 3006; //SWEREF99TM
        mapBox1.Map.Layers.Add(layWms);
        mapBox1.Map.BackColor = Color.White;
        mapBox1.Map.ZoomToExtents();
The shapefile I use as baselayer have the same projection as I request from the WMS service.
Why do I need to add a shapefile before I add a WMS layer? If I remove the code that add the shapefile layer in the working WMS tutorial sample I get a blank MAP. I have used nuget to get the latest version of SharpMap (1.1)
Coordinator
Jun 8 at 6:59 AM
There is nothing wrong with your code. The server is just not able to deliver a result within the set timeout.
When you configure logging for your application, you can read the url that is being requested.
If you put that in your browser, you can wait for several minutes to get a result. So far, I have not received one yet :).

This is an issue I cannot help you with, you have to contact the wms service provider.

If you set the SRID to 4326, you will get a result within reasonable time.
Marked as answer by stenvall on 6/8/2016 at 12:13 AM
Jun 8 at 7:23 AM
Thank you! Maybe I can use tiling to speed things up? I make a new thread for that question.
Jun 8 at 9:22 AM
stenvall wrote:
Why do I need to add a shapefile before I add a WMS layer? If I remove the code that add the shapefile layer in the working WMS tutorial sample I get a blank MAP.
When I zoom in the WMS layer shows... Why do I have to do this... shouldnt the line "mapBox1.Map.ZoomToExtents();" take care of this?
        SharpMap.Layers.WmsLayer wmsL = new SharpMap.Layers.WmsLayer(
 "US Cities",
 "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer");
        wmsL.SetImageFormat("image/png");
        wmsL.Version = "1.1.0";
        wmsL.AddLayer("2");
        wmsL.SRID = 4326;
        mapBox1.Map.Layers.Add(wmsL);
        mapBox1.Map.ZoomToExtents();
        mapBox1.Refresh();
        mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;