Created
October 27, 2014 19:06
-
-
Save JimBlaney/932194537d151f8c151b to your computer and use it in GitHub Desktop.
Esri JSAPI layer to support STYLES argument on WMSLayer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"dojo/_base/array", | |
"dojo/_base/declare", | |
"dojo/_base/lang", | |
"esri/layers/WMSLayer" | |
], function( | |
array, | |
declare, | |
lang, | |
WMSLayer | |
) { | |
/* | |
* for each WMSLayerInfo, a "style" property has been added to indicate the | |
* active style for the individual layer. update the layerInfo's style property | |
* and finish with a call to layer::refresh() to update the layer in the map. | |
*/ | |
var StyledWMSLayer = declare(WMSLayer, { | |
getImageUrl: function(extent, width, height, callback) { | |
WMSLayer.prototype.apply(this, [ | |
extent, | |
width, | |
height, | |
lang.hitch(this, function(url) { | |
url = url.replace("STYLES=&", lang.replace("STYLES={styles}&", { | |
styles: array.map(array.filter(this.layerInfos, function(li) { | |
return this.visibleLayers.indexOf(li.name) !== -1; | |
}, this), function(li) { | |
return li.style; | |
}) | |
})); | |
callback(url); | |
}) | |
]); | |
} | |
}); | |
return StyledWMSLayer; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Jim, thanks for sharing. Could not get your code running , so I did a similar stunt based on Esri´s custom layer example: