I have a FeatureLayer, that I would like to render using the same scheme as an existing REST service sublayer. I thought if I made a MapImageLayer based on the REST service, I could use the sublayer's renderer property. However, this property seems to be designed only for overriding the REST service, not for getting the info from the service. (The property shows up as null.)
Anyone know a way of getting this info?
Solved! Go to Solution.
Jim,
You can do this if you use a esriRequest to get the drawingInfo from the sub layer and then use jsonUtils.fromJson ('esri/renderers/jsonUtils') method to create the renderer.
esriRequest({
url: YOUR_layerUrl,
content: {
f: 'json'
},
handleAs: 'json',
callbackParamName: 'callback'
}).then(lang.hitch(this, function (layerInfo) {
var rend = jsonUtil.fromJson(layerInfo.drawingInfo.renderer);
}));
Jim,
You can do this if you use a esriRequest to get the drawingInfo from the sub layer and then use jsonUtils.fromJson ('esri/renderers/jsonUtils') method to create the renderer.
esriRequest({
url: YOUR_layerUrl,
content: {
f: 'json'
},
handleAs: 'json',
callbackParamName: 'callback'
}).then(lang.hitch(this, function (layerInfo) {
var rend = jsonUtil.fromJson(layerInfo.drawingInfo.renderer);
}));
Thanks, Robert! I forgot to mention that I was using 4.6, but once I adjust for that version, it works fine. Much appreciated!