标签:gis
备注:防止中文乱码,中文字体选用“微软雅黑”。
function Print(printTitle) { //var printTitle = $("#ipttitle").val(); var legend = $("#Checkbox1").prop("checked"); var printTask = new esri.tasks.PrintTask(printUrl); //打印模板 var template = new esri.tasks.PrintTemplate(); template.format = "JPG"; template.label = "Portrait (Image)"; //template.layout = "Letter ANSI A Landscape"; template.layout = "printtemplate";//这是本人自定义的地图模板,不是arcgis系统自带的 //获取所有图层的Id var arrlegend = []; for (var j = 0; j < map.layerIds.length; j++) { var layerid = "layer" + j; arrlegend.push({ "layerId": layerid });//根据图层id,打印对应的图例 } var options = { scaleBarUnit: "Miles", legendLayers: arrlegend, titleText: printTitle }; if (!legend) { options.legendLayers = [];//图例数组为空时,不打印图例 } template.layoutOptions = options; //打印参数 var params = new esri.tasks.PrintParameters(); params.map = map; params.template = template; printTask.execute(params, printResult,printError); } function printError(error) { var error = error; $("#btnPrint").removeAttr("disabled"); } function printResult(result) { $("#btnPrint").removeAttr("disabled"); var url = result.url; var str = "<br/>" + "<a href=‘" + url + "‘ target=‘_blank‘>打印输出</a>"; $("#PrintResult").html(str); }
本文出自 “IT技术学习与交流” 博客,谢绝转载!
标签:gis
原文地址:http://qing0991.blog.51cto.com/1640542/1842079