[GIS] How to use geoserver’s vendor specific parameters in openlayers

geoserveropenlayers-2

I want to rotate my map in openlayers. When I set an "angle" as an url option in geoserver openlayers preview, the map is rotated, but I can't seem to find the correct place in my openlayers html-file.

http://docs.geoserver.org/latest/en/user/services/wms/vendor.html

Best Answer

These vendor parameters need to be sent to geoserver from OpenLayers. hence the parameter needs to be put in the options of the constructor of your layer.

So the simple way of constructing our layer is like this:

var wms = new OpenLayers.Layer.WMS("My Layer",
                                   "http://example.com/geoserver/wms",
                                   {layers: "states"});

To pass on vendor parameters to the server, you'll need to do this:

var wms = new OpenLayers.Layer.WMS("My Layer",
                                   "http://example.com/geoserver/wms",
                                   {
                                    layers: "states",
                                    transparent: true, //standard WMS parameter
                                    angle: 45, //vendor specific parameter
                                    buffer:5 //vendor specific parameter
                                   });

These vendor specific parameters will be appended to the WMS requests that OpenLayers makes, and hence Geoserver will respond with an appropriate response.