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.
Çankaya,
What browser and version are you using?
Robert,
Chrome: 54.0.2840.71 m
Firefox: 49.0.2
Testing in both.
Çankaya,
I am at a loss here. I don't know why you are getting "Get Layout Templates Info Error".
Robert,
I managed to get rid of the error. Also, method #1 working fine now, so I can manually add values to the printout. The only problem is to make it automatically.
Can you tell me if there is something missing from the code below? (The rest of Print.js is unchanged v2.2)
template.showAttribution = false;
//See if there is a parcel search layer added to the map var plyr; array.some(this.map.graphicsLayerIds, lang.hitch(this, function (layerId) { var lyr = this.map.getLayer(layerId); if(lyr.name === "Search Results: Parcels"){ plyr = lyr; return true; } })); if(plyr){ var xppins = "", obj, cTextElements = []; array.map(plyr.graphics, lang.hitch(this, function(gra, index){ if (plyr.graphics.length === 1){ obj = {DistrictName: "District Name: " + gra.attributes.NAME}; cTextElements.push(obj); } else if (plyr.graphics.length > 1){ } template.layoutOptions.customTextElements = cTextElements; })); } //end my change
Çankaya,
Do you have more than one parcel selected? I don't see anything wrong with that code.
Nope, I just select 1 feature, popup shows up, then I use print widget.
Çankaya,
Try updating to this code and then check you browsers web console for the messages:
//See if there is a parcel search layer added to the map
var plyr;
array.some(this.map.graphicsLayerIds, lang.hitch(this, function (layerId) {
var lyr = this.map.getLayer(layerId);
if(lyr.name === "Search Results: Parcels"){
plyr = lyr;
return true;
}
}));
if(plyr){
console.info("we found the layer");
var xppins = "", obj, cTextElements = [];
array.map(plyr.graphics, lang.hitch(this, function(gra, index){
if (plyr.graphics.length === 1){
console.info("there is only one feature in the layer");
obj = {DistrictName: "District Name: " + gra.attributes.NAME};
cTextElements.push(obj);
console.info(obj);
} else if (plyr.graphics.length > 1){
}
template.layoutOptions.customTextElements = cTextElements;
}));
}
//end my change
Çankaya,
Make sure you are adding the eSeach layer as an operational layer.
Hello Robert,
I placed some console messages here and there as you asked.
var plyr; array.some(this.map.graphicsLayerIds, lang.hitch(this, function (layerId) { console.info("layerId: ", layerId); var lyr = this.map.getLayer(layerId); console.info("layer name: ", lyr.name); if (lyr.name === "Search Results: Parcels") { plyr = lyr; return true; } }));
I get my layer names & ids first, then;
layerId: labels
layer name: undefined
layerId: graphicsLayer3
layer name: undefined
Any idea why the name is passed as undefined?
Thanks
Çankaya,
Please use the advanced editor to attach your eSearch widget config_Enhanced Search Widget.json