swingley,Thank you for your reply/suggestion. I am not using setDynamicLayerInfos on my dynamic service before re-creating my legend, but would be happy to do so...if I could only understand how.I've found a couple of different explanations of the method online and about 3 or 4 examples of its use but, so far, have been unable to apply any of what I am seeing in them to my code in a way that works. The closest thing I've come up with (as far as I can tell regarding how I think it is supposed to work) is to try to set the layer's DynamicLayerInfos in the callback function where the generated renderer is applied: cbExecuteGenerateRendererTask: function(renderer){
var optionsArray = [];
var drawingOptions = new esri.layers.LayerDrawingOptions();
drawingOptions.renderer = renderer;
optionsArray[this.layerId] = drawingOptions;
this.layer.setLayerDrawingOptions(optionsArray);
this.layer.setVisibleLayers([this.layerId]);
// --------
// this.layer is instantiated elsewhere as: new esri.layers.ArcGISDynamicMapServiceLayer("serviceUrl");
// That mapping service contains 7 layers of data; only one is visible at any one time and a single
// attribute from that visible layer is used to generate the renderer for it.
//---------
if (this.dynamicLayerInfos === null){
this.dynamicLayerInfos = this.layer.createDynamicLayerInfosFromLayerInfos();
}
var dynamicLayerInfos = [];
var dynamicLayerInfo = new esri.layers.DynamicLayerInfo();
dynamicLayerInfo.id = this.layerId;
dynamicLayerInfo.source = this.dynamicLayerInfos[this.layerId];
dynamicLayerInfos.push(dynamicLayerInfo);
this.layer.setDynamicLayerInfos(dynamicLayerInfos);
}
I've tried doing the dynamicLayerInfos part before and after setting the drawing options and before and after setting the visible layers. The message I receive when "this.layer.setDynamicLayerInfos(dynamicLayerInfos);" makes the export request is invariably:{"error":{"code":400,"message":"Missing mapLayerId for dynamic mapLayer with 'id': 1.","details":[]}}
I'm not sure what "mapLayerId" it is referring to. There is a mapLayerId provided for the source in the JSON of the request, so I'm guessing it's not that one. The export request sent when I setDynamicLayerInfos on the service looks like this:http://<mydomain>/arcgis/rest/services/<myservice>/MapServer/export?dpi=96&transparent=true&format=png8&layers=show:-1&dynamicLayers=[{
"id": 1,
"source": {
"defaultVisibility": false,
"id": 1,
"maxScale": 0,
"minScale": 0,
"name": "Crops (vegetables, fruits, berries, nuts, nursery, sod, Christmas trees, greenhouse, mushrooms, and maple)",
"parentLayerId": -1,
"subLayerIds": null,
"source": {
"type": "mapLayer",
"mapLayerId": 1
}
},
"drawingInfo": {
"renderer": {
"type": "classBreaks",
"field": "FRUIT_FARM_NUM",
"minValue": 0,
"classBreakInfos": [{
"classMaxValue": 14,
"label": "0 - 14",
"description": "",
"symbol": {
"color": [204, 255, 204, 255],
"type": "esriSFS",
"style": "esriSFSSolid"
}
}, {
"classMaxValue": 59,
"label": "15 - 59",
"description": "",
"symbol": {
"color": [130, 217, 142, 255],
"type": "esriSFS",
"style": "esriSFSSolid"
}
}, {
"classMaxValue": 165,
"label": "60 - 165",
"description": "",
"symbol": {
"color": [72, 179, 100, 255],
"type": "esriSFS",
"style": "esriSFSSolid"
}
}, {
"classMaxValue": 298,
"label": "166 - 298",
"description": "",
"symbol": {
"color": [28, 142, 73, 255],
"type": "esriSFS",
"style": "esriSFSSolid"
}
}, {
"classMaxValue": 498,
"label": "299 - 498",
"description": "",
"symbol": {
"color": [0, 104, 55, 255],
"type": "esriSFS",
"style": "esriSFSSolid"
}
}]
}
}
}]&bbox=-14896912.62163498,3215744.8139635143,-5700009.378365019,10123206.186036486&bboxSR=102100&imageSR=102100&size=940,706&f=json
I've also tried playing around with this a bit in the "onUpdateEnd" handler but I can't get it to work there either and don't believe it would help there any more than in the GenerateRendererTask callback anyway.Can you be a bit more forthcoming re: the usage of this method?Cheers,jtm