[GIS] Print Selected Area in Map in Arcgis javascript API

arcgis-javascript-apicartographyprinting

I'm working on arcgis javascript api, and I'm trying to implement a selection print tool, I'm new to this api, and don't know how to select area of the map, and after that, print the selected drawn area. Any help?

Best Answer

As far as I can tell, you'll need to just zoom in on the selected area and print it, assuming you're using the Print Task found here: https://developers.arcgis.com/javascript/jsapi/printtask-amd.html. It doesn't look like there's an option to print only part of what's visible.

Note: The PrintTask requires an ArcGIS Server 10.1 Export Web Map Task. So make sure you've got that first.

Create a navigation toolbar and set it to ZOOM_IN: https://developers.arcgis.com/javascript/jsapi/navigation-amd.html. That will be your "select an area of the map".

Now, there is also an option that's just referred to as "export": http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Map/02r3000000v7000000/

1) This is not the same thing as the Export Web Map task.

2) It does not print the basemap, only the layers on your server.

3) It does allow you to specify a bounding box.

If export is available on your server and you choose this option you'll want to use the Draw toolbar instead of the navigation area: https://developers.arcgis.com/javascript/jsapi/draw-amd.html. Get the extent of the shape once it's drawn and pass the xmin, ymin, xmax, ymax to the export function.