ThinkGeo.com    |     Documentation    |     Premium Support

Using of WmsImageLayer

I try to use an WmsImageLayer. In the Quick Starts I found only a Samples to use WmsLayer with "map.BackgroundMap.WmsMap". This is very nice, but I search an solution to bind 2 or more WmsLayer to my map.


So I have found the WmsImageLayer object. But I can not show the layer in the map. I get infos like boundingbox and server layer names but I show nothing in my map. What is wrong? I have tryed to add the layer as dynamic layer or as static layer to the map, same with the same result - no image :-(


Her is my code:


WmsImageLayer wmsLayer = new WmsImageLayer(new Uri(lgbWmsUrl)); 



if (!wmsLayer.IsOpen)

{

   wmsLayer.Open();

}



wmsLayer.IsVisible = true;

wmsLayer.IsTransparent = true;

wmsLayer.ActiveStyleNames.Add("1");

wmsLayer.Crs = "EPSG:4326";

this.map.CurrentExtent = wmsLayer.GetBoundingBox();

wmsLayer.TimeoutInSecond = 35;

wmsLayer.OutputFormat = "image/png";



foreach (string name in wmsLayer.GetServerLayerNames())

{

   wmsLayer.ActiveLayerNames.Add(name);

}



this.map.DynamicLayers.Add("Wms Layer", wmsLayer);




wmsLayer.Close();

 

This code shows me the wms layer in the map, but I have 2 or more WmsLayer to bind to map...


this.map.BackgroundMap.WmsMap.Name = "Wms LGB Layer";

this.map.BackgroundMap.WmsMap.ServerPath = lgbWmsUrl;

this.map.BackgroundMap.WmsMap.Parameters.Add("layers", "somelayername"));

this.map.BackgroundMap.WmsMap.Parameters.Add("FORMAT", "image/png");

this.map.BackgroundMap.WmsMap.Parameters.Add("id", "0");

this.map.BackgroundMap.WmsMap.Parameters.Add("TRANSPARENT", "true");

this.map.BackgroundMap.WmsMap.Parameters.Add("SRS", "EPSG:4326");

 

could you help me please?


Anke



Anke, 
  
 Thanks for all the information.  We will check into the WmsImageLayer and see why it is not drawing.  We will try a publicly accessible WMS server for the test.  I will let you know the results soon. 
  
 David

Anke, 
  
 Just wanted to follow-up and let you know we haven’t had time to do the test yet but we will shortly.  Is there any more information you could give me?  Would it be possible for you to tell me the WMS site you are hitting and its parameters?  If they are sensitive you can send them via e-mail to support@thinkgeo.com and ask it to be forwarded to David.  
  
 David

Anke, 
  
 I tested the code you provided and found that you did not set the UpperThreshold and LowerThreshold of the WmsImageLayer.  You will need to add these two lines: 
                  
                 wmsLayer.UpperThreshold = double.MaxValue; 
                 wmsLayer.LowerThreshold = 0; 
   
 I used our own WMS server locally so I wasn’t able to test your specific one.  I also entered an issue so that we use this as the default in the future otherwise I think other will be confused as well.  Thanks for reporting this! 
  
 David.

David,


if I set:


wmsLayer.UpperThreshold = double.MaxValue; 

wmsLayer.LowerThreshold = 0;


I see only a pink background and a little red x. So I see less as without setting treshold (I see my other statis layers from shape file). If I set  LowerThreshold  to 0 and UpperThreshold  to 1000, I see my other layers but no wms layer (like without setting treshold). So I think this is not the problem, or?


Anke



Anke


I think the problem may be that no ActiveLayers were set on the WMSImagelayer Object.  I was able to modify the LoadAWMSLayer sample under the "Satelite Imagery" section with the attached code and it seemed to work.  Can you give this code a try and let us know if it resolves the issue?


Thanks!



33-Code.txt (668 Bytes)

I have tried your code and the sample is be functional with my wms layer url too. So I have look to my code and found 2 defective lines:


wmsLayer.ActiveStyleNames.Add("1"); 

wmsLayer.OutputFormat = "image/png";


Without these to lines, my sample shows the wms layer. And i have definitely and Style with the titel "1" in the GetCabability of the wms layer and an format form "image/png" to. Because with this 2 settings and the settings for treshold I see only a pink layer!


Thank you for your help.


Anke from germany :-)



Is your WMS Server Local?  If so can you check the logs on the web server and see what type of URL is being formulated by the Map Control and see what happens when you put that same URL in the browser?  There may be a bug or the server is expecting soething in a slightly different format.


In a future version we will expose a property so you can get the URL that the Map Control creates and easily test it in a browser to help troubleshoot problems.


Thanks!



Today I have a new question, because the WmsImageLayer, so I post this in the same Thread.


My wms layer has 4 Styles:


Name = "1"; Title = "Darstellungsvariante Standard" 

Name = "2"; Title = "Darstellungsvariante Amtlich" 

Name = "3"; Title = "Darstellungsvariante Grauton" 

Name = "5"; Title = "Darstellungsvariante Farbreduziert"


This informations are inherit into the GetCabability of my wms layer as <Style>-Tag.


When I open the WmsImageLayer and try to read GetServerStyleNames, I get 0 items. I think it should be 4, isn't it so?


wmsLayer.Open(); 

Collection<string> styleNames = wmsLayer.GetServerStyleNames(); 

wmsLayer.Close();

When I try to set ActivStyleName to "3" for example, the layer is only pink and I see nothing else!


wmsLayer.ActiveStyleNames.Add(styleName);

But if I set the Style of to Background Wms Layer, I get no errors and I see the correct style.


this.map.BackgroundMap.WmsMap.Parameters.Add("STYLES", "3");

Could you help me by this problem, please? How can I set the style for the wms image layer? And thy I get no result by call the Method GetServerStyleNames?


Anke



Anke, 
  
 Can you provide the URL to the WMS web service so we can try to recreate it here? 
  
 Thanks! 
  
 

I had send you this with mail, respectively  I send it at 22.09.2008 to support@thinkgeo.com for David. Because it are sensitive data… 
  
 Bye Anke

Anke, 
  
 Your e-mail must have been accidently overlooked or caught by our junk-mail filter. Can you resend this information to support?

Anke,  
  
 Thanks for the additional information. We are taking a look at the problem.

Anke,


I believe the problem is the bounding box

Try referencing the bounding box I set below.



mapEngine.CurrentExtent = ExtentHelper.GetDrawingExtent(new RectangleShape(11.2, 53.5, 14.8, 51.3), 740, 528);


            WmsRasterLayer wmsImageLayer = new WmsRasterLayer(new Uri("url"));


            wmsImageLayer.Open();

            foreach (string layerName in wmsImageLayer.GetServerLayerNames())

            {

                wmsImageLayer.ActiveLayerNames.Add(layerName);

            }

            wmsImageLayer.ActiveStyleNames.Add("3");

            wmsImageLayer.

            wmsImageLayer.Close();


            mapEngine.StaticLayers.Add("wmsImageLayer", wmsImageLayer);


You can use wmsImageLayer.GetRequestUrl(new RectangleShape(11.2, 53.5, 14.8, 51.3), 740, 528) get request url, and it works.


ThinkGeo Support 



Hello Ryan,


You have posted in your code somthing for the "WmsRasterLayer". I use the Map Suite Web 3.0.2 (Beta) and there is no "WmsRasterLayer" given. Have you used the new version, which would be releasead in the next days?


If I use:


wmsImageLayer.ActiveLayerNames.Add("3");" 


at WmyImageLayer object in version 3.0.2 with my wms layer, I see only a pink page (see post from 10-06-2008 07:13 AM). If I set the style at the wms background layer I see the correct style:


this.map.BackgroundMap.WmsMap.Parameters.Add("STYLES", "3");


 


I have also the problem by using "pan", the wms layer slips - so that the shape file (or for example google maps layer) and my wms layer do not stay on top of each other. To explain this, I created 3 images:


Image "Perfect_location.jpg" - the position is correct - the google border and the wms border stays on top of each other


Image "shifted_location_1.jpg" - the position is shifted - I think you can see the white border and the border of my wms layer


Image "shifted_location_2.jpg" - the position is shifted - I think you can see the white border and the border of my wms layer (top right)


 


I hope you can help me


Anke



Anke,  
  
 The WMSRasterLayer is simply a rename of the WMSImageLayer that we will be using in a future release. So for the time being you should be able to use WMSImageLayer and have the image show properly with the version you currently have. With the later version you will be able to use WMSImageLayer as we will make it backwards compatible. 
  
 The problem with the WMS layer slipping is a known issue and one that we have resolved for the next release. Basically you need to manually set a style for the map such as Align = Left and this ‘slipping’ will go away. We will do this automatically for you in the next release. 
  
 ThinkGeo Support