Hi,
I am adding a custom widget to send an email with some description and map screenshot.Is there a way that I can create an attachment with the current map screen shot and is there any geoprocessing service to send an email ?
Thank you!
esri user,
I use the Print service for this with the map only template chosen.
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> <SPAN class="string token">'esri/tasks/PrintTemplate'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'esri/tasks/PrintParameters'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'esri/tasks/PrintTask'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> PrintTemplate<SPAN class="punctuation token">,</SPAN> PrintParameters<SPAN class="punctuation token">,</SPAN> PrintTask<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> map<SPAN class="punctuation token">.</SPAN>infoWindow<SPAN class="punctuation token">.</SPAN><SPAN class="token function">hide</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> oWid <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN>width<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> oHgt <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN>height<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> printTask <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PrintTask</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'.../rest/services/ExportWebMap/GPServer/Export_Web_Map'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> template <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PrintTemplate</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//calc for maintaining the maps aspect ratio</SPAN> template<SPAN class="punctuation token">.</SPAN>exportOptions <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN> width<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">1542</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">1542</SPAN> <SPAN class="operator token">/</SPAN> oWid<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> oHgt<SPAN class="punctuation token">,</SPAN> dpi<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">200</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>imgHeight <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">1542</SPAN> <SPAN class="operator token">/</SPAN> oWid<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> oHgt<SPAN class="punctuation token">;</SPAN> template<SPAN class="punctuation token">.</SPAN>format <SPAN class="operator token">=</SPAN> <SPAN class="string token">'jpg'</SPAN><SPAN class="punctuation token">;</SPAN> template<SPAN class="punctuation token">.</SPAN>layout <SPAN class="operator token">=</SPAN> <SPAN class="string token">'MAP_ONLY'</SPAN><SPAN class="punctuation token">;</SPAN> template<SPAN class="punctuation token">.</SPAN>preserveScale <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN> template<SPAN class="punctuation token">.</SPAN>showAttribution <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN> template<SPAN class="punctuation token">.</SPAN>outScale <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getScale</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> params <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PrintParameters</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> params<SPAN class="punctuation token">.</SPAN>map <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">;</SPAN> params<SPAN class="punctuation token">.</SPAN>template <SPAN class="operator token">=</SPAN> template<SPAN class="punctuation token">;</SPAN> printTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">execute</SPAN><SPAN class="punctuation token">(</SPAN>params<SPAN class="punctuation token">,</SPAN> printResult<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="token function">printResult</SPAN><SPAN class="punctuation token">(</SPAN>rsltURL<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> mapImg <SPAN class="operator token">=</SPAN> domConstruct<SPAN class="punctuation token">.</SPAN><SPAN class="token function">toDom</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'<img src="'</SPAN> <SPAN class="operator token">+</SPAN> rsltURL<SPAN class="punctuation token">.</SPAN>url <SPAN class="operator token">+</SPAN> <SPAN class="string token">'" border="0" style="width:740px;height:"'</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>imgHeight <SPAN class="operator token">+</SPAN> <SPAN class="string token">';"/>'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> domConstruct<SPAN class="punctuation token">.</SPAN><SPAN class="token function">place</SPAN><SPAN class="punctuation token">(</SPAN>mapImg<SPAN class="punctuation token">,</SPAN> mapImgDiv<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'replace'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
ArcGIS Server/Portal does not come with an email server. If you have access to an email server then I imagine you could set this up.
Is there a custom code or widget that take a screen shot of the webapp window and give the option to save the image file ?
There are two ways to do this that I know of. If it's a 3D sceneview in the 4.X API you can use scene.takeScreenshot. If you're using 3D I can give you an example.
If you're not, I recommend using this third party open source library: GitHub - tsayen/dom-to-image: Generates an image from a DOM node using HTML5 canvas
I know a few people who have successfully extracted a jpg from a 2D map using that.
Thank you Thomas! I am using 2D map, and above one seems not supported in all browsers
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.