[OpenLayers-Users] How to get get the WMS-layer's parameters

Tim Schaub noreply at geocartic.com
Tue Jun 19 16:00:37 EDT 2007


Hey-

yangzhaohui wrote:
> Hello dear sir,
>    I have a question about Openlayers.In order to make a print image 
> demo,I want to know how to get the WMS parameters(like 
> name,url,param,option) of a wmslayer in a running Openlayers 
> application.So that I can open a new window with those parameters to 
> print the current image.Thank you very much!
>  Best wishes for your! 
>                                                         Sincerely yours,
>                                                               Yang                                                                                                                     

Assuming your map is assigned to a variable called "map", you can get 
the detail you're looking for this way:

var layer = map.layers[0];
// layer.options is the options object for the layer
// layer.name is the title for the layer in your map
// layer.url is the base url for the layer

var params = layer.params;
// params["LAYERS"] is a comma delimited string of WMS layer names
// params["FORMAT"} is the format that goes in the GetMap request
// etc.

var request = layer.getURL(map.getExtent());
// request is the full request string for the current extent

// Tim





More information about the Users mailing list