ThinkGeo.com    |     Documentation    |     Premium Support

Adding a WMS layer: "LAYERS parameter missing"

Hello,


I am trying to add a WMS image to my map control. When I try to either open the WMSFeatureLayer or do a map.refresh after adding the layer and associated overlay to the map, I receive the following error:


"LAYERS parameter is missing"


The code I am using so far is as follows:


 


        Dim overlayRaster As New LayerOverlay

        Dim layerWMS As New WmsRasterLayer(New Uri("giswebservices.massgis.state.ma.us/geoserver/wms?"))
        layerWMS.Parameters.Add("LAYERS", "massgis:GISDATA.IMG_COQ2005")
        layerWMS.Parameters.Add("SRS", "EPSG:26986")
        layerWMS.Parameters.Add("FORMAT", "image/gif")

        overlayRaster.Layers.Add(layerWMS)

        map.Overlays.Add("Raster", overlayRaster)

map.Refresh


I was trying to retrieve the URI by doing layerWMS.GetRequestUrl but it seems the layer must be open first and this error occurs durring layerWMS.Open as well. Any help is appreciated.

Thanks.



Nelson,


Thanks for your post.
 
I think the hidden problem is that when you add layers, you probably need to add it to the ActiveLayerNames instead of add it to Parameters.

Dim layerWMS As New WmsRasterLayer(New Uri("giswebservices.massgis.state.ma.us/geoserver/wms?"))
'layerWMS.Parameters.Add("LAYERS","massgis:GISDATA.IMG_COQ2005" )
layerWMS.Parameters.Add("SRS", "EPSG:26986")
layerWMS.Parameters.Add("FORMAT", "image/gif")
layerWMS.ActiveLayerNames.Add("massgis:GISDATA.IMG_COQ2005")

 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

Thanks Yale. I had come across this property but it is labeled as ReadOnly so I hadn’t bothered to try. Thanks again!

Glad that resolved the issue! 
  
 Thanks!

Nelson, 
  
 Thanks for letting us know your staut. The Parameters is aproperty to add some special parameters , which did not include the ActiveLyaers. Sorry to make you misunderstand. 
  
 Thanks. 
  
 Yale