I'm using JSAPI 3.8 on AGS10.2.1.I'm creating a very simple print task like this
var url = configuration.servicesHome + "/Utilities/PrintingTools/GPServer/Export Web Map Task";
console.log(url);
var template = new PrintTemplate();
template.layoutOptions = {
titleText: "Selected Work",
legendLayers: []
};
template.format = "PDF";
template.layout = "A4 Landscape";
template.exportOptions = {
width: 1024,
height: 786,
dpi: 96
};
var params = new PrintParameters();
params.template = template;
params.map = map;
showLoading();
var printTask = new PrintTask(url);
printTask.execute(params, function(results){
window.open(results.url);
hideLoading();
});
If I check the request, I get a value for Web_Map_as_JSON that looks like this...
{
"mapOptions": {
"showAttribution": true,
"extent": {
"xmin": 503082.44985599886,
"ymin": 6944909.337356286,
"xmax": 503759.78454400157,
"ymax": 6945403.050843714,
"spatialReference": {
"wkid": 28356,
"latestWkid": 28356
}
},
"spatialReference": {
"wkid": 28356,
"latestWkid": 28356
},
"scale": 1999.9999999999995
},
"operationalLayers": [{
"id": "layer2",
"title": "layer2",
"opacity": 1,
"minScale": 1000000,
"maxScale": 200,
"url": "http://gisapps/ArcGIS/rest/services/gis_cache_prd/MapServer"
},
{
"id": "layer3",
"title": "layer3",
"opacity": 1,
"minScale": 1000000,
"maxScale": 200,
"url": "http://gisapps/ArcGIS/rest/services/gis_client_prd/MapServer"
},
{
"id": "layer4",
"title": "layer4",
"opacity": 1,
"minScale": 500000,
"maxScale": 0,
"url": "http://gisapps/arcgis/rest/services/work_orders_prd/MapServer",
"visibleLayers": [1,
3,
4,
5,
6,
7],
"layers": []
},
{
"id": "graphicsLayer5",
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": []
}
},
{
"id": "graphicsLayer6",
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": []
}
},
{
"id": "graphicsLayer7",
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": []
}
},
{
"id": "graphicsLayer8",
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": []
}
},
{
"id": "graphicsLayer9",
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": []
}
},
{
"id": "map_graphics",
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": [{
"layerDefinition": {
"name": "pointLayer",
"geometryType": "esriGeometryPoint"
},
"featureSet": {
"geometryType": "esriGeometryPoint",
"features": [{
"geometry": {
"x": 503421.1172000002,
"y": 6945156.1941,
"spatialReference": {
"wkid": 28356,
"latestWkid": 28356
}
},
"attributes": {
"SITE_SUN": 1529778
},
"symbol": {
"color": [0,
255,
0,
64],
"size": 13.5,
"angle": 0,
"xoffset": 0,
"yoffset": 0,
"type": "esriSMS",
"style": "esriSMSSquare",
"outline": {
"color": [0,
255,
0,
255],
"width": 0.75,
"type": "esriSLS",
"style": "esriSLSSolid"
}
}
}]
}
}]
}
}],
"exportOptions": {
"outputSize": [1024,
786],
"dpi": 96
},
"layoutOptions": {
"titleText": "Selected Work",
"scaleBarOptions": {
},
"legendOptions": {
"operationalLayers": []
}
}
}
And the resulting map appears as I expect.If however I add a layer definition to one of the layers such that the resulting Web_Map_as_JSON is this
// Everything is identical except the layer definition on "layer4" which now looks like this...
//...
{
"id": "layer4",
"title": "layer4",
"opacity": 1,
"minScale": 500000,
"maxScale": 0,
"url": "http://gisapps/arcgis/rest/services/work_orders_prd/MapServer",
"visibleLayers": [1,
3,
4,
5,
6,
7],
"layers": [{
"id": 7,
"layerDefinition": {
"definitionExpression": "LAST_SCH_DATE >= date '2014-4-1' and LAST_SCH_DATE <= date '2014-8-31'",
"layerTimeOptions": null
}
}]
},
// ...
That layer ("layer4") no longer appears on my print map and I can see a "severe" error in my ArcGIS server log which reads "layer4: invalid or corrupt file".Has anyone else had success adding layer definitions (particularly when using dates and/or other standardized queries) to maps for print tasks?