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(); });
{ "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": [] } } }
// 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 } }] }, // ...
Disabling dynamic layers resolves this problem, but it's an unsatisfying fix. Why would having dynamic layers enabled somehow prevent the use of layerDefinition elements in the ExportWebMap schema? This issue still exists at 10.5.1, and the layerDefinition (and definitionExpression) aren't being hand-coded, they're a built-in property of the esri.Map object in the JavaScript API that's passed into the parameters of a esri.tasks.PrintTask. DynamicLayers support definitionExpressions, so why the incompatibility?
Bug. https://community.esri.com/message/658246-imageparameterslayerdefs-does-not-work-with-105
Worse: regression bug on 10.5.1...