I have a Web Mapping Application with a standard Print Widget. I would like to include the contents of the popup window in the printout.
Here is an example:
GIS Portal for the City of Abilene, TX
Standard printout:
Popup window:
Desired printout:
My research so far:
There is a BLOG POST by esri explaining how to do this. This post shows 2 methods. The first method is not suitable for my purposes cause it requires manual data entries for each printout. The second method seems incomplete, Format & Layout_Template parameters are missing. Print does not work even if I add those parameters manually before publishing the service. If the second method worked properly, I would have modified it to match my needs, unfortunately it doesn't.
http://stackoverflow.com/questions/32363943/arcgis-javascript-web-map-printout-with-popup-shown
dojoOn(map.infoWindow, "selection-change", function(){ //build custom text here }
My knowledge on JavaScript is limited, so I couldn't manage what he explained here. Where am I supposed to add this and what should I include in the function?
We have the print button generating an html page that pulls data from the database and formats it in pretty much an exact replica of the .mxd we were using. For the map it uses a function on the rest endpoint to generate an image from the map service.
This seems even more complicated than the others.
Either one the above solutions works for me.
TL;DR I want to include popup window or it's contents in the printout.
Thanks in advance.
Solved! Go to Solution.
Hello again Robert,
var gra = this.map.infoWindow.getSelectedFeature(); var obj = { TXT1: "Name: " + gra.attributes.NAME };
Once a feature is selected, Popup Window is displayed. When Popup Window is closed, feature is no longer selected but the above code still uses the last selected feature.
How can I clear getSelectedFeature() when Popup Window is closed?
this.map.infoWindow.clearFeatures()
Thank you, but I meant where and can I handle the event when the Popup Window is closed.
I tried the ones below but didn't work.
map.infoWindow.on('hide', function(){ console.info("infoWindow hide event"); this.map.infoWindow.clearResults(); });
====================================
dojo.connect(map.infoWindow.hide, "onclick", function () { console.info("infoWindow hide event"); this.map.infoWindow.clearResults(); });
Mission accomplished.
this.map.infoWindow.on('hide', function(){ console.info("infoWindow hide event"); this.map.infoWindow.clearFeatures(); });
I am going to prepare a tutorial for printing popup contents soon.
Thank you Robert
// edit start var cTextElements = []; var gra = this.map.infoWindow.getSelectedFeature(); var obj = { TXT1: "Name: " + gra.attributes.NAME }; cTextElements.push(obj); template.layoutOptions.customTextElements = cTextElements; // edit end this.printparams.template = template;
utils.combineRadioCheckBoxWithLabel(extentRadio, this.printWidgetMapExtentLabel); // edit start this.map.infoWindow.on('hide', function () { this.map.infoWindow.clearFeatures(); }); // end edit
Hi Çankaya,
Thanks for your helpful write-up. I was able to publish GP service and set up the template and ready to populate attributes fields to the print outs.
However I always got field value as "undefined". I was wondering if you could share your Print.js and eSearch files if they have been customized so I can take a better look at the customization.
I am not a big JS user so kinda of trying to picking up things by self-learning.
Thanks in advance!
KP
Hello Kipo,
Sorry for the delay.
I have only made changes on Print.js and they are shown on the list above. Please check again. If you can't make it work, feel free to send me with your print.js so I can have a look.
Take care.
Thanks for your reply Cankaya.
I finally got it to work although I moved to other projects these days.
KP
Robert,
This method works great but how do I format the date and numeric fields?
See attached for fields "SALEDATE" AND "ACRES".
Rich,
You would use dojo formatters.
dojo/number — The Dojo Toolkit - Reference Guide
dojo/date/locale::format() — The Dojo Toolkit - Reference Guide