GeoProcessing or PrintTask example using Quickstart?
Wondering if anyone could share a sample using either a GPtask or PrintTask within a Quickstart-like (MVVM) example.
I like how the databinding is working in the quickstart example, but i am trying to put the PrintTask code in the ViewModel and getting a bit stumped.
I added a /// <reference path="../../../Libs/jsapi_v311.js.d.ts"/> so that i can reference esri.task objects, but i can't seem to create the objects at runtime. I get ' TypeError: Object doesn't support this action' which I think is telling me that it doesn't know about the object types i'm creating.
Is this reference only for the typescript intellisense stuff? do i need to put this code else where, or just have include's elsewhere?
-
Hi Ryan, do you mind posting the code that is failing, e.g. the line with "new"?
0 -
Hi Ryan,
You'll likely need to require the correct modules. Since the Esri library is AMD, you need to ask for the 'pieces' you want to use and load them as needed. This way, the whole library isn't loaded which could bog down loadtimes.
See the require at https://developers.arcgis.com/javascript/jsapi/printtask-amd.html
-Kevin
0 -
So... how would the 'require' look in the mvvm setting of the quickstart (which file / or if in ViewModel, can i declare for the whole 'class')...
For example if i have my files:
TemplateModule.css
TemplateModule.tsTemplateModuleView.html
TemplateModuleView.ts
TemplateModuleViewModel.ts
In TemplateModuleViewModel.ts for this dumbed down example the constructor gives the error "Error in Template moduleTypeError: Object doesn't support this action "
/// <reference path="../../../Libs/Framework.d.ts" />
/// <reference path="../../../Libs/Mapping.Infrastructure.d.ts" />
/// <reference path="../../../Libs/jsapi_v311.js.d.ts"/>
module quickStart.template {
export class TemplateModuleViewModel extends geocortex.framework.ui.ViewModelBase {
app: geocortex.essentialsHtmlViewer.ViewerApplication;
greeting: Observable<string> = new Observable<string>();
printTask: any = null;
constructor(app: geocortex.essentialsHtmlViewer.ViewerApplication, lib: string) {
super(app, lib);
}
initialize(config: any): void {
try {
if (config) {
this.greeting.set(config["greeting"] || this.app.getResource(this.libraryId, "hello-world-greeting"));
}
var printURL = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
this.app.trace.info("before print constructor");
this.printTask = new esri.tasks.PrintTask(printURL, { async: true });
this.app.trace.info("after print constructor");
} catch (err) {
this.app.trace.error("Error in Template module" + err.toString());
}
}
}
}0 -
Hi Ryan,
You could use a legacy dojo.declare and add it to index.html (this is where the product puts the requires). In the upcoming release of 2.4 the index.html will include a dojo.require("esri.tasks.PrintTask"); so moving forward you won't have to worry about requiring this module.
Cheers,
Kevin0 -
Never even crossed my mind to look there. This was all i needed.
Thanks Kevin!
0
Please sign in to leave a comment.
Comments
5 comments