Select to view content in your preferred language

How to Override STYLES= in WMS getMapUrl to specify a style?

1224
3
05-16-2013 07:14 AM
AmyRamsdell
Occasional Contributor
Through the js api http://developers.arcgis.com/en/javascript/jsapi/wmslayer.html, I see no way to override the getMapUrl to inject a STYLES parameter value in the getMapUrl. We added it to the beginning of the string and it worked for awhile to bring back the correct style but something changed on the wms server and now it returns an error that STYLES cannot be defined twice.

http://lcat.usgs.gov/geoserver/cbntn/wms?STYLES=cbntn_indicators_tsscombo&SERVICE=WMS&REQUEST=GetMap...

We were able to get around this by forcing the request through a proxy and changing it there but is there a better way?
0 Kudos
3 Replies
derekswingley1
Deactivated User
You can use setRequestPreCallback to manipulate the URL for the request before it's sent.
0 Kudos
AmyRamsdell
Occasional Contributor
We have been unsuccessful at getting this to fire for a wms layer.  Putting an alert in the function passed to esri.setRequestPreCallback never fires when adding the WMS Layer but we can verify that it fires for other layers including a KML layer.

I don't believe it has anything to do with the creation of the wms layer but below is the code:

var wmsLayerInfo = new esri.layers.WMSLayerInfo({name:"cbntn:cbntn_indicators",title:"WMS Layer"});
         var info = {
            layerInfos: [wmsLayerInfo],
            extent: chesMap.map.extent
          };
          
          var wms = new esri.layers.WMSLayer(url,{
            resourceInfo: info,
            visibleLayers: ["cbntn:cbntn_indicators"],
            id: ''+chesMap.tempModel.getLabel(chesMap.tempItem)
          });
0 Kudos
derekswingley1
Deactivated User
You are correct, setRequestPreCallback does not fire for WMS layers. My mistake. I do not see a clear workaround for this.
0 Kudos