PrintViewModel
require(["esri/widgets/Print/PrintViewModel"], function(PrintVM) { /* code goes here */ });
esri/widgets/Print/PrintViewModel
Provides the logic for the Print widget.
var view = new MapView({
container: "viewDiv",
map: map
});
var print = new Print({
viewModel: new PrintVM({
view: view
})
});
Constructors
- new PrintViewModel(properties)
- Parameter:properties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
String | The name of the class. more details | more details | Accessor | |
String | The URL of the REST endpoint of the Export Web Map Task. more details | more details | PrintViewModel | |
Boolean | When | more details | PrintViewModel | |
String | The view model's state. more details | more details | PrintViewModel | |
Object | The service metadata that contains the format and layout information for the printout. more details | more details | PrintViewModel | |
Number | The time interval in milliseconds between each job status request sent to an asynchronous GP task. more details | more details | PrintViewModel | |
MapView | The view from which the widget will operate. more details | more details | PrintViewModel |
Property Details
- Since: ArcGIS API for JavaScript 4.7
The name of the class. The declared class name is formatted as
esri.folder.className
.
- printServiceUrl String
The URL of the REST endpoint of the Export Web Map Task.
- scaleEnabled Boolean
When
true
, scale is used in the printed map.- Default Value:false
- state Stringreadonly
The view model's state.
Possible Values:"disabled"|"initializing"|"ready"|"error"
- Default Value:disabled
- templatesInfo Objectreadonly
- Example:
const print = new Print({ view: view, printServiceUrl: url }); view.ui.add(print, {position: "top-right"}); console.log("PrintViewModel templatesInfo Formats: ", print.viewModel.templatesInfo.format.choiceList); console.log("PrintViewModel templatesInfo Layouts: ", print.viewModel.templatesInfo.layout.choiceList);
- updateDelay Number
The time interval in milliseconds between each job status request sent to an asynchronous GP task.
- Default Value:1000
- view MapView
The view from which the widget will operate.
Method Overview
Name | Return Type | Summary | Class | |
---|---|---|---|---|
Promise | This method should be called to load the view model's printing resources. more details | more details | PrintViewModel | |
Promise<Object> | Prints (exports) the current MapView according to selected options. more details | more details | PrintViewModel |
Method Details
- load(){Promise}
This method should be called to load the view model's printing resources.
Returns:Type Description Promise When resolved, the view model has loaded the print service metadata necessary for printing.
Prints (exports) the current MapView according to selected options.
Parameter:printTemplate PrintTemplateThe PrintTemplate is used to specify the layout template options which is then used by the PrintTask to generate the print page.
Returns:Type Description Promise<Object> Resolves to an object with the following properties: Property Type Description url String URL to the exported printout.