I need to ask , how to check the passed legend layer info( json) into the printtemplate before printing.
Please geo programmers i need your assistance.
Solved! Go to Solution.
in order to check the layer before printing I found this URL it has the answer:
Thabo,
Are you using the Print Dijit or just some custom code that uses the PrintTask?
I am using Print task but not single function which runs on the click
attached is the code :
function printMap() {
console.log('Global Render
info')
console.log(global_renderer);
layer.setRenderer(global_renderer);
layer.redraw();
//createLegend(rendering.featureMap.fields[0]);
var legendLayer = new
LegendLayer();// Get the legend Layers
legendLayer.layerId =
layer.id;
console.log('legend Layer
for Print');
console.log(layer);
var printMap = new
esri.tasks.PrintTask("http://statscenprod:6080/arcgis/rest/services/ExportWebMap9/GPServer/Export%20Web%20Map");
var params = new
esri.tasks.PrintParameters();
var template = new
esri.tasks.PrintTemplate();
var txtmetadata =
document.getElementById("metadata").innerHTML;
var len = 35;
var curr = len;
var prev = 0;
alert(txtmetadata);
output = [];
var textmetaadat;
if (txtmetadata.length >
35)
{
while
(txtmetadata[curr]) {
if (
txtmetadata[curr++] == ' ') {
output.push(txtmetadata.substring(prev, curr).trim());
prev
= curr;
curr
+= len;
}
}
output.push(txtmetadata.substr(prev).trim());
var joinedtxt =
output.join('\n')
alert(joinedtxt);
textmetaadat =
"Metadata : " + "\n" + joinedtxt;
}
else
{
textmetaadat =
"Metadata : " + "\n" + document.getElementById("metadata").innerHTML;
}
template.exportOptions = ;
template.format = "pdf";
template.layout = "Letter
ANSI A Landscape6";
console.log(legendLayer);
template.preserveScale =
true;
template.showAttribution =
false;
template.layoutOptions =
]
};
params.map = map;
params.template = template;
printMap.execute(params,
printResult).then(function(resolvedVal){
console.log(resolvedVal);
// Logs the value the promise resolves to
});
};
function printResult(result) {
var time = new Date();
console.log(time.getTime())
window.open(result.url +=
"?Atlastimets=" + time.getTime());
console.log('check the layer
after printing')
console.log(layer);
};
$('#btn').click(function () {
printMap();
});
Regards
Thabo Gilbert Mojahi
Cell : 0713208732
Fax : 086 601 8766
Tel(office) : 012 310 6397
If people do not believe that mathematics is simple, it is only because
they do not realize how complicated life is. ~John Louis von Neumann
>>> "Robert Scheitlin, GISP" <geonet@esri.com> 10/10/2016 16:38 >>>
GeoNet
( https://community.esri.com/?et=watches.email.thread)
Re: Printask printtemplate legend issuereply from Robert Scheitlin,
GISP
( https://community.esri.com/people/rscheitlin?et=watches.email.thread)
in ArcGIS API for JavaScript - View the full discussion
(
https://community.esri.com/message/639938-re-printask-printtemplate-legend-issue?commentID=639938&et=watches.email.thread#comment-639938)
Thabo,
Are you using the Print Dijit or just some custom code that uses the
PrintTask?
Reply to this message by replying to this email, or go to the message
on GeoNet
(
https://community.esri.com/message/639938-re-printask-printtemplate-legend-issue?commentID=639938&et=watches.email.thread#comment-639938)
Start a new discussion in ArcGIS API for JavaScript by email
(
mailto:discussions-community-developers-webdevelopers-arcgisapiforjavascript@mail.geonet.esri.com)
or at GeoNet
(
https://community.esri.com/choose-container.jspa?contentType=1&containerType=14&container=2128&et=watches.email.thread)
Following Re: Printask printtemplate legend issue
(
https://community.esri.com/message/639938-re-printask-printtemplate-legend-issue?commentID=639938&et=watches.email.thread#comment-639938)
in these streams: Inbox
This email was sent by GeoNet because you are a registered user.
You may unsubscribe
(
https://community.esri.com/unsubscribe.jspa?email=thabomoj%40statssa.gov.za&token=8cc2f7c722630dbf4d0b040099a8f18de596fb44255fed8a1746a394189b9352)
instantly from GeoNet, or adjust email frequency in your email
preferences
( https://community.esri.com/user-preferences!input.jspa)
I needed to check the layer which the printtemplate receives so as to see if I am sending the right Layer.
However there is a problem with printing when I am rendering a field with ClassBreaksRenderer the legend renders perfectly with print legend , however when I am rendering I am rendering another field the sample attached
in order to check the layer before printing I found this URL it has the answer: