I was missing a pesky ;Used:// get print templates from the export web map task
var printInfo = esri.request({
"url": printURL,
"content": { "f": "json" }
});
printInfo.then(handlePrintInfo, handleError);
function handlePrintInfo(resp) {
var layoutTemplate, templateNames, mapOnlyIndex, templates;
layoutTemplate = dojo.filter(resp.parameters, function(param, idx) {
return param.name === "Layout_Template";
});
if ( layoutTemplate.length == 0 ) {
console.log("print service parameters name for templates must be \"Layout_Template\"");
return;
}
templateNames = layoutTemplate[0].choiceList;
// remove the MAP_ONLY template then add it to the end of the list of templates
mapOnlyIndex = dojo.indexOf(templateNames, "MAP_ONLY");
if ( mapOnlyIndex > -1 ) {
var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0];
templateNames.push(mapOnly);
}
// create a print template for each choice
templates = dojo.map(templateNames, function(ch) {
var plate = new esri.tasks.PrintTemplate();
plate.layout = plate.label = ch;
plate.format = "PDF";
plate.layoutOptions = {
"authorText": "Made by: Marion County Information Technology",
"copyrightText": "Maps are for display purposes only",
"legendLayers": [],
"titleText": "Marion County Parks",
"scalebarUnit": "Miles"
};
return plate;
});
// create the print dijit
var printer = new esri.dijit.Print({
"map": map,
"templates": templates,
url: printURL
}, dojo.byId("print_button"));
printer.startup();
}
function handleError(err) {
alert(err);
console.log("Something broke: ", err);
}
}
and now want to call it using the button I placed in the header:<td align="center" style="width: 40px;" valign="middle">
<button dojotype="dijit.form.ToggleButton" id="imgprint" title="Print Map" onclick="window.print();">
<img style="border:none;" src="images/print.png" alt="Print Map"/>
</td>
Should I change the html to reference "print_button" since that is what it is expecting?