operationalLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapServer, { "id": "collection" });
function addEqualBreaks(number, colorStart, colorEnd) { equalBreaksOptions[0] = number; //number of breaks equalBreaksOptions[1] = colorStart; equalBreaksOptions[2] = colorEnd; activeClassification = 2; // 2 = automatic //maximum of 12 classes: if (number > 11){ number = 11; document.getElementById("equalBreaksText").value = 12; } //get the min/max-Values of the active Layer from an Array: var breakStep = (maxValues[activeLayer] - minValues[activeLayer]) / (number + 1); //size of one class var colorArray = generateColor(colorStart, colorEnd, number); //generates an array of an color gradient symbol = new esri.symbol.SimpleFillSymbol(); symbol.setColor(new dojo.Color([150, 150, 150, 0.75])); var renderer = new esri.renderer.ClassBreaksRenderer(symbol, attributeFields[activeLayer] + currentYear); for (var i = 0; i <= number; i++) { var min = minValues[activeLayer] + i * breakStep; var max = minValues[activeLayer] + (i + 1) * breakStep; renderer.addBreak({ minValue: min, maxValue: max, symbol: new esri.symbol.SimpleFillSymbol().setColor(dojo.colorFromHex('#' + colorArray)), label: min + " - " + max }); } //delete the entrys of the manual classification: var breaksList = document.getElementById("Breaks"); breaksList.innerHTML = ''; breakCount = 0; //following from the ArcGIS Server JS-API: var optionsArray = []; var drawingOptions = new esri.layers.LayerDrawingOptions(); drawingOptions.renderer = renderer; optionsArray[activeLayer] = drawingOptions; operationalLayer.setLayerDrawingOptions(optionsArray); legend.refresh(); }
function exportMap(){ exportTitle = document.getElementById("mapExportTitle").value; //a text-field to enter a title exportAuthor = document.getElementById("mapExportAuthor").value; //a text-field to enter an author var legendLayer = new esri.tasks.LegendLayer(); legendLayer.layerId = "collection"; // "collection" is the id of the operationalLayer //printer if(printer != undefined){ printer.destroy(); } printer = new esri.dijit.Print({ map: map, templates: [{ label: "PNG Hochformat", format: "PNG32", layout: "A4 Portrait", layoutOptions: { titleText: exportTitle, authorText: exportAuthor, scalebarUnit: 'Kilometer', legendLayers: [legendLayer] } },{ label: "PNG Querformat", format: "PNG32", layout: "A4 Landscape", layoutOptions: { titleText: exportTitle, authorText: exportAuthor, scalebarUnit: 'Kilometer', legendLayers: [legendLayer] } }], url: "http://.../arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task/" }, dojo.byId("printButton")); document.getElementById("exportWarning").innerHTML = "Achtung: Das exportieren der Karte kann einige Sekunden in Anspruch nehmen."; printer.startup(); dojo.connect(printer,'onPrintStart',function(){ console.log('The print operation has started'); document.getElementById("loadingImage").style.visibility = "visible"; }); dojo.connect(printer,'onPrintComplete',function(value){ console.log('The url to the print image is : ' + value.url); document.getElementById("loadingImage").style.visibility = "hidden"; }); }
Solved? Have you looked at the JSON passed to the print service? A nice way to review the JSON is with JSONLint - The JSON Validator.