URL in popup to print selected feature and attributes

807
4
07-24-2019 01:14 PM
Claire_Peterson
Occasional Contributor

I have been working at this for a week no with no luck and I am not sure if I am going about this the correct way. I have gone through the examples that Tanu has posted about https://www.esri.com/arcgis-blog/products/arcgis-enterprise/uncategorized/printing-popups-from-web-a...Printing Popups from Web Application, etc but nothing seems to work.

I don't want to create another web application just to print this information so what we are looking for is to have a hyperlink in the features popup (shown below) that opens a new page with the objectid in the URL. I'd like to automatically generate a PDF with clicking on "Generate Map" that displays the feature that has a matching objectid to what is in the URL along with some additional layers and a few important attributes below the map.

Right now I have a php file that opens up an HTML page that displays a map with the feature layers along with the attributes that queries the objectid in the URL but I cannot get the map to display only that feature.

Another route I have taken is to publish a printing service that has a template I created but I am unable to pass any of the attributes to the layout. 

Does anyone have any tips or information on how to do this? I am a novice when it comes to JavaScript, ArcPy, etc .

0 Kudos
4 Replies
KellyHutchins
Esri Frequent Contributor

One option might be to use the screenshot widget that is available on GitHub: 

https://github.com/Esri/screenshot-widget

It allows you to generate an image that optionally contains the legend and popup. You can see how it works in this app by using the 'Take a screenshot' tool in the upper left corner below the Home extent button. 

http://www.arcgis.com/apps/InteractiveLegend/index.html?appid=4c19fd54446c474cab2277f02b3c74aa

0 Kudos
Claire_Peterson
Occasional Contributor

Hi Kelly,

Is there any way to do this onload versus having the user physically draw out the area?

I have already created a map in the 3.29 version of the API that does everything I need it to - has a set container size, zooms in to the feature based on the ID in the URL, highlights the feature and hides the rest of the features in that layer. I spoke with someone yesterday and they mentioned that MapView in version 4.12 of the API may work but it's been very tricky updating the code from 3.29 to 4.12 and have it perform the same way.

I have a file that uses FPDF to generate a PDF and the goal is to take what appears in the HTML <div> (on the page with the Javascript) and place it in the PDF.

0 Kudos
KellyHutchins
Esri Frequent Contributor

The source code for the screenshot widget is available on GitHub. I'm sure it's possible to modify the code to bypass the draw portion and just print out a pre-defined extent. The code for the widget uses version 4.x of the JSAPI. 

0 Kudos
Claire_Peterson
Occasional Contributor

Hi Kelly - I don't think updating the our code to 4.x will be in the picture due to a time constraint. Is there anything available for 3.x that could satisfy my need? I have been trying to work with PrintTask/PrintTemplate/etc but honestly, none of it is making sense and I can't seem to get it to work.

I am using JS to create a new map (separate from the webmaps we already have created on AGO) that is bringing in rest services from our own server (one of which is under credentials) I have a screenshot button working but it only shows the basemap and no layers - even the layers with no credentials. All I really need is to take this map that I've created, turn it into an image/screenshot and place it into an HTML <div>.