Add the print widget to a button

499
2
Jump to solution
08-27-2021 08:48 AM
socialpromotions
New Contributor II

Hi all, I have added the print widget to my web map but right now it is always present there on the map in a big window and takes up a lot of space. I would like to move this widget to a button which when clicked opens the widget preferably like other buttons in the image. I am new to javascript so some details would be really helpful. I have only added this code from ArcGIS API with no div which already adds the widget to the map. 

var print = new Print({
       view: view
      });
// Adds widget below other elements in the top left corner of the view
      view.ui.add(print"top-right");

  });
 
Would also like to know if anyone has other references for a different print widget that gives option to set extent of the map to be printed/exported. This does allow to set the extent of the map to be printed, but only by providing width and height by numbers without any preview. It does not neccessarily have to come with layout view with scale and everything.
Thanks
0 Kudos
1 Solution

Accepted Solutions
BenRomlein
Occasional Contributor

Check out the expand widget: https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html

var print = new Print({
       view: view
      });

printExpand = new Expand({
  expandIconClass: "esri-icon-printer",
  expandTooltip: "Expand Print",
  view: view,
  content: print
});

view.ui.add(printExpand, "top-right");

;

View solution in original post

2 Replies
BenRomlein
Occasional Contributor

Check out the expand widget: https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html

var print = new Print({
       view: view
      });

printExpand = new Expand({
  expandIconClass: "esri-icon-printer",
  expandTooltip: "Expand Print",
  view: view,
  content: print
});

view.ui.add(printExpand, "top-right");

;

socialpromotions
New Contributor II

Works great. Thank you!!