I'm in the process of converting some existing custom Geocortex tools to ESRI WAB and JSAPI web tools.
For one of these, what I'm looking to recreate is the ability to:
ESRI suggested that I look into using the Geoprocessing Widget to call a geoprocessing service that generates the maps. GP Widget looks promising.
QUESTION 1 - Is there another more appropriate out of the box offering? I've previously set up a custom print template on my hosting server, which worked fine. But what I need is a little more, I guess you'd say - complex. More like a fancy ultra print widget with the ability to pass in some parameters that are used as text in a print template.
Of course, I immediately started reading about arcpy.ConvertWebMapToArcGISProject(). The thought of working out my functionality in Python has a much great appeal than trying to whip up some jimu-jambalaya in WAB (sorry still not feeling the love).
QUESTION 2 - What is the easiest way for me to generate some sample JSON based off an actual web map of mine that I can use for testing with my geoprocessing code?
I could, of course, follow the guidelines here. But is there a simpler (lazier) way? Something similar to generating JSON output for a map service using the "?f=pjson." karate chop.
https://server.arcgisonline.com/arcgis/rest/services/Elevation/World_Hillshade_Dark/MapServer/0/?f=pjson
Hey, thanks for chiming in.
Solved! Go to Solution.
Just doing a post-mortem on this one: You can your JSON from esri/tasks/PrintTask, as explained here: Get the WebMap from Javascript API esri/map.
I am going to boldly answer Part 2 of my own question from last month (last year).
If you have a web map stored as an item in Portal, you can get a JSON representation of it using the following URL:
https://<yourwebadaptor>.<yourdomain>/portal/sharing/rest/content/items/<youritemsnearlyendlessandgibberishishID?f=pjson
Hold that thought, buster!
That's some pretty JSON but not at all like the kind I was looking for... which was:
{ "mapOptions": {},
"operationalLayers": [],
"baseMap": [], "
exportOptions": {},
"layoutOptions": {} }
What's going on here?!
Just doing a post-mortem on this one: You can your JSON from esri/tasks/PrintTask, as explained here: Get the WebMap from Javascript API esri/map.
So, it seems you figured it out! I'm trying to do the same things. I already have the first part of the workflow: I have a script that selects what I need. Next is to print out the map along with a summary of several attributes and a legend. My thought is to create a custom print service, but not sure how to incorporate this in my existing script (or, if I should). I really want to limit the number of clicks the user needs to do; ideally, they should be able to click the map, the GP tool should start running, then prompt the user to save a PDF map.
The "ConvertWebMapToArcGISProject" is a little confusing to me, though. I don't need to be able to open the map in ArcMap/Pro. Any thoughts/suggestions?
Agree with you, some of the ESRI examples look real straight forward until you try to solve a real world problem. For me it came down creating a GP Service in Python that does what I need with a map saved in APRX project. You can work in Pro or Python until you have that right. Once that's done, you call that services using...Geoprocessor.
Once you have an instance of a geoprocessing service to call and a printTask in Javascript, you can do something like:
var webMapAsJSON = printTask._getPrintDefinition(currentMap, params);
var webMapAsJSONasString = JSON.stringify(webMapAsJSON);
var file;
var gpParams = {"Web_Map_as_JSON" : webMapAsJSONasString,"PDFOutputFile" : file};
gp.submitJob(gpParams, this.completeCallback, this.statusCallback);
Let me know if that helps.
Thanks for your input. We're in the early stages, so I'll let you know when we get this implemented!